FastLED
3.10.9
Loading...
Searching...
No Matches
◆
insert()
[5/6]
template<typename
Key
, typename T, typename
Hash
= Hash<Key>, typename KeyEqual = EqualTo<Key>, int INLINED_COUNT = FASTLED_HASHMAP_INLINED_COUNT>
pair
<
iterator
, bool >
fl::unordered_map
<
Key
, T,
Hash
, KeyEqual, INLINED_COUNT >::insert
(
Key
&&
key
,
T &&
value
)
inline
Definition at line
357
of file
unordered_map.h
.
357
{
358
const
bool
will_rehash
=
needs_rehash
();
359
if
(
will_rehash
) {
360
// if half the buckets are tombstones, rehash inline to prevent
361
// memory spill over into the heap.
362
if
(
_tombstones
>
_size
) {
363
rehash_inline_no_resize
();
364
}
else
{
365
rehash_internal
(
_buckets
.size() * 2);
366
}
367
}
368
fl::size
idx
;
369
bool
is_new
;
370
fl::pair<fl::size, bool>
p
=
find_slot
(
key
);
371
idx
=
p
.first;
372
is_new
=
p
.second;
373
if
(
is_new
) {
374
_buckets
[
idx
].key =
fl::move
(
key
);
375
_buckets
[
idx
].value =
fl::move
(
value
);
376
mark_occupied
(
idx
);
377
++
_size
;
378
}
else
{
379
FASTLED_ASSERT
(
idx
!=
npos
(),
"unordered_map::insert: invalid index"
);
380
_buckets
[
idx
].value =
fl::move
(
value
);
381
}
382
return
{
iterator
(
this
,
idx
),
is_new
};
383
}
fl::unordered_map::rehash_internal
void rehash_internal(fl::size new_cap) FL_NO_EXCEPT
Definition
unordered_map.h:916
fl::unordered_map::needs_rehash
bool needs_rehash() const FL_NO_EXCEPT
Definition
unordered_map.h:321
fl::unordered_map::npos
static fl::size npos() FL_NO_EXCEPT
Definition
unordered_map.h:805
fl::unordered_map::_buckets
fl::vector_inlined< Entry, INLINED_COUNT > _buckets
Definition
unordered_map.h:1078
fl::unordered_map::_size
fl::size _size
Definition
unordered_map.h:1079
fl::unordered_map::mark_occupied
void mark_occupied(fl::size idx) FL_NO_EXCEPT
Definition
unordered_map.h:818
fl::unordered_map::rehash_inline_no_resize
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_NULL_DEREFERENCE void rehash_inline_no_resize() FL_NO_EXCEPT
Definition
unordered_map.h:972
fl::unordered_map::find_slot
pair< fl::size, bool > find_slot(const Key &key) const FL_NO_EXCEPT
Definition
unordered_map.h:850
fl::unordered_map::_tombstones
fl::size _tombstones
Definition
unordered_map.h:1080
fl::unordered_map
Definition
unordered_map.h:61
fl::fl::adl_barrier::move
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
Definition
s16x16x4.h:30
fl::unordered_map::iterator
Definition
unordered_map.h:190
fl
unordered_map
Generated on Mon Nov 2 2026 09:25:25 for FastLED by
1.13.2