Queue/Definition

From Rosetta Code
Revision as of 20:30, 4 November 2007 by rosettacode>Nirs (Start new task)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Queue/Definition
You are encouraged to solve this task according to the task description, using any language you may know.

Implement a FIFO queue. Elements are added at one side and popped from the other in the order of insertion.

Operations:

  • push - add element
  • pop - pop first element
  • empty - return truth value when empty

Errors:

  • handle the error of trying to pop from an empty queue (behavior depends on the language and platform)

Define the data structure for a FIFO element. Said element should contain a data member capable of holding a numeric value, and the link to the next element should be mutable.