19template <
typename Key,
typename T,
typename Hash = Hash<Key>,
20 typename KeyEqual = EqualTo<Key>,
21 int INLINED_COUNT = FASTLED_HASHMAP_INLINED_COUNT>
64 const ValueWithTimestamp *existing =
mMap.find_value(key);
70 ValueWithTimestamp &vwt =
71 const_cast<ValueWithTimestamp &
>(*existing);
73 vwt.last_access_time = curr;
82 mMap.insert(key, vwt);
87 ValueWithTimestamp *vwt =
mMap.find_value(key);
91 vwt->last_access_time = curr;
99 const ValueWithTimestamp *vwt =
mMap.find_value(key);
100 return vwt ? &vwt->value :
nullptr;
108 auto entry =
mMap.find_value(key);
111 entry->last_access_time = curr;
121 ValueWithTimestamp &vwt =
mMap[key];
122 vwt.last_access_time = curr;
153 for (
auto it =
mMap.begin(); it !=
mMap.end(); ++it) {
154 const auto &entry = *it;
155 const ValueWithTimestamp &vwt = entry.second;
157 if (vwt.last_access_time < oldest_time) {
158 oldest_time = vwt.last_access_time;
159 oldest_key = entry.first;
166 mMap.remove(oldest_key);
memory_resource * get_memory_resource() const
T & operator[](const Key &key)
fl::size capacity() const
HashMapLru(fl::size max_size, memory_resource *resource)
unordered_map< Args, ValueWithTimestamp, Hash< Args >, EqualTo< Args >, FASTLED_HASHMAP_INLINED_COUNT > mMap
T * find_value(const Key &key)
void insert(const Key &key, const T &value)
void swap(HashMapLru &other)
HashMapLru(fl::size max_size)
bool remove(const Key &key)
const T * find_value(const Key &key) const
void setMaxSize(fl::size max_size)
Polymorphic memory resource base class (PMR-style).
PMR-style polymorphic memory resource for type-erased allocation.
void swap(T &a, T &b) FL_NOEXCEPT
constexpr int type_rank< T >::value
fl::u64 time() FL_NOEXCEPT
Alias for millis64() - returns 64-bit millisecond time.
Base definition for an LED controller.
ValueWithTimestamp() FL_NOEXCEPT
ValueWithTimestamp(const T &v, u32 time)
static constexpr T max() FL_NOEXCEPT