Queue

A queue is a data structure where items are added at one end and removed from the other, following First-In-First-Out (FIFO) order — like a line at a shop.

General Programming

The main operations are enqueue (add to the back) and dequeue (remove from the front). Queues are used for task scheduling, print jobs, and processing requests in order.

Examples

Python

from collections import deque
q = deque()
q.append("a")
q.append("b")
print(q.popleft())

Output:

a

See also

Back to the Dictionary