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::unordered_map
<
Key
, T,
Hash
, KeyEqual, INLINED_COUNT >::find_index
(
const
Key
&
key
)
const
inline
private
Definition at line
907
of file
unordered_map.h
.
907
{
908
const
fl::size
cap
=
_buckets
.size();
909
const
fl::size
mask
=
cap
- 1;
910
const
fl::size
h
=
_hash
(
key
) &
mask
;
911
912
if
(
cap
<=
kLinearProbingOnlySize
) {
913
// linear probing
914
for
(
fl::size
i
= 0;
i
<
cap
; ++
i
) {
915
const
fl::size
idx
= (
h
+
i
) &
mask
;
916
if
(
is_empty
(
idx
))
917
return
npos
();
918
if
(
is_occupied
(
idx
) &&
_equal
(
_buckets
[
idx
].
key
,
key
))
919
return
idx
;
920
}
921
}
else
{
922
// quadratic probing up to 8 tries
923
fl::size
i
= 0;
924
for
(;
i
<
kQuadraticProbingTries
; ++
i
) {
925
const
fl::size
idx
= (
h
+
i
+
i
*
i
) &
mask
;
926
if
(
is_empty
(
idx
))
927
return
npos
();
928
if
(
is_occupied
(
idx
) &&
_equal
(
_buckets
[
idx
].
key
,
key
))
929
return
idx
;
930
}
931
// fallback to linear for the rest
932
for
(;
i
<
cap
; ++
i
) {
933
const
fl::size
idx
= (
h
+
i
) &
mask
;
934
if
(
is_empty
(
idx
))
935
return
npos
();
936
if
(
is_occupied
(
idx
) &&
_equal
(
_buckets
[
idx
].
key
,
key
))
937
return
idx
;
938
}
939
}
940
941
return
npos
();
942
}
fl::unordered_map::npos
static fl::size npos()
Definition
unordered_map.h:804
fl::unordered_map::_hash
Hash _hash
Definition
unordered_map.h:1123
fl::unordered_map::is_empty
bool is_empty(fl::size idx) const
Definition
unordered_map.h:813
fl::unordered_map::_equal
KeyEqual _equal
Definition
unordered_map.h:1124
fl::unordered_map::_buckets
fl::vector_inlined< Entry, INLINED_COUNT > _buckets
Definition
unordered_map.h:1117
fl::unordered_map::is_occupied
bool is_occupied(fl::size idx) const
Definition
unordered_map.h:809
fl::unordered_map::kLinearProbingOnlySize
@ kLinearProbingOnlySize
Definition
unordered_map.h:903
fl::unordered_map::kQuadraticProbingTries
@ kQuadraticProbingTries
Definition
unordered_map.h:904
fl::unordered_map
Definition
unordered_map.h:58
fl
unordered_map
Generated on Tue Jun 16 2026 00:07:07 for FastLED by
1.13.2