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

◆ find_index()

template<typename Key, typename T, typename Hash = Hash<Key>, typename KeyEqual = EqualTo<Key>, int INLINED_COUNT = FASTLED_HASHMAP_INLINED_COUNT>
size_t fl::HashMap< Key, T, Hash, KeyEqual, INLINED_COUNT >::find_index ( const Key & key) const
inlineprivate

Definition at line 391 of file hash_map.h.

391 {
392 const size_t cap = _buckets.size();
393 const size_t mask = cap - 1;
394 const size_t h = _hash(key) & mask;
395
397 // linear probing
398 for (size_t i = 0; i < cap; ++i) {
399 const size_t idx = (h + i) & mask;
400 if (is_empty(idx))
401 return npos;
403 return idx;
404 }
405 } else {
406 // quadratic probing up to 8 tries
407 size_t i = 0;
408 for (; i < kQuadraticProbingTries; ++i) {
409 const size_t idx = (h + i + i * i) & mask;
410 if (is_empty(idx))
411 return npos;
413 return idx;
414 }
415 // fallback to linear for the rest
416 for (; i < cap; ++i) {
417 const size_t idx = (h + i) & mask;
418 if (is_empty(idx))
419 return npos;
421 return idx;
422 }
423 }
424
425 return npos;
426 }
static constexpr size_t npos
Definition hash_map.h:291
bool is_empty(size_t idx) const
Definition hash_map.h:298
KeyEqual _equal
Definition hash_map.h:583
@ kQuadraticProbingTries
Definition hash_map.h:388
@ kLinearProbingOnlySize
Definition hash_map.h:387
bool is_occupied(size_t idx) const
Definition hash_map.h:294
fl::vector_inlined< Entry, INLINED_COUNT > _buckets
Definition hash_map.h:576

Referenced by fl::HashMap< Key, T, Hash, KeyEqual >::find(), fl::HashMap< Key, T, Hash, KeyEqual >::find(), fl::HashMap< Key, T, Hash, KeyEqual >::find_value(), fl::HashMap< Key, T, Hash, KeyEqual >::find_value(), and fl::HashMap< Key, T, Hash, KeyEqual >::remove().

+ Here is the caller graph for this function: