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

◆ insert() [1/6]

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

Definition at line 324 of file unordered_map.h.

324 {
325 const bool will_rehash = needs_rehash();
326 if (will_rehash) {
327 // if half the buckets are tombstones, rehash inline to prevent
328 // memory spill over into the heap.
329 if (_tombstones > _size) {
331 } else {
332 rehash_internal(_buckets.size() * 2);
333 }
334 }
336 bool is_new;
338 idx = p.first;
339 is_new = p.second;
340 if (is_new) {
341 _buckets[idx].key = key;
342 _buckets[idx].value = value;
344 ++_size;
345 } else {
346 FASTLED_ASSERT(idx != npos(), "unordered_map::insert: invalid index at "
347 << idx << " which is " << npos());
348 _buckets[idx].value = value;
349 }
350 return {iterator(this, idx), is_new};
351 }
static fl::size npos()
void mark_occupied(fl::size idx)
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_NULL_DEREFERENCE void rehash_inline_no_resize()
fl::vector_inlined< Entry, INLINED_COUNT > _buckets
pair< fl::size, bool > find_slot(const Key &key) const
bool needs_rehash() const
void rehash_internal(fl::size new_cap)