FastLED
3.9.15
Loading...
Searching...
No Matches
◆
find_slot()
template<typename
Key
, typename T, typename
Hash
= Hash<Key>, typename KeyEqual = EqualTo<Key>, int INLINED_COUNT = FASTLED_HASHMAP_INLINED_COUNT>
pair
< fl::size, bool >
fl::unordered_map
<
Key
, T,
Hash
, KeyEqual, INLINED_COUNT >::find_slot
(
const
Key
&
key
)
const
inline
private
Definition at line
849
of file
unordered_map.h
.
849
{
850
const
fl::size
cap
=
_buckets
.size();
851
const
fl::size
mask
=
cap
- 1;
852
const
fl::size
h
=
_hash
(
key
) &
mask
;
853
fl::size
first_tomb
=
npos
();
854
855
if
(
cap
<= 8) {
856
// linear probing
857
for
(
fl::size
i
= 0;
i
<
cap
; ++
i
) {
858
const
fl::size
idx
= (
h
+
i
) &
mask
;
859
860
if
(
is_empty
(
idx
))
861
return
{
first_tomb
!=
npos
() ?
first_tomb
:
idx
,
true
};
862
if
(
is_deleted
(
idx
)) {
863
if
(
first_tomb
==
npos
())
864
first_tomb
=
idx
;
865
}
else
if
(
is_occupied
(
idx
) &&
_equal
(
_buckets
[
idx
].
key
,
key
)) {
866
return
{
idx
,
false
};
867
}
868
}
869
}
else
{
870
// quadratic probing up to 8 tries
871
fl::size
i
= 0;
872
for
(;
i
< 8; ++
i
) {
873
const
fl::size
idx
= (
h
+
i
+
i
*
i
) &
mask
;
874
875
if
(
is_empty
(
idx
))
876
return
{
first_tomb
!=
npos
() ?
first_tomb
:
idx
,
true
};
877
if
(
is_deleted
(
idx
)) {
878
if
(
first_tomb
==
npos
())
879
first_tomb
=
idx
;
880
}
else
if
(
is_occupied
(
idx
) &&
_equal
(
_buckets
[
idx
].
key
,
key
)) {
881
return
{
idx
,
false
};
882
}
883
}
884
// fallback to linear for the rest
885
for
(;
i
<
cap
; ++
i
) {
886
const
fl::size
idx
= (
h
+
i
) &
mask
;
887
888
if
(
is_empty
(
idx
))
889
return
{
first_tomb
!=
npos
() ?
first_tomb
:
idx
,
true
};
890
if
(
is_deleted
(
idx
)) {
891
if
(
first_tomb
==
npos
())
892
first_tomb
=
idx
;
893
}
else
if
(
is_occupied
(
idx
) &&
_equal
(
_buckets
[
idx
].
key
,
key
)) {
894
return
{
idx
,
false
};
895
}
896
}
897
}
898
899
return
{
npos
(),
false
};
900
}
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_deleted
bool is_deleted(fl::size idx) const
Definition
unordered_map.h:811
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
Definition
unordered_map.h:58
fl
unordered_map
Generated on Tue Jun 16 2026 00:07:07 for FastLED by
1.13.2