|
ADS
Algorithms and Data Structures
|
The QUEUE of the book [see ADT.h] realized with a circular vector of \( m \) places, the place 0 following the place \( m - 1 \): the queue is in \( n \) consecutive places from the one of its front, \( h \), so that its back is in the place \( ( h + n - 1 ) \bmod m \) and every operation takes \( O( 1 ) \) time; the modulo is a comparison and a subtraction, since the sum is below \( 2 m \), instead of a division. More...
#include "ADS/Contract.h"#include "ADS/Iterators.h"#include <cstddef>#include <memory>#include <utility>#include "ADS/queue/impl/ArrayQueue.tpp"Go to the source code of this file.
Classes | |
| class | ADS::ArrayQueue< T > |
| a QUEUE realized with a circular vector of a given capacity More... | |
Namespaces | |
| namespace | ADS |
The QUEUE of the book [see ADT.h] realized with a circular vector of \( m \) places, the place 0 following the place \( m - 1 \): the queue is in \( n \) consecutive places from the one of its front, \( h \), so that its back is in the place \( ( h + n - 1 ) \bmod m \) and every operation takes \( O( 1 ) \) time; the modulo is a comparison and a subtraction, since the sum is below \( 2 m \), instead of a division.
The contracts [see Contract.h] are the preconditions of the book: top() and dequeue() need a queue that is not empty, enqueue() one that is not full; enqueue() ensures one item more, dequeue() one less, and the invariant is \( 0 \leq n \leq m \) with the front inside the vector. A queue is copied item by item and moved in \( O( 1 ) \) time, the queue moved from left empty with no capacity, as an ArrayStack [see ArrayStack.h]. The operations are defined in ArrayQueue.tpp.