|
ADS
Algorithms and Data Structures
|
[Stack] More...
#include <ADS/ADT.h>
[Stack]
QUEUE (section 4.3.1): items are added at the back and removed from the front (FIFO); top() reads the front. As axioms, \( \mathrm{empty}( \mathrm{create} ) = \mathbf{true} \), \( \mathrm{empty}( \mathrm{enqueue}( Q , v ) ) = \mathbf{false} \), \( \mathrm{top}( \mathrm{enqueue}( \mathrm{create} , v ) ) = v \), \( \mathrm{dequeue}( \mathrm{enqueue}( \mathrm{create} , v ) ) = \mathrm{create} \), and for \( Q \) not empty \( \mathrm{top}( \mathrm{enqueue}( Q , v ) ) = \mathrm{top}( Q ) \) and \( \mathrm{dequeue}( \mathrm{enqueue}( Q , v ) ) = \mathrm{enqueue}( \mathrm{dequeue}( Q ) , v ) \), while top() and dequeue() of the empty queue are undefined