cure v0.5.0 Cure.Queue

Queue module for a FIFO like behavior. Based on Erlang’s :queue module, but with my own small twist to it for easier use in Elixir (usage with |>, etc..)

Summary

Types

t()

Queue type. Consists out of a double ended list

Functions

Drops the oldest value from the queue (not returned to the user). Does nothing if queue = empty. Returns the updated queue

Checks if current queue is empty

Creates a queue from a list (newest entry at head of list)

Creates a new queue

Pops the oldest value from the queue and returns it to the user. Value returned is nil if queue = empty

Inserts the value into the queue. Returns the updated queue

Reverses the queue (oldest item becomes newest, and vice versa)

Returns amount of elements inside the queue

Types

t :: {List.t, List.t}

Queue type. Consists out of a double ended list.

Functions

drop(arg)

Specs

drop(Queue.t) :: Queue.t

Drops the oldest value from the queue (not returned to the user). Does nothing if queue = empty. Returns the updated queue.

empty?(arg1)

Specs

empty?(Queue.t) :: Atom

Checks if current queue is empty.

from_list(list)

Specs

from_list(List.t) :: Queue.t

Creates a queue from a list (newest entry at head of list).

new()

Specs

new :: Queue.t

Creates a new queue.

pop(arg)

Specs

pop(Queue.t) :: {Queue.t, [{:value, any}]}

Pops the oldest value from the queue and returns it to the user. Value returned is nil if queue = empty.

push(arg, value)

Specs

push(Queue.t, any) :: Queue.t

Inserts the value into the queue. Returns the updated queue.

reverse(arg)

Specs

reverse(Queue.t) :: Queue.t

Reverses the queue (oldest item becomes newest, and vice versa).

size(arg)

Specs

size(Queue.t) :: integer

Returns amount of elements inside the queue.