ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
LinkedQueue.h File Reference

A QUEUE [see ADT.h] realized as a singly linked list with a pointer to the first cell, the front, and one to the last cell, the back (exercise 4.10 of the book): enqueue() appends a cell after the back and dequeue() removes the front, both in \( O( 1 ) \) time, and the queue has no bound on its size, unlike the circular vector of ArrayQueue. More...

#include "ADS/Contract.h"
#include "ADS/Iterators.h"
#include "ADS/memory/ObjectPool.h"
#include <cstddef>
#include <utility>
#include "ADS/queue/impl/LinkedQueue.tpp"

Go to the source code of this file.

Classes

class  ADS::LinkedQueue< T >
 a QUEUE realized as a singly linked list with a front and a back More...

Namespaces

namespace  ADS

Detailed description

A QUEUE [see ADT.h] realized as a singly linked list with a pointer to the first cell, the front, and one to the last cell, the back (exercise 4.10 of the book): enqueue() appends a cell after the back and dequeue() removes the front, both in \( O( 1 ) \) time, and the queue has no bound on its size, unlike the circular vector of ArrayQueue.

The cells come from an ObjectPool [see ObjectPool.h], the one of a dequeue() serving the next enqueue(), so that a queue in a steady state calls no allocator and its cells stay in the cache.

The contracts [see Contract.h]: top() and dequeue() need a queue that is not empty; enqueue() ensures that the queue is not empty, and that top() is \( v \) if the queue was empty. A queue is copied cell by cell and moved in \( O( 1 ) \) time, the one moved from left empty. The operations are defined in LinkedQueue.tpp.

See also
A. Montresor, Algoritmi e Strutture Dati, 2025, exercise 4.10, https://algoritmicamente.it/materiali/libro/capitoli/cap04.pdf
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa