#include "queue.h"

class Queue<ValueType>

This class models a linear structure called a queue in which values are added at one end and removed from the other. This discipline gives rise to a first-in/first-out behavior (FIFO) that is the defining feature of queues.
Constructor
Queue() Initializes a new empty queue.
Methods
size() Returns the number of values in the queue.
isEmpty() Returns true if the queue contains no elements.
clear() Removes all elements from the queue.
enqueue(value) Adds value to the end of the queue.
dequeue() Removes and returns the first item in the queue.
peek() Returns the first value in the queue, without removing it.
front() Returns the first value in the queue by reference.
back() Returns the last value in the queue by reference.

Constructor detail


Queue();
Initializes a new empty queue.

Usage:

Queue<ValueType> queue;

Method detail


int size();
Returns the number of values in the queue.

Usage:

int n = queue.size();

bool isEmpty();
Returns true if the queue contains no elements.

Usage:

if (queue.isEmpty()) . . .

void clear();
Removes all elements from the queue.

Usage:

queue.clear();

void enqueue(ValueType value);
Adds value to the end of the queue.

Usage:

queue.enqueue(value);

ValueType dequeue();
Removes and returns the first item in the queue.

Usage:

ValueType first = queue.dequeue();

ValueType peek();
Returns the first value in the queue, without removing it. For compatibility with the STL classes, this method is also exported under the name front, in which case it returns the value by reference.

Usage:

ValueType first = queue.peek();

ValueType & front();
Returns the first value in the queue by reference.

Usage:

ValueType first = queue.front();

ValueType & back();
Returns the last value in the queue by reference.

Usage:

ValueType last = queue.back();