Okasaki.Protocols.Deque protocol (Okasaki v1.0.1) View Source

Link to this section Summary

Functions

True if the deque is empty.

Inserts a new item to the left end of the deque.

Inserts a new item to the right end of the deque.

Checks if a certain element is part of the deque.

Removes an item from the left side of the deque.

Removes an item from the right side of the deque.

Returns the number of elements currently in the queue.

Converts the deque to a list.

Link to this section Types

Link to this section Functions

Specs

empty?(t()) :: boolean()

True if the deque is empty.

Link to this function

insert_left(deque, item)

View Source

Specs

insert_left(t(), item :: any()) :: t()

Inserts a new item to the left end of the deque.

Link to this function

insert_right(deque, item)

View Source

Specs

insert_right(t(), item :: any()) :: t()

Inserts a new item to the right end of the deque.

Specs

member?(t(), item :: any()) :: boolean()

Checks if a certain element is part of the deque.

Specs

remove_left(t()) :: {:ok, {item :: any(), t()}} | {:error, :empty}

Removes an item from the left side of the deque.

Specs

remove_right(t()) :: {:ok, {item :: any(), t()}} | {:error, :empty}

Removes an item from the right side of the deque.

Specs

size(t()) :: non_neg_integer()

Returns the number of elements currently in the queue.

Specs

to_list(t()) :: list()

Converts the deque to a list.