Sun. Jan 22nd, 2023


A first-in-first-out data structure represents a queue. For example, just like a real queue of people: the first person to join the queue will be the first person to get served and so on.

Queues are widely used. Some examples of their application include:

  • Event loops – an event loop responds to inputs, and maintains a queue of actions that need to be processed. They are processed in the order in which they are received.
  • A to-do list on a job request system – you would expect the first job requested to be actioned before subsequent requests

Once an item has been removed from the list, all items move up one position – i.e. item 2 moves to position 1, item 3 moves to position 2 and so on.