-
Notifications
You must be signed in to change notification settings - Fork 0
Queues
Bruno Fernandes edited this page Aug 4, 2018
·
5 revisions
FIFO complement of lists. Support two key operations:
-
Enqueue
- Place an item onto the end of the queue -
Dequeue
- Remove an item from the front of the queue
n.b. Push
and Pop
are aliases for these operations.
Implementation | Performance | Std. lib equivalent |
---|---|---|
Queue |
Constant time operations | None |
CircularBuffer |
Constant time operations | None |
ResizingBuffer |
Constant amortised time operations | Queue |
The elements of a Queue
are represented as a chain of node references, with the Queue
itself containing references to its head and tail. Its list implementation analogue is the LinkedList
.
CircularBuffer
also has references to a head and tail, but its contents are held within a fixed-size array that can 'wrap over itself.' ResizingBuffer
is like a CircularBuffer
that can resize itself to prevent overflow.