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
70
ValueWithTimestamp
&
vwt
=
71
const_cast<
ValueWithTimestamp
&
>
(*existing);
72
vwt
.value =
value
;
73
vwt
.last_access_time =
curr
;
74
return
;
75
}
76
if
(
mMap
.size() >=
mMaxSize
) {
77
evictOldest
();
78
}
79
80
// Insert or update the value with current timestamp
81
ValueWithTimestamp
vwt
(
value
,
mCurrentTime
);
82
mMap
.insert(
key
,
vwt
);
83
}
fl::HashMapLru::mMaxSize
fl::size mMaxSize
Definition
unordered_map_lru.h:171
fl::HashMapLru::mMap
unordered_map< Key, ValueWithTimestamp, Hash, KeyEqual, INLINED_COUNT > mMap
Definition
unordered_map_lru.h:170
fl::HashMapLru::mCurrentTime
u32 mCurrentTime
Definition
unordered_map_lru.h:172
fl::HashMapLru::evictOldest
void evictOldest()
Definition
unordered_map_lru.h:143
fl::HashMapLru
Definition
unordered_map_lru.h:22
fl::HashMapLru::ValueWithTimestamp
Definition
unordered_map_lru.h:25
fl
HashMapLru
Generated on Tue Jun 16 2026 00:07:05 for FastLED by
1.13.2