|
Click
|
#include <deque.hh>
Public Types | |
| enum | { RESERVE_GROW = (size_type) -1 } |
| Constant passed to reserve() to grow the deque. More... | |
| typedef T | value_type |
| Value type. | |
| typedef T & | reference |
| Reference to value type. | |
| typedef const T & | const_reference |
| Const reference to value type. | |
| typedef T * | pointer |
| Pointer to value type. | |
| typedef const T * | const_pointer |
| Pointer to const value type. | |
| typedef fast_argument< T >::type | value_argument_type |
| Type used for value arguments (either T or const T &). | |
| typedef const T & | const_access_type |
| typedef int | size_type |
| Type of sizes (size()). | |
| typedef Deque_iterator< T > | iterator |
| Iterator type. | |
| typedef Deque_const_iterator< T > | const_iterator |
| Const iterator type. | |
Public Member Functions | |
| Deque () | |
| Construct an empty deque. | |
| Deque (size_type n, value_argument_type v) | |
| Construct a deque containing n copies of v. | |
| Deque (const Deque< T > &x) | |
| Construct a deque as a copy of x. | |
| Deque< T > & | operator= (const Deque< T > &x) |
| Replace this deque's contents with a copy of x. | |
| Deque< T > & | assign (size_type n, value_argument_type v=T()) |
| Replace this deque's contents with n copies of v. | |
| iterator | begin () |
| Return an iterator for the first element in the deque. | |
| iterator | end () |
| Return an iterator for the end of the deque. | |
| const_iterator | begin () const |
| const_iterator | end () const |
| const_iterator | cbegin () const |
| Return a const_iterator for the beginning of the deque. | |
| const_iterator | cend () const |
| Return a const_iterator for the end of the deque. | |
| size_type | size () const |
| Return the number of elements. | |
| size_type | capacity () const |
| Return the deque's capacity. | |
| bool | empty () const |
| Test if the deque is empty (size() == 0). | |
| void | resize (size_type n, value_argument_type v=T()) |
| Resize the deque to contain n elements. | |
| bool | reserve (size_type n) |
| Reserve space for at least n more elements. | |
| T & | operator[] (size_type i) |
| Return a reference to the ith element. | |
| const T & | operator[] (size_type i) const |
| T & | at (size_type i) |
| Return a reference to the ith element. | |
| const T & | at (size_type i) const |
| T & | front () |
| Return a reference to the first element. | |
| const T & | front () const |
| T & | back () |
| Return a reference to the last element (number size()-1). | |
| const T & | back () const |
| T & | unchecked_at (size_type i) |
| Return a reference to the ith element. | |
| const T & | unchecked_at (size_type i) const |
| T & | at_u (size_type i) |
| const T & | at_u (size_type i) const |
| void | push_back (value_argument_type v) |
| Append v to the end of the deque. | |
| void | pop_back () |
| Remove the last element. | |
| void | push_front (value_argument_type v) |
| Prepend element v. | |
| void | pop_front () |
| Remove the first element. | |
| iterator | insert (iterator it, value_argument_type v) |
| Insert v before position it. | |
| iterator | erase (iterator it) |
| Remove the element at position it. | |
| iterator | erase (iterator a, iterator b) |
| Remove the elements in [a, b). | |
| void | clear () |
| Remove all elements. | |
| void | swap (Deque< T > &x) |
| Swap the contents of this deque and x. | |
Deque template.
Deque implements a double-ended queue: a growable array that can efficiently add and remove elements at both ends (see push_back(), pop_back(), push_front(), and pop_front()). Its interface should be compatible with C++'s std::deque, although that type has more methods. Deque elements are accessed with operator[] like arrays.
Deque is implemented using a circular buffer of elements. This makes its operations slightly slower than those of Vector. If you only need to push elements to the end of an array, prefer Vector.
Example code:
| typedef T Deque< T >::value_type |
Value type.
| typedef T& Deque< T >::reference |
Reference to value type.
| typedef const T& Deque< T >::const_reference |
Const reference to value type.
| typedef T* Deque< T >::pointer |
Pointer to value type.
| typedef const T* Deque< T >::const_pointer |
Pointer to const value type.
| typedef fast_argument<T>::type Deque< T >::value_argument_type |
Type used for value arguments (either T or const T &).
| typedef Deque_iterator<T> Deque< T >::iterator |
Iterator type.
| typedef Deque_const_iterator<T> Deque< T >::const_iterator |
Const iterator type.
| anonymous enum |
Constant passed to reserve() to grow the deque.
|
inlineexplicit |
Construct a deque containing n copies of v.
Construct a deque as a copy of x.
Replace this deque's contents with a copy of x.
|
inline |
Replace this deque's contents with n copies of v.
|
inline |
Return an iterator for the first element in the deque.
|
inline |
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Return a const_iterator for the beginning of the deque.
|
inline |
|
inline |
Return the number of elements.
|
inline |
Return the deque's capacity.
The capacity is greater than or equal to the size(). Functions such as resize(n) will not allocate new memory for the deque if n <= capacity().
|
inline |
Test if the deque is empty (size() == 0).
|
inline |
Resize the deque to contain n elements.
never
| n | new size |
| v | value used to fill new elements |
Reserve space for at least n more elements.
This function changes the deque's capacity(), not its size(). If reserve(n) succeeds, then any succeeding call to resize(m) with m < n will succeed without allocating deque memory.
Return a reference to the ith element.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Return a reference to the first element.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Return a reference to the last element (number size()-1).
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Return a reference to the ith element.
Unlike operator[]() and at(), this function does not check bounds, even if assertions are enabled. Use with caution.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Append v to the end of the deque.
A copy of v is added to position size(). Takes amortized O(1) time.
|
inline |
Remove the last element.
Takes O(1) time.
|
inline |
Prepend element v.
A copy of v is added to position 0. Other elements are shifted one position forward. Takes amortized O(1) time.
|
inline |
Remove the first element.
Other elements are shifted one position backward. Takes O(1) time.
|
inline |
Insert v before position it.
|
inline |
Remove the element at position it.
|
inline |
Remove the elements in [a, b).
|
inline |
Remove all elements.
Swap the contents of this deque and x.