set

queue

The queue class supports a single-ended queue. Its template specification is shown here:

template <class T, class Container = deque<T> > class queue

Here, T is the type of data being stored and Container is the type of container used to hold the queue. It has the following constructor:

explicit queue(const Container &cnt = Container( ));

The queue( ) constructor creates an empty queue. By default, it uses a deque as a container, but a queue can only be accessed in a first-in, first-out manner. You can also use a list as a container for a queue. The container is held in a protected object called c of type Container.

The following comparison operators are defined for queue:

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

queue contains the following member functions:

Member

Description

value_type &back( );
const value_type &back( ) const;

Returns a reference to the last element in the queue.

bool empty( ) const;

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

value_type &front( );
const value_type &front( ) const;

Returns a reference to the first element in the queue.

void pop( );

Removes the first element in the queue.

void push(const value_type &val);

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

size_type size( ) const;

Returns the number of elements currently in the queue.




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