Prioqueue v0.2.7 Prioqueue.Protocol protocol View Source
Link to this section Summary
Functions
Returns true
if (and only if) the Priority Queue is empty.
Extracts the current minimum from the Priority Queue,
according to the ordering introduced by the Priority Queue's cmp_fun
.
Inserts item
at the correct ordering place inside prioqueue
,
Returns true
if data equal to item
is inside of prioqueue
,
Peeks at the current minimum item from the Priority Queue,
according to the ordering introduced by the Priority Queue's cmp_fun
.
Returns the number of elements currently stored in the Priority Queue.
Returns the Priority Queue in list form.
Link to this section Types
prioqueue()
View Source
prioqueue() :: t()
prioqueue() :: t()
t()
View Source
t() :: term()
t() :: term()
Link to this section Functions
empty?(prioqueue) View Source
Returns true
if (and only if) the Priority Queue is empty.
This is a lot faster than checking if the size is nonzero.
extract_min(prioqueue) View Source
Extracts the current minimum from the Priority Queue,
according to the ordering introduced by the Priority Queue's cmp_fun
.
Runs in O(log n).
Returns {:ok, {item, priority_queue_without_item}}
, or {:error, :empty}
if the priority queue is empty.
insert(prioqueue, item) View Source
Inserts item
at the correct ordering place inside prioqueue
,
according to the ordering introduced by the Priority Queue's cmp_fun
.
Runs in O(log n).
member?(prioqueue, item) View Source
Returns true
if data equal to item
is inside of prioqueue
,
according to the result of calling the priority queue's comparison function.
peek_min(prioqueue) View Source
Peeks at the current minimum item from the Priority Queue,
according to the ordering introduced by the Priority Queue's cmp_fun
.
Runs in O(1).
Returns {:ok, item}
, or {:error, :empty}
if the priority queue is empty.
size(prioqueue) View Source
Returns the number of elements currently stored in the Priority Queue.
to_list(prioqueue) View Source
Returns the Priority Queue in list form.
Note that the first-to-be-extracted element appears as the head of the list.