Data structure largely mimicking std::deque, but using single preallocated ring buffer.
Synopsis
Declared in <util/vecdeque.h>
template<typename T>
class VecDeque;
Description
-
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().
Member Functions
Name |
Description |
|
Constructors |
|
Destroy a deque. |
Assignment operators |
|
|
|
Get the capacity of this deque (maximum size it can have without reallocating). |
|
Resize the deque to be size 0. The capacity will remain unchanged. |
|
Construct a new element at the end of the deque. |
|
Construct a new element at the beginning of the deque. |
|
Test whether the contents of this deque is empty. |
|
|
|
Subscript operators |
|
Remove the last element of the deque. Requires !empty(). |
|
Remove the first element of the deque. Requires !empty(). |
|
|
|
|
|
Increase the capacity to capacity. Capacity will not shrink. |
|
Resize the deque to be exactly size size (adding default‐constructed elements if needed). |
|
Make the capacity equal to the size. The contents does not change. |
|
Get the number of elements in this deque. |
|
Swap two deques. |
Friends
Name |
Description |
Comparison between two deques, implementing lexicographic ordering on the contents. |
|
Equality comparison between two deques (only compares size+contents, not capacity). |
|
Non‐member version of swap. |
Created with MrDocs