Deque
The \ (deque \) header file mainly includes a dual-end queue container. It is a linear storage space that can be inserted at both ends to delete, similar to vector and queue. Compared with \ (vector \), \ (deque \) can insert elements at the beginning of \ (O (1. Compared with \ (queue \), \ (deque \) can be randomly accessed as an array.
Declaration Method
Deque <int> q; deque <int>: iterator it;
Q. Size ()
Returns the size of the double-ended queue.
Q. Empty ()
Whether the double-end queue is empty.
Q. Clear ()
Clear the container.
[]
Random Access like \ (vector.
Q. Begin ()/Q. End ()
Returns the first iterator or the last iterator.
Q. Front ()/Q. Back ()
Returns the header/tail element.
Q. push_front (X)/Q. push_back ()
Insert element \ (x \) at the head/end of the team \).
Q. pop_front ()/Q. pop_back ()
Show team Header/team end Elements
# Include <deque>