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
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
Functions
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.
Specs
from_list(List.t) :: Queue.t
Creates a queue from a list (newest entry at head of list).
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.
Specs
push(Queue.t, any) :: Queue.t
Inserts the value into the queue. Returns the updated queue.
Specs
reverse(Queue.t) :: Queue.t
Reverses the queue (oldest item becomes newest, and vice versa).