|
|
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( ); | 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( ); | 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. |
|
|