Data structure largely mimicking std::deque, but using single preallocated ring buffer.
Declared in <util/vecdeque.h>
template<typename T>
class VecDeque;
More efficient and better memory locality than std::deque.
Most operations ({push_,pop_,emplace_,}{front,back}(), operator[], ...) are O(1), unless reallocation is needed (in which case they are O(n)).
Supports reserve(), capacity(), shrink_to_fit() like vectors.
No iterator support.
Data is not stored in a single contiguous block, so no data().
| Name | Description |
|---|---|
VecDeque [constructor] | Constructors |
~VecDeque [destructor] | Destroy a deque. |
operator= | Assignment operators |
back | back overloads |
capacity | Get the capacity of this deque (maximum size it can have without reallocating). |
clear | Resize the deque to be size 0. The capacity will remain unchanged. |
emplace_back | Construct a new element at the end of the deque. |
emplace_front | Construct a new element at the beginning of the deque. |
empty | Test whether the contents of this deque is empty. |
front | front overloads |
operator[] | Subscript operators |
pop_back | Remove the last element of the deque. Requires !empty(). |
pop_front | Remove the first element of the deque. Requires !empty(). |
push_back | push_back overloads |
push_front | push_front overloads |
reserve | Increase the capacity to capacity. Capacity will not shrink. |
resize | Resize the deque to be exactly size size (adding default-constructed elements if needed). |
shrink_to_fit | Make the capacity equal to the size. The contents does not change. |
size | Get the number of elements in this deque. |
swap | Swap two deques. |
| Name | Description |
|---|---|
operator<=> | Comparison between two deques, implementing lexicographic ordering on the contents. |
operator== | Equality comparison between two deques (only compares size+contents, not capacity). |
swap | Non-member version of swap. |