structure v0.2.2 Structure.Queue View Source

Efficient double ended fifo queue

Link to this section Summary

Functions

Returns if the queue is empty

Create queue from list

Returns length of the queue

Returns if element is in the queue

Create a new empty queue

Pop an item from the rear of the queue

Pop an item from the front of the queue

Push an item at the end of the queue

Push an item at the front of the queue

Returns the items in the queue as a list

Link to this section Types

Link to this type t() View Source
t() :: %Structure.Queue{front: list | [], rear: list | []}

Link to this section Functions

Link to this function empty?(queue) View Source
empty?(t) :: boolean

Returns if the queue is empty.

O(1)

Link to this function from_list(l) View Source
from_list(list) :: t

Create queue from list.

O(length(l))

Link to this function length(queue) View Source
length(t) :: non_neg_integer

Returns length of the queue.

O(len(q))

Link to this function member?(queue, item) View Source
member?(t, any) :: boolean

Returns if element is in the queue.

O(len(q)) worst case

Create a new empty queue.

O(1)

Link to this function pop_back(q) View Source
pop_back(t) :: {:empty, t} | {any, t}

Pop an item from the rear of the queue.

O(1) amortized. O(len(q)) worst case.

Link to this function pop_front(q) View Source
pop_front(t) :: {:empty, t} | {any, t}

Pop an item from the front of the queue.

O(1) amortized. O(len(q)) worst case.

Link to this function push_back(q, item) View Source
push_back(t, any) :: t

Push an item at the end of the queue.

O(1)

Link to this function push_front(q, item) View Source
push_front(t, any) :: t

Push an item at the front of the queue.

O(1)

Link to this function to_list(queue) View Source
to_list(t) :: list

Returns the items in the queue as a list.

O(len(q))