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>
fl::size
fl::HashMap
<
Key
, T,
Hash
, KeyEqual, INLINED_COUNT >::find_index
(
const
Key
&
key
)
const
inline
private
Definition at line
510
of file
hash_map.h
.
510
{
511
const
fl::size
cap
=
_buckets
.size();
512
const
fl::size
mask
=
cap
- 1;
513
const
fl::size
h
=
_hash
(
key
) &
mask
;
514
515
if
(
cap
<=
kLinearProbingOnlySize
) {
516
// linear probing
517
for
(
fl::size
i
= 0;
i
<
cap
; ++
i
) {
518
const
fl::size
idx
= (
h
+
i
) &
mask
;
519
if
(
is_empty
(
idx
))
520
return
npos
();
521
if
(
is_occupied
(
idx
) &&
_equal
(
_buckets
[
idx
].
key
,
key
))
522
return
idx
;
523
}
524
}
else
{
525
// quadratic probing up to 8 tries
526
fl::size
i
= 0;
527
for
(;
i
<
kQuadraticProbingTries
; ++
i
) {
528
const
fl::size
idx
= (
h
+
i
+
i
*
i
) &
mask
;
529
if
(
is_empty
(
idx
))
530
return
npos
();
531
if
(
is_occupied
(
idx
) &&
_equal
(
_buckets
[
idx
].
key
,
key
))
532
return
idx
;
533
}
534
// fallback to linear for the rest
535
for
(;
i
<
cap
; ++
i
) {
536
const
fl::size
idx
= (
h
+
i
) &
mask
;
537
if
(
is_empty
(
idx
))
538
return
npos
();
539
if
(
is_occupied
(
idx
) &&
_equal
(
_buckets
[
idx
].
key
,
key
))
540
return
idx
;
541
}
542
}
543
544
return
npos
();
545
}
fl::HashMap::npos
static fl::size npos()
Definition
hash_map.h:408
fl::HashMap::_equal
KeyEqual _equal
Definition
hash_map.h:708
fl::HashMap::kQuadraticProbingTries
@ kQuadraticProbingTries
Definition
hash_map.h:507
fl::HashMap::kLinearProbingOnlySize
@ kLinearProbingOnlySize
Definition
hash_map.h:506
fl::HashMap::is_occupied
bool is_occupied(fl::size idx) const
Definition
hash_map.h:413
fl::HashMap::_buckets
FL_DISABLE_WARNING_POP fl::vector_inlined< Entry, INLINED_COUNT > _buckets
Definition
hash_map.h:701
fl::HashMap::is_empty
bool is_empty(fl::size idx) const
Definition
hash_map.h:417
fl::HashMap::_hash
Hash _hash
Definition
hash_map.h:707
fl::HashMap
Definition
hash_map.h:60
fl
HashMap
Generated on Fri Aug 22 2025 20:59:36 for FastLED by
1.13.2