keen/col/mut-priority-queue
Sourcemut-priority-queue[k, v] record (has private fields)size[k, v] nat64(a (k, v) mut-priority-queue) k priorityNumber of pairs in the queue. This is O(
a size).~=[k, v] void(a (k, v) mut-priority-queue, (key k, value v)) k priorityAdds a pair to the queue. This is O(
a.size log).peek[k, v] (k, v) option(a (k, v) mut-priority-queue)Returns the first pair (with the lowest key) without modifying
a. This is O(1).pop[k, v] (k, v) option(a (k, v) mut-priority-queue) k priorityRemoves and returns the first pair (with the lowest key). Returns an empty option if the queue was empty. This is amortized O(
a.size log).copy[k, v] (k, v) mut-priority-queue(a (k, v) mut-priority-queue) k priorityCopy pairs to a new priority queue. This is O(n).
Mutable priority queue.
Elements are key-value pairs. Pairs are sorted by key. Popping removes the first pair (with the lowest key).
If two pairs have the same key, the second pair added will be popped second.