(create lt-comparator id-fn)
Creates a priority queue with the given comparator, where an element x
from
the queue for which (not (lt y x)) is true for each other element y
in the
queue, will be treated as the minimum by get-min
and extract-min
.
Creates a priority queue with the given comparator, where an element `x` from the queue for which (not (lt y x)) is true for each other element `y` in the queue, will be treated as the minimum by `get-min` and `extract-min`.
(build queue elements)
Build a priority queue out of the given unsorted elements, expecting the element at index 0 not to ever be accessed.
Works in Θ(n).
Build a priority queue out of the given unsorted elements, expecting the element at index 0 not to ever be accessed. Works in Θ(n).
(extract-min queue)
Extract an element x
from the queue for which (not (lt y x)) is true for each
other element y
in the queue. Returns a pair of [new-priority-queue extracted-min].
Works in O(log(n)).
Extract an element `x` from the queue for which (not (lt y x)) is true for each other element `y` in the queue. Returns a pair of [new-priority-queue extracted-min]. Works in O(log(n)).
(find-by-id queue id)
Finds an element by its id.
Works in Θ(1).
Finds an element by its id. Works in Θ(1).
(get-min queue)
Return an element x
from the queue for which (not (lt y x)) is true
for each other element y
in the queue.
Works in Θ(1).
Return an element `x` from the queue for which (not (lt y x)) is true for each other element `y` in the queue. Works in Θ(1).
(insert queue x)
Inserts a new element to the priority queue, keeping the heap ordering.
Works in O(log(n))
Inserts a new element to the priority queue, keeping the heap ordering. Works in O(log(n))
(queue-empty? queue)
Returns true iff the queue is empty.
Returns true iff the queue is empty.
(remove-by-id queue id)
Removes an element by its id. Returns a pair of [new-priority-queue removed-element].
Works in O(log(n)).
Removes an element by its id. Returns a pair of [new-priority-queue removed-element]. Works in O(log(n)).
(update-by-id queue id f)
Updates an element by its id by applying function f
to it.
Returns a new priority queue fix fixed ordering, or nil if the element is not present.
Do not affect the output of the id-fn on this element by this change, the priority queue is not responsible for fixing that!
Works in O(log(n)).
Updates an element by its id by applying function `f` to it. Returns a new priority queue fix fixed ordering, or nil if the element is not present. Do not affect the output of the id-fn on this element by this change, the priority queue is not responsible for fixing that! Works in O(log(n)).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close