C++ deque Library
C++ deque Functions
The <deque> library has functions that let you work with deques. A deque (double-ended queue) is like a vector, but you can add and remove elements at both the front and the back.
A list of popular deque functions can be found in the table below.
| Function | Description |
|---|---|
| assign() | Replaces all the elements of a deque with new values |
| at() | Returns the element at a specified index (position) in a deque |
| back() | Returns the last element of a deque |
| begin() | Returns an iterator pointing to the first element of a deque |
| clear() | Removes all the elements from a deque |
| empty() | Checks whether a deque is empty or not |
| end() | Returns an iterator pointing to the position after the last element of a deque |
| erase() | Removes one element, or a range of elements, from a deque |
| front() | Returns the first element of a deque |
| insert() | Inserts one or more elements at a specified position in a deque |
| pop_back() | Removes the last element of a deque |
| pop_front() | Removes the first element of a deque |
| push_back() | Adds an element to the end of a deque |
| push_front() | Adds an element to the beginning of a deque |
| resize() | Changes the number of elements in a deque, by adding or removing elements at the end |
| size() | Returns the number of elements in a deque |
| swap() | Swaps the contents of two deques |