Queues
First-in, first-out (FIFO): add at the back, remove from the front.
Beginner
from collections import deque
q = deque()
q.append("job1") # enqueue
q.popleft() # dequeue
Variants: circular buffer (a fixed array used as a queue — the standard UART receive buffer in firmware), deque (both ends) and priority queue (heap). Queues power breadth-first search, task schedulers and message passing between threads.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.