[#VecDeque]
= VecDeque
:mrdocs:

Data structure largely mimicking std&colon;&colon;deque, but using single preallocated ring buffer&period;

== Synopsis

Declared in `&lt;util&sol;vecdeque&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename T&gt;
class VecDeque;
----

== Description

* More efficient and better memory locality than std&colon;&colon;deque&period;
* Most operations (&lcub;push&lowbar;,pop&lowbar;,emplace&lowbar;,&rcub;&lcub;front,back&rcub;(), operator&lsqb;&rsqb;, &period;&period;&period;) are O(1), unless reallocation is needed (in which case they are O(n))&period;
* Supports reserve(), capacity(), shrink&lowbar;to&lowbar;fit() like vectors&period;
* No iterator support&period;
* Data is not stored in a single contiguous block, so no data()&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:VecDeque/2constructor-08.adoc[`VecDeque`]         [.small]#[constructor]#
| Constructors
| xref:VecDeque/2destructor.adoc[`&#126;VecDeque`] [.small]#[destructor]#
| Destroy a deque&period;
| xref:VecDeque/operator_assign-0d.adoc[`operator&equals;`] 
| 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)&period;
| xref:VecDeque/clear.adoc[`clear`] 
| Resize the deque to be size 0&period; The capacity will remain unchanged&period;
| xref:VecDeque/emplace_back.adoc[`emplace&lowbar;back`] 
| Construct a new element at the end of the deque&period;
| xref:VecDeque/emplace_front.adoc[`emplace&lowbar;front`] 
| Construct a new element at the beginning of the deque&period;
| xref:VecDeque/empty.adoc[`empty`] 
| Test whether the contents of this deque is empty&period;
| xref:VecDeque/front-01.adoc[`front`] 
| `front` overloads
| xref:VecDeque/operator_subs-09.adoc[`operator&lsqb;&rsqb;`] 
| Subscript operators
| xref:VecDeque/pop_back.adoc[`pop&lowbar;back`] 
| Remove the last element of the deque&period; Requires !empty()&period;
| xref:VecDeque/pop_front.adoc[`pop&lowbar;front`] 
| Remove the first element of the deque&period; Requires !empty()&period;
| xref:VecDeque/push_back-01.adoc[`push&lowbar;back`] 
| `push&lowbar;back` overloads
| xref:VecDeque/push_front-04.adoc[`push&lowbar;front`] 
| `push&lowbar;front` overloads
| xref:VecDeque/reserve.adoc[`reserve`] 
| Increase the capacity to capacity&period; Capacity will not shrink&period;
| xref:VecDeque/resize.adoc[`resize`] 
| Resize the deque to be exactly size size (adding default&hyphen;constructed elements if needed)&period;
| xref:VecDeque/shrink_to_fit.adoc[`shrink&lowbar;to&lowbar;fit`] 
| Make the capacity equal to the size&period; The contents does not change&period;
| xref:VecDeque/size.adoc[`size`] 
| Get the number of elements in this deque&period;
| xref:VecDeque/swap.adoc[`swap`] 
| Swap two deques&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:operator_3way-056.adoc[operator&lt;&equals;&gt;]`
| Comparison between two deques, implementing lexicographic ordering on the contents&period;
| `xref:operator_eq-0a6.adoc[operator&equals;&equals;]`
| Equality comparison between two deques (only compares size&plus;contents, not capacity)&period;
| `xref:swap-01.adoc[swap]`
| Non&hyphen;member version of swap&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
