FastLED
3.9.15
Loading...
Searching...
No Matches
◆
find_unoccupied_index_using_bitset()
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_unoccupied_index_using_bitset
(
const
Key
&
key
,
const fl::bitset< 1024 > &
occupied_set
) const
inline
private
Definition at line
547
of file
hash_map.h
.
548
{
549
const
fl::size
cap
=
_buckets
.size();
550
const
fl::size
mask
=
cap
- 1;
551
const
fl::size
h
=
_hash
(
key
) &
mask
;
552
553
if
(
cap
<=
kLinearProbingOnlySize
) {
554
// linear probing
555
for
(
fl::size
i
= 0;
i
<
cap
; ++
i
) {
556
const
fl::size
idx
= (
h
+
i
) &
mask
;
557
bool
occupied
=
occupied_set
.test(
idx
);
558
if
(
occupied
) {
559
continue
;
560
}
561
return
idx
;
562
}
563
}
else
{
564
// quadratic probing up to 8 tries
565
fl::size
i
= 0;
566
for
(;
i
<
kQuadraticProbingTries
; ++
i
) {
567
const
fl::size
idx
= (
h
+
i
+
i
*
i
) &
mask
;
568
bool
occupied
=
occupied_set
.test(
idx
);
569
if
(
occupied
) {
570
continue
;
571
}
572
return
idx
;
573
}
574
// fallback to linear for the rest
575
for
(;
i
<
cap
; ++
i
) {
576
const
fl::size
idx
= (
h
+
i
) &
mask
;
577
bool
occupied
=
occupied_set
.test(
idx
);
578
if
(
occupied
) {
579
continue
;
580
}
581
return
idx
;
582
}
583
}
584
return
npos
();
585
}
fl::HashMap::npos
static fl::size npos()
Definition
hash_map.h:408
fl::HashMap::kQuadraticProbingTries
@ kQuadraticProbingTries
Definition
hash_map.h:507
fl::HashMap::kLinearProbingOnlySize
@ kLinearProbingOnlySize
Definition
hash_map.h:506
fl::HashMap::_buckets
FL_DISABLE_WARNING_POP fl::vector_inlined< Entry, INLINED_COUNT > _buckets
Definition
hash_map.h:701
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