2013-04-10 23:57:08 -07:00
|
|
|
{{Data structure}}
|
|
|
|
|
[[File:Fifo.gif|frame|right|Illustration of FIFO behavior]]
|
2016-12-05 22:15:40 +01:00
|
|
|
|
|
|
|
|
;Task:
|
2015-02-20 00:35:01 -05:00
|
|
|
Implement a FIFO queue.
|
2016-12-05 22:15:40 +01:00
|
|
|
|
2015-02-20 00:35:01 -05:00
|
|
|
Elements are added at one side and popped from the other in the order of insertion.
|
2013-04-10 23:57:08 -07:00
|
|
|
|
2016-12-05 22:15:40 +01:00
|
|
|
|
2013-04-10 23:57:08 -07:00
|
|
|
Operations:
|
2016-12-05 22:15:40 +01:00
|
|
|
* push (aka ''enqueue'') - add element
|
|
|
|
|
* pop (aka ''dequeue'') - pop first element
|
|
|
|
|
* empty - return truth value when empty
|
|
|
|
|
|
2013-04-10 23:57:08 -07:00
|
|
|
|
|
|
|
|
Errors:
|
2016-12-05 22:15:40 +01:00
|
|
|
* handle the error of trying to pop from an empty queue (behavior depends on the language and platform)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;See:
|
|
|
|
|
* [[Queue/Usage]] for the built-in FIFO or queue of your language or standard library.
|
2013-04-10 23:57:08 -07:00
|
|
|
|
2013-10-27 22:24:23 +00:00
|
|
|
|
|
|
|
|
{{Template:See also lists}}
|
2016-12-05 22:15:40 +01:00
|
|
|
<br><br>
|