FastLED 3.9.15
Loading...
Searching...
No Matches

◆ insert()

template<typename Key, typename T, typename Hash = Hash<Key>, typename KeyEqual = EqualTo<Key>, int INLINED_COUNT = FASTLED_HASHMAP_INLINED_COUNT>
void fl::HashMapLru< Key, T, Hash, KeyEqual, INLINED_COUNT >::insert ( const Key & key,
const T & value )
inline

Definition at line 51 of file hash_map_lru.h.

51 {
52 // Only evict if we're at capacity AND this is a new key
53 const ValueWithTimestamp *existing = mMap.find_value(key);
54
55 auto curr = mCurrentTime++;
56
57 if (existing) {
58 // Update the value and access time
60 const_cast<ValueWithTimestamp &>(*existing);
61 vwt.value = value;
62 vwt.last_access_time = curr;
63 return;
64 }
65 if (mMap.size() >= mMaxSize) {
67 }
68
69 // Insert or update the value with current timestamp
71 mMap.insert(key, vwt);
72 }
HashMap< Key, ValueWithTimestamp, Hash, KeyEqual, INLINED_COUNT > mMap
uint32_t mCurrentTime

References evictOldest(), fl::HashMapLru< Key, T, Hash, KeyEqual, INLINED_COUNT >::ValueWithTimestamp::last_access_time, mCurrentTime, mMap, mMaxSize, and fl::HashMapLru< Key, T, Hash, KeyEqual, INLINED_COUNT >::ValueWithTimestamp::value.

+ Here is the call graph for this function: