datastructures v0.1.1 Data.Queue.Simple
A simple and performant queue.
Summary
Functions
Dequeue a value from the queue
Dequeue a value from the queue, raising if it's empty
Check if the queue is empty
Enqueue a value in the queue
Fold the queue from the left
Fold the queue from the right
Check if the the value is present in the queue
Creates an empty queue
Creates a new queue from the given enumerable
Peek the element that would be dequeued
Peek the element that should be dequeued, raising if it's empty
Reverse the queue
Get the size of the queue
Convert the queue to a list
Types
Functions
Dequeue a value from the queue.
Examples
iex> Data.Queue.Simple.new |> Data.Queue.enq(42) |> Data.Queue.enq(23) |> Data.Queue.deq
{42,#Queue<[23]>}
iex> Data.Queue.Simple.new |> Data.Queue.deq(:empty)
{:empty,#Queue<[]>}
Dequeue a value from the queue, raising if it's empty.
Examples
iex> Data.Queue.Simple.new |> Data.Queue.enq(42) |> Data.Queue.deq!
{42,#Queue<[]>}
iex> Data.Queue.Simple.new |> Data.Queue.deq!
** (Data.Error.Empty) the queue is empty
Enqueue a value in the queue.
Examples
iex> Data.Queue.Simple.new |> Data.Queue.enq(42) |> Data.Queue.enq(23) |> Data.Queue.enq(1337)
#Queue<[42,23,1337]>
Creates a new queue from the given enumerable.
Examples
iex> Data.Queue.Simple.new(1 .. 4)
#Queue<[1,2,3,4]>
Peek the element that would be dequeued.
Examples
iex> Data.Queue.Simple.new |> Data.Queue.enq(42) |> Data.Queue.peek
42
iex> Data.Queue.Simple.new |> Data.Queue.peek(:empty)
:empty
Peek the element that should be dequeued, raising if it's empty.
Examples
iex> Data.Queue.Simple.new |> Data.Queue.enq(42) |> Data.Queue.enq(23) |> Data.Queue.peek!
42
iex> Data.Queue.Simple.new |> Data.Queue.peek!
** (Data.Error.Empty) the queue is empty
Reverse the queue.
Examples
iex> Data.Queue.Simple.new(1 .. 4) |> Data.Queue.reverse
#Queue<[4,3,2,1]>