deque


A deque is a sequential container that is optimized for fast indexed based access and efficient insertion at either of its extremities.

Library

Standards<ToolKit>

Declaration


#include <deque>

template< class T, class Allocator >
class deque

Interface

Constructor
deque()
Constructs an empty container.
Constructor
explicit deque( const Allocator& alloc )
Constructs an empty container. Uses alloc to allocate storage.
Constructor
explicitdeque( size_type n , const T& value , const Allocator& alloc )
Constructs a container to contain n elements set to value (default T() ), using alloc (default allocate<T> ) to allocate storage.
Constructor
deque( const T* first , const T* last , const Allocator& alloc )
Constructs a container to contain copies of all elements in the range [ first , last ) , using alloc (default allocate<T> ) to allocate storage.
Constructor
deque( const_iterator first , const_iterator last , const Allocator& alloc )
Constructs a container to contain copies of all elements pointed to by iterators in the range [ first , last ) , using alloc (default allocate<T> ) to allocate storage.
Constructor
deque( const deque< T, Allocator >& other )
Constructs a container that is a copy of other .
Destructor
~deque()
Destroys the container and erases all of its items.
=
deque< T, Allocator >& operator=( const deque< T, Allocator >& other )
Replaces the container's contents with a copy of other and returns a reference to the container.
[]
T& operator[]( size_type index )
Returns a reference to the container's index element.
[]
const T& operator[]( size_type index ) const
Returns a const reference to the container's index element.
assign
void assign( const T* first , const T* last )
Removes all of the container's elements, then inserts the elements in the range [ first ... last ) .
assign
void assign( const_iterator first , const_iterator last )
Removes all of the container's elements, then inserts the elements pointed to by the iterators in range [ first ... last ) .
assign
void assign( size_type n , const T& value )
Removes all of the container's elements, then inserts n copies of value (default T() ).
at
T& at( size_type pos )
Returns a reference to the container's pos element.
at
const T& at( size_type pos )
Returns a const reference to the container's pos element.
back
T& back()
Returns a reference to the container's last element.
back
const T& back() const
Returns a const reference to the container's last element.
begin
iterator begin()
Returns an iterator positioned at the container's first element.
begin
const_iterator begin() const
Returns a const iterator positioned at the container's first element.
clear
void clear()
Erases the container's elements.
empty
bool empty() const
Returns true if the container has no entries.
end
iterator end()
Returns an iterator positioned immediately after the container's last element.
end
const_iterator end() const
Returns a const iterator positioned immediately after the container's last element.
erase
void erase( iterator pos )
Erases the element at pos .
erase
void erase( iterator first , iterator last )
Erases the elements in range [ first , last ) .
front
T& front()
Returns a reference to the container's first element.
front
const T& front() const
Returns a const reference to the container's first element.
get_allocator
Allocator get_allocator() const
Returns a copy of the allocator the container is using.
insert
iterator insert( iterator pos , const T& value )
Inserts value (default T() ) at pos and returns an iterator pointing to the new element's position.
insert
void insert( iterator pos , size_type n , const T& value )
Inserts n copies of value at pos .
insert
void insert( iterator pos , const T* first , const T* last )
Inserts copies of the elements in the range [ first , last ) at pos .
insert
void insert( iterator pos , const_iterator first , const_iterator last )
Inserts copies of the elements in the range [ first , last ) at pos .
max_size
size_type max_size() const
Returns the maximum number of entries the container can contain.
pop_back
void pop_back()
Erases the container's last element.
pop_front
void pop_front()
Erases the container's first element.
push_back
void push_back( const T& value )
Adds value at the end of the container.
push_front
void push_front( const T& value )
Inserts a copy of value in front of container's first element.
rbegin
reverse_iterator rbegin()
Returns a reverse iterator positioned at container's last item.
rbegin
const_reverse_iterator rbegin() const
Returns a constant reverse iterator positioned at container's last item.
rend
reverse_iterator rend()
Returns a reverse iterator positioned immediately before container's first item.
rend
const_reverse_iterator rend() const
Returns a constant reverse iterator positioned immediately before container's first item.
resize
void resize( size_type n , T value ) const
Adjusts the container to hold n elements, using value (default T() ) to initialize new elements if necessary.
size
size_type size() const
Returns the number of elements in the container.
swap
void swap( deque< T, Allocator >& other )
Exchanges the container's contents with other .

Non-Member Functions

==
bool operator==( const deque< T, Allocator >& x , const deque< T, Allocator >& y )
Returns true if x is equivalent to y .
<
bool operator<( const deque< T, Allocator >& x , const deque< T, Allocator >& y )
Returns true if x is lexicographically less than y .
swap
void swap( const deque< T, Allocator >& x , const deque< T, Allocator >& y )
Exchanges the contents of x and y .

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.