Prioqueue v0.2.1 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

Link to this section Functions

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

Returns true if (and only if) the Priority Queue is empty.

This is a lot faster than checking if the size is nonzero.

Link to this function extract_min(prioqueue) View Source
extract_min(prioqueue) ::
  {:ok, {item :: any, prioqueue}} |
  :error

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 if the priority queue is empty.

Link to this function insert(prioqueue, item) View Source
insert(prioqueue, item :: any) :: prioqueue

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).

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

Returns true if data equal to item is inside of prioqueue,

according to the result of calling the priority queue’s comparison function.

Link to this function peek_min(prioqueue) View Source
peek_min(Prioqueue.t) :: {:ok, item :: any} | :error

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 if the priority queue is empty.

Link to this function size(prioqueue) View Source
size(prioqueue) :: non_neg_integer

Returns the number of elements currently stored in the Priority Queue.

Link to this function to_list(prioqueue) View Source
to_list(prioqueue) :: list

Returns the Priority Queue in list form.

Note that the first-to-be-extracted element appears as the head of the list.