FastLED
3.9.15
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
355
of file
unordered_map.h
.
355
{
356
const
bool
will_rehash
=
needs_rehash
();
357
if
(
will_rehash
) {
358
// if half the buckets are tombstones, rehash inline to prevent
359
// memory spill over into the heap.
360
if
(
_tombstones
>
_size
) {
361
rehash_inline_no_resize
();
362
}
else
{
363
rehash_internal
(
_buckets
.size() * 2);
364
}
365
}
366
fl::size
idx
;
367
bool
is_new
;
368
fl::pair<fl::size, bool>
p
=
find_slot
(
key
);
369
idx
=
p
.first;
370
is_new
=
p
.second;
371
if
(
is_new
) {
372
_buckets
[
idx
].key =
fl::move
(
key
);
373
_buckets
[
idx
].value =
fl::move
(
value
);
374
mark_occupied
(
idx
);
375
++
_size
;
376
}
else
{
377
FASTLED_ASSERT
(
idx
!=
npos
(),
"unordered_map::insert: invalid index at "
378
<<
idx
<<
" which is "
<<
npos
());
379
_buckets
[
idx
].value =
fl::move
(
value
);
380
}
381
return
{
iterator
(
this
,
idx
),
is_new
};
382
}
fl::unordered_map::npos
static fl::size npos()
Definition
unordered_map.h:804
fl::unordered_map::mark_occupied
void mark_occupied(fl::size idx)
Definition
unordered_map.h:817
fl::unordered_map::rehash_inline_no_resize
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_NULL_DEREFERENCE void rehash_inline_no_resize()
Definition
unordered_map.h:1009
fl::unordered_map::_buckets
fl::vector_inlined< Entry, INLINED_COUNT > _buckets
Definition
unordered_map.h:1117
fl::unordered_map::_size
fl::size _size
Definition
unordered_map.h:1118
fl::unordered_map::find_slot
pair< fl::size, bool > find_slot(const Key &key) const
Definition
unordered_map.h:849
fl::unordered_map::needs_rehash
bool needs_rehash() const
Definition
unordered_map.h:318
fl::unordered_map::rehash_internal
void rehash_internal(fl::size new_cap)
Definition
unordered_map.h:984
fl::unordered_map::_tombstones
fl::size _tombstones
Definition
unordered_map.h:1119
fl::unordered_map
Definition
unordered_map.h:58
fl::fl::move
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
Definition
s16x16x4.h:28
fl::unordered_map::iterator
Definition
unordered_map.h:187
fl
unordered_map
Generated on Tue Jun 16 2026 00:07:07 for FastLED by
1.13.2