#include "queue.h"
Public Member Functions | |
| Queue () | |
| ~Queue () | |
| int | size () |
| bool | isEmpty () |
| void | enqueue (ElemType elem) |
| ElemType | dequeue () |
| ElemType | peek () |
| void | clear () |
| const Queue & | operator= (const Queue &rhs) |
| Queue (const Queue &rhs) | |
Classes | |
| struct | cell |
The constructor initializes a new empty queue.
The destructor deallocates storage associated with this queue.
| int Queue< ElemType >::size | ( | ) |
This member function returns the number of elements in this queue.
| bool Queue< ElemType >::isEmpty | ( | ) |
This member function returns true if this queue contains no elements, false otherwise.
| void Queue< ElemType >::enqueue | ( | ElemType | elem | ) |
This member function adds element to the end of this queue. That element becomes the last element in the queue. The queue's size increases by one.
| ElemType Queue< ElemType >::dequeue | ( | ) |
This member function removes the front element from this queue and returns it. The front element is the one that was first enqueued. The queue's size decreases by one. This function raises an error if called on an empty queue.
| ElemType Queue< ElemType >::peek | ( | ) |
This member function returns the value of front element in this queue, without removing it. The queue's size is unchanged. Raises an error if peek is called on an empty queue.
| void Queue< ElemType >::clear | ( | ) |
This member function removes all elements from this queue. The queue is made empty and will have size() = 0.
| const Queue< ElemType > & Queue< ElemType >::operator= | ( | const Queue< ElemType > & | rhs | ) |
This copy constructor and operator= are defined to make a deep copy, making it possible to pass/return queues by value and assign from one queue to another. The entire contents of the queue, including all elements, are copied. Each queue element is copied from the original queue to the copy using assignment (operator=). Making copies is generally avoided because of the expense and thus, queues are typically passed by reference, however, when a copy is needed, these operations are supported.
1.5.1