Home >>C++ Standard Template Library Tutorial(STL) >C++ Deque

C++ Deque

C++ Deque

Deque in C++ is an abbreviation that generally stands for double ended queue. The queue data structure is generalised by the Deque and that basically means the insertion and deletion can be executed from both the ends that can be either front or back.

Syntax

Here is the syntax for creating deque object in C++:

deque deque_name;

C++ Deque Functions

Method Description
assign() This function is used to assign new content and replacing the old one.
emplace() This function is used to add a new element at a specified position.
emplace_back() This function is used to add a new element at the end.
emplace_front() This function is used to add a new element in the beginning of a deque.
insert() This function is used to add a new element just before the specified position.
push_back() This function is used to add a new element at the end of the container.
push_front() This function is used to add a new element at the beginning of the container.
pop_back() This function is used to delete the last element from the deque.
pop_front() This function is used to delete the first element from the deque.
swap() This function is used to exchange the contents of two deques.
clear() This function is used to remove all the contents of the deque.
empty() This function is used to check whether the container is empty or not.
erase() This function is used to remove the elements.
max_size() This function is used to determine the maximum size of the deque.
resize() This function is used to change the size of the deque.
shrink_to_fit() This function is used to reduce the memory to fit the size of the deque.
size() This function is used to return the number of elements.
at() This function is used to access the element at position pos.
operator[]() This function is used to access the element at position pos.
operator=() This function is used to assign new contents to the container.
back() This function is used to access the last element.
begin() This function is used to return an iterator to the beginning of the deque.
cbegin() This function is used to return a constant iterator to the beginning of the deque.
end() This function is used to return an iterator to the end.
cend() This function is generally used to return a constant iterator to the end.
rbegin() This function is used to return a reverse iterator to the beginning.
crbegin() This function is used to return a constant reverse iterator to the beginning.
rend() This function is used to return a reverse iterator to the end.
crend() This function is used to return a constant reverse iterator to the end.
front() This function is used to access the last element.
   
   
   
   

No Sidebar ads