30 while (new_capacity < min_capacity) {
34 T* new_data =
static_cast<T*
>(
mResource->allocate(new_capacity *
sizeof(T)));
40 for (fl::size i = 0; i <
mSize; ++i) {
141 return !(*
this == other);
186 return &(*mDeque)[
mIndex];
244 return !(*
this == other);
300 if (
this != &other) {
302 for (fl::size i = 0; i < other.size(); ++i) {
310 if (
this != &other) {
322 other.mData =
nullptr;
339 T&
at(fl::size index) {
340 if (index >=
mSize) {
348 const T&
at(fl::size index)
const {
349 if (index >=
mSize) {
374 return iterator(
this, 0);
378 return const_iterator(
this, 0);
382 return iterator(
this,
mSize);
385 const_iterator
end()
const {
386 return const_iterator(
this,
mSize);
408 return const_iterator(
this, 0);
412 return const_iterator(
this,
mSize);
438 return static_cast<fl::size
>(-1) /
sizeof(T);
458 T* new_data =
static_cast<T*
>(
mResource->allocate(
mSize *
sizeof(T)));
464 for (fl::size i = 0; i <
mSize; ++i) {
523 mData[back_index].~T();
541 if (new_size >
mSize) {
544 while (
mSize < new_size) {
547 }
else if (new_size <
mSize) {
549 while (
mSize > new_size) {
557 if (
this != &other) {
558 T* temp_data =
mData;
560 fl::size temp_size =
mSize;
561 fl::size temp_front =
mFront;
570 other.
mData = temp_data;
572 other.
mSize = temp_size;
573 other.
mFront = temp_front;
580 fl::size index =
pos.mIndex;
584 for (fl::size i =
mSize; i > index; --i) {
588 mData[from_idx].~T();
596 return iterator(
this, index);
600 fl::size index =
pos.mIndex;
604 for (fl::size i =
mSize; i > index; --i) {
608 mData[from_idx].~T();
616 return iterator(
this, index);
620 fl::size index =
pos.mIndex;
624 for (fl::size i =
mSize + count - 1; i >= index + count; --i) {
625 fl::size from_idx =
get_index(i - count);
628 mData[from_idx].~T();
632 for (fl::size i = 0; i < count; ++i) {
633 fl::size insert_idx =
get_index(index + i);
638 return iterator(
this, index);
645 fl::size index =
pos.mIndex;
649 mData[erase_idx].~T();
652 for (fl::size i = index; i <
mSize - 1; ++i) {
656 mData[from_idx].~T();
660 return iterator(
this, index);
663 iterator
erase(const_iterator first, const_iterator last) {
664 if (first == last)
return iterator(
this, first.mIndex);
666 fl::size start_idx = first.mIndex;
667 fl::size count = last.mIndex - first.mIndex;
670 for (fl::size i = 0; i < count; ++i) {
671 fl::size destroy_idx =
get_index(start_idx + i);
672 mData[destroy_idx].~T();
676 for (fl::size i = start_idx; i <
mSize - count; ++i) {
677 fl::size from_idx =
get_index(i + count);
680 mData[from_idx].~T();
684 return iterator(
this, start_idx);
688 template<
typename... Args>
690 fl::size index =
pos.mIndex;
694 for (fl::size i =
mSize; i > index; --i) {
698 mData[from_idx].~T();
706 return iterator(
this, index);
709 template<
typename... Args>
715 return mData[back_index];
718 template<
typename... Args>
731 for (fl::size i = 0; i < count; ++i) {
741 for (fl::size i = 0; i <
mSize; ++i) {
742 if ((*
this)[i] != other[i]) {
750 return !(*
this == other);
755 for (fl::size i = 0; i < min_size; ++i) {
756 if ((*
this)[i] < other[i]) {
759 if ((*
this)[i] > other[i]) {
767 return *
this < other || *
this == other;
771 return other < *
this;
775 return *
this > other || *
this == other;
const_iterator(const iterator &it)
const T & operator*() const
fl::size operator-(const const_iterator &other) const
const_iterator operator+(fl::size n) const
bool operator!=(const const_iterator &other) const
const_iterator & operator+=(fl::size n)
bool operator>(const const_iterator &other) const
const_iterator & operator--()
const T * operator->() const
bool operator<(const const_iterator &other) const
bool operator==(const const_iterator &other) const
const_iterator operator--(int)
const_iterator(const deque *dq, fl::size index)
bool operator<=(const const_iterator &other) const
const_iterator operator++(int)
const T & operator[](fl::size n) const
bool operator>=(const const_iterator &other) const
const_iterator & operator++()
const_iterator & operator-=(fl::size n)
fl::random_access_iterator_tag iterator_category
const_iterator operator-(fl::size n) const
iterator(deque *dq, fl::size index)
bool operator>=(const iterator &other) const
bool operator!=(const iterator &other) const
iterator & operator-=(fl::size n)
T & operator[](fl::size n) const
fl::random_access_iterator_tag iterator_category
bool operator<(const iterator &other) const
bool operator==(const iterator &other) const
bool operator>(const iterator &other) const
iterator & operator+=(fl::size n)
fl::size operator-(const iterator &other) const
iterator operator-(fl::size n) const
iterator operator+(fl::size n) const
bool operator<=(const iterator &other) const
deque(fl::size count, const T &value=T())
memory_resource * mResource
const_iterator begin() const
T & operator[](fl::size index)
void push_back(T &&value)
const_reverse_iterator crend() const
bool operator<=(const deque &other) const
void push_front(const T &value)
bool operator!=(const deque &other) const
void push_front(T &&value)
deque & operator=(const deque &other) FL_NOEXCEPT
const_reverse_iterator rbegin() const
fl::reverse_iterator< const_iterator > const_reverse_iterator
fl::reverse_iterator< iterator > reverse_iterator
void resize(fl::size new_size, const T &value)
iterator emplace(const_iterator pos, Args &&... args)
bool operator<(const deque &other) const
T & emplace_back(Args &&... args)
fl::size capacity() const
deque(deque &&other) FL_NOEXCEPT
const_iterator cbegin() const
memory_resource * get_memory_resource() const
bool operator==(const deque &other) const
deque & operator=(deque &&other) FL_NOEXCEPT
void reserve(fl::size new_capacity)
bool operator>=(const deque &other) const
void resize(fl::size new_size)
void ensure_capacity(fl::size min_capacity)
const_iterator end() const
const_reverse_iterator crbegin() const
fl::size get_index(fl::size logical_index) const
deque(const deque &other) FL_NOEXCEPT
reverse_iterator rbegin()
iterator insert(const_iterator pos, T &&value)
iterator erase(const_iterator first, const_iterator last)
iterator insert(const_iterator pos, fl::size count, const T &value)
const T & at(fl::size index) const
fl::size max_size() const
T & emplace_front(Args &&... args)
const_iterator cend() const
static const fl::size kInitialCapacity
iterator insert(const_iterator pos, const T &value)
void assign(fl::size count, const T &value)
bool operator>(const deque &other) const
iterator erase(const_iterator pos)
const_reverse_iterator rend() const
void push_back(const T &value)
const T & operator[](fl::size index) const
deque(memory_resource *resource)
deque(fl::initializer_list< T > init)
Polymorphic memory resource base class (PMR-style).
Reverse iterator adapter - reverses the direction of a bidirectional iterator.
PMR-style polymorphic memory resource for type-erased allocation.
constexpr T && forward(typename remove_reference< T >::type &t) FL_NOEXCEPT
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
constexpr int type_rank< T >::value
void init(Context &ctx, int w, int h)
memory_resource * default_memory_resource() FL_NOEXCEPT
Get the default memory resource (wraps fl::Malloc / fl::Free / fl::realloc).
deque< float > deque_float
deque< double > deque_double
Base definition for an LED controller.