FastLED
3.10.9
Loading...
Searching...
No Matches
◆
insert()
[2/3]
template<typename T>
iterator
fl::deque
< T >::insert
(
const_iterator
pos
,
fl::size
count
,
const T &
value
)
inline
Definition at line
757
of file
deque.h
.
757
{
758
fl::size
idx
=
pos
.mIndex;
759
if
(
count
== 0)
return
iterator
(
this
,
idx
);
760
fl::size
old_size
=
mSize
;
761
// Extend by `count` slots. First push uses `value` if the deque
762
// is empty, else copies the current back; subsequent pushes copy
763
// whatever's at the back now. All these copies will be overwritten
764
// by the shift + fill below.
765
for
(
fl::size
k
= 0;
k
<
count
; ++
k
) {
766
fl::size
before
=
mSize
;
767
if
(
mSize
== 0)
push_back
(
value
);
768
else
push_back
((*
this
)[
mSize
- 1]);
769
if
(
mSize
==
before
) {
770
// Allocation failed: drop the partial extension (FastLED #4899).
771
while
(
mSize
>
old_size
)
pop_back
();
772
return
end
();
773
}
774
}
775
// Shift elements [idx .. old_size) right by `count` slots.
776
for
(
fl::size
i
=
old_size
;
i
>
idx
; --
i
) {
777
(*this)[
i
- 1 +
count
] =
fl::move
((*
this
)[
i
- 1]);
778
}
779
for
(
fl::size
i
= 0;
i
<
count
; ++
i
) {
780
(*this)[
idx
+
i
] =
value
;
781
}
782
return
iterator
(
this
,
idx
);
783
}
fl::deque::iterator
Definition
deque.h:191
fl::deque::push_back
void push_back(const T &value) FL_NO_EXCEPT
Definition
deque.h:614
fl::deque::pop_back
void pop_back() FL_NO_EXCEPT
Definition
deque.h:656
fl::deque::end
iterator end() FL_NO_EXCEPT
Definition
deque.h:515
fl::deque::mSize
fl::size mSize
Definition
deque.h:42
fl::deque
Definition
deque.h:29
fl::fl::adl_barrier::move
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
Definition
s16x16x4.h:30
fl
deque
Generated on Mon Nov 2 2026 09:25:21 for FastLED by
1.13.2