map

deque

The deque class supports a double-ended queue. Its template specification is

template <class T, class Allocator = allocator<T> > class deque

Here, T is the type of data stored in the deque. It has the following constructors:

explicit deque(const Allocator &a = Allocator( ) );
explicit deque(size_type num, const T &val = T ( ),
       const Allocator &a = Allocator( ));
deque(const deque<T, Allocator> &ob);
template <class InIter> deque(InIter start, InIter end,
       const Allocator &a = Allocator( ));

The first form constructs an empty deque. The second form constructs a deque that has num elements with the value val. The third form constructs a deque that contains the same elements as ob. The fourth form constructs a queue that contains the elements in the range specified by start and end.

The following comparison operators are defined for deque:

==, <, <=, !=, >, >=

deque contains the following member functions:

Member

Description

template <class InIter>
  void assign(InIter start, InIter end);

Assigns the deque the sequence defined by start and end.

void assign(size_type num, const T &val);

Assigns the deque num elements of value val.

reference at(size_type i);
const_reference at(size_type i) const;

Returns a reference to the element specified by i.

reference back( );
const_reference back( ) const;

Returns a reference to the last element in the deque.

iterator begin( );
const_iterator begin( ) const;

Returns an iterator to the first element in the deque.

void clear( );

Removes all elements from the deque.

bool empty( ) const;

Returns true if the invoking deque is empty and false otherwise.

const_iterator end( ) const;
iterator end( );

Returns an iterator to the end of the deque.

iterator erase(iterator i);

Removes the element pointed to by i. Returns an iterator to the element after the one removed.

iterator erase(iterator start, iterator end);

Removes the elements in the range start to end. Returns an iterator to the element after the last element removed.

reference front( );
const_reference front( ) const;

Returns a reference to the first element in the deque.

allocator_type get_allocator( ) const;

Returns deque’s allocator.

iterator insert(iterator i,
                        const T &val);

Inserts val immediately before the element specified by i. An iterator to the element is returned.

void insert(iterator i, size_type num,
                   const T &val);

Inserts num copies of val immediately before the element specified by i.

template <class InIter>
  void insert(iterator i,
                      InIter start, InIter end);

Inserts the sequence defined by start and end immediately before the element specified by i.

size_type max_size( ) const;

Returns the maximum number of elements that the deque can hold.

reference operator[ ](size_type i);
const_reference
  operator[ ](size_type i) const;

Returns a reference to the ith element.

void pop_back( );

Removes the last element in the deque.

void pop_front( );

Removes the first element in the deque.

void push_back(const T &val);

Adds an element with the value specified by val to the end of the deque.

void push_front(const T &val);

Adds an element with the value specified by val to the front of the deque.

reverse_iterator rbegin( );
const_reverse_iterator rbegin( ) const;

Returns a reverse iterator to the end of the deque.

reverse_iterator rend( );
const_reverse_iterator rend( ) const;

Returns a reverse iterator to the start of the deque.

void resize(size_type num, T val = T ( ));

Changes the size of the deque to that specified by num. If the deque must be lengthened, those elements with the value specified by val are added to the end.

size_type size( ) const;

Returns the number of elements currently in the deque.

void swap(deque<T, Allocator> &ob)

Exchanges the elements stored in the invoking deque with those in ob.




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net