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 62 of file unordered_map_lru.h.

62 {
63 // Only evict if we're at capacity AND this is a new key
64 const ValueWithTimestamp *existing = mMap.find_value(key);
65
66 auto curr = mCurrentTime++;
67
68 if (existing) {
69 // Update the value and access time
71 const_cast<ValueWithTimestamp &>(*existing);
72 vwt.value = value;
73 vwt.last_access_time = curr;
74 return;
75 }
76 if (mMap.size() >= mMaxSize) {
78 }
79
80 // Insert or update the value with current timestamp
82 mMap.insert(key, vwt);
83 }
unordered_map< Key, ValueWithTimestamp, Hash, KeyEqual, INLINED_COUNT > mMap