An ADT that contains a collection of elements, and follows the first in first out (FIFO) principle.1

Queues depict a sequence of entities, often modelling real world situations such as car queues for carparks, task scheduling, waiting lines, call centre systems, buffering, printer management, etc.

Properties

  • adding an element to the rear of the queue is called enqueue
  • removing an element from the front of the queue is called dequeue
  • returning the element at the front of the queue without modifying the queue is called peeking/front
  • follows first in first out (FIFO) principle
    • first element added to the queue will be the first one to be removed
  • mutable length

Signature

name: Queue
import: element, boolean
operators:
  newQueue: -> Queue;
  enqueue: Queue × element -> Queue;
  dequeue: Queue -> Queue;
  front: Queue -> element;
  isEmpty: Queue -> boolean;

Implementation

Footnotes

  1. https://en.wikipedia.org/wiki/Queue_(abstract_data_type)