A queue is a data structure sometimes used in esoteric programming languages.
A queue works by the principle of First In, First Out (FIFO). What is enqueued onto the queue first, will be dequeued first. This leads to the operations ENQUEUE, which puts a value at the back of the queue, and DEQUEUE, which takes a value from the front, removes it, and returns it.
In addition to ENQUEUE and DEQUEUE, there are a few other queue manipulation operations, many of which are the queue equivalent of stack operations, that queues can use that are generally accomplished through scalar variables.
The following table lists them, including the operation, its name, its traditional (or completely made up) laconic representation, its meaning, and an example in "Generic Queue Language" (GQL), a language used solely for example purposes.
||Peek||Get the value at the front of the queue without removing it||Not possible due to the FIFO nature of queues|
||Drop||Remove the value from the front of the queue and discard it|
||Roll||Move the value from the front of the queue to the back|
||Duplicate||Duplicate the value at the front of the queue to the back|
Use in esolangs
Here are some examples of esoteric programming languages that use queues:
- Q-BAL works like a stack-based language, except using queues instead of stacks.
- Qdeql uses a single queue.
- NULL uses three queues.
- Fueue uses a single queue.
- 0815 uses a single queue and 3 registers.
- Bitwise Cyclic Tag uses two queues, one for program and one for data.