One way queue with time-complexity of enqueueing and dequeueing O(1) even at worst case.
Create queue from list. The newest element comes head of the queue.
["H","e","l","l","o"]
|> fromListLIFO
|> head
--> Just "H"Create queue from list. The oldest element of the list comes head of the queue.
["H"]
|> (::) "e"
|> (::) "l"
|> (::) "l"
|> (::) "o"
|> fromListFIFO
|> head
--> Just "H"Returns True if the argument has no element.
empty
|> enqueue "a"
|> isEmpty
--> False
empty
|> enqueue "a"
|> dequeue
|> isEmpty
--> TrueReturns the oldest element injected in the queue wrapped in Maybe.
empty
|> head
--> Nothing
empty
|> enqueue "e"
|> enqueue "l"
|> enqueue "m"
|> head
--> Just "e"Returns the queue as second argument with the element as the first argument injected into the rear side.
empty
|> enqueue 100
|> enqueue 200
|> head
--> Just 100Returns queue without the oldest element of the given queue.
empty
|> enqueue "e"
|> enqueue "l"
|> enqueue "m"
|> enqueue "i"
|> enqueue "s"
|> enqueue "h"
|> dequeue
|> head
--> Just "l"Convert a queue to List. The last element in the queue will become the head of the returned list.
empty
|> enqueue 100
|> enqueue 200
|> enqueue 300
|> toListLIFO
--> [300,200,100]Convert a queue to List. The first element in the queue will become the head of the returned list.
empty
|> enqueue 100
|> enqueue 200
|> enqueue 300
|> toListFIFO
--> [100,200,300]
Representation of First-In, First-Out(FIFO) data structure.