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);
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) {
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 }
void push_back(const T &value) FL_NO_EXCEPT
Definition deque.h:614
void pop_back() FL_NO_EXCEPT
Definition deque.h:656
iterator end() FL_NO_EXCEPT
Definition deque.h:515
fl::size mSize
Definition deque.h:42
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
Definition s16x16x4.h:30