[#VecDeque] = VecDeque :mrdocs: Data structure largely mimicking std::deque, but using single preallocated ring buffer. == Synopsis Declared in `<util/vecdeque.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 [cols="1,4"] |=== | Name| Description | xref:VecDeque/2constructor-08.adoc[`VecDeque`] [.small]#[constructor]# | Constructors | xref:VecDeque/2destructor.adoc[`~VecDeque`] [.small]#[destructor]# | Destroy a deque. | xref:VecDeque/operator_assign-0d.adoc[`operator=`] | Assignment operators | xref:VecDeque/back-09.adoc[`back`] | `back` overloads | xref:VecDeque/capacity.adoc[`capacity`] | Get the capacity of this deque (maximum size it can have without reallocating). | xref:VecDeque/clear.adoc[`clear`] | Resize the deque to be size 0. The capacity will remain unchanged. | xref:VecDeque/emplace_back.adoc[`emplace_back`] | Construct a new element at the end of the deque. | xref:VecDeque/emplace_front.adoc[`emplace_front`] | Construct a new element at the beginning of the deque. | xref:VecDeque/empty.adoc[`empty`] | Test whether the contents of this deque is empty. | xref:VecDeque/front-01.adoc[`front`] | `front` overloads | xref:VecDeque/operator_subs-09.adoc[`operator[]`] | Subscript operators | xref:VecDeque/pop_back.adoc[`pop_back`] | Remove the last element of the deque. Requires !empty(). | xref:VecDeque/pop_front.adoc[`pop_front`] | Remove the first element of the deque. Requires !empty(). | xref:VecDeque/push_back-01.adoc[`push_back`] | `push_back` overloads | xref:VecDeque/push_front-04.adoc[`push_front`] | `push_front` overloads | xref:VecDeque/reserve.adoc[`reserve`] | Increase the capacity to capacity. Capacity will not shrink. | xref:VecDeque/resize.adoc[`resize`] | Resize the deque to be exactly size size (adding default‐constructed elements if needed). | xref:VecDeque/shrink_to_fit.adoc[`shrink_to_fit`] | Make the capacity equal to the size. The contents does not change. | xref:VecDeque/size.adoc[`size`] | Get the number of elements in this deque. | xref:VecDeque/swap.adoc[`swap`] | Swap two deques. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:operator_3way-056.adoc[operator<=>]` | Comparison between two deques, implementing lexicographic ordering on the contents. | `xref:operator_eq-0a6.adoc[operator==]` | Equality comparison between two deques (only compares size+contents, not capacity). | `xref:swap-01.adoc[swap]` | Non‐member version of swap. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#