Module trait_based_collection::priority_queue
source · [−]Expand description
A collection of different implementations of priority queues. The priority queue is a data structure that allows you to insert elements into it and then retrieve them in order of priority. The priority is determined through a comparator function that is passed to the priority queue.
Currently, the following implementations are available:
BinaryHeap
: A binary heap implementation of a priority queue using an array.
For more information, see the respective structs’ documentation.
Structs
An implementation of a priority queue using a binary heap. The binary heap is implemented using
an array. The binary heap is a complete binary tree, meaning that every level of the tree is
filled except for the last level, which is filled from left to right. The binary heap is stored
using a function that determines the order of the elements in the heap.
Iterator over the elements of a
BinaryHeap
. This struct is created by the into_iter
method on BinaryHeap
. See its documentation for more.A mutable iterator over the elements of a
BinaryHeap
. The order of the elements is
guaranteed to be the same as the order as if the elements were removed from the heap. However,
even if an element is modified, the heap property will be maintained from the point of view of
when the iterator was created. However, the heap will be modified once the mutable reference to
the element is dropped. For more information, see the documentation for PeekMut
.A mutable reference to an element in a
BinaryHeap
that can be used to modify the element
while maintaining the heap property. The element is only modified when the PeekMut
is
dropped and the user has tried to modify the element (by mutably dereferencing the PeekMut
).
If the user has not tried to modify the element, the element is not modified.