dranges.binaryheap
A simple binary heap implementation, used as a basis for a priority queue in dranges.priorityqueue, itself
used in the dranges.graph algorithms.
This module is old (august 2009), I will clean it up to follow the changes in D containers and ranges.
License:
Boost License 1.0.
Authors:
Philippe Sigaud
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- struct
BinaryHeap
(alias predicate = "a < b",T);
- this(T[] _data);
- bool
empty
();
- template
put
(T)
- void
put
(T t);
- template
put
(U : T[])
- void
put
(U array);
- template
put
(P,V) if (is(T == Tuple!(P,V)))
- void
put
(V value, P priority);
- T
front
();
- BinaryHeap
save
();
- void
popFront
();
- void
swapKeys
(size_t i1, size_t i2);
- void
changeKey
(T oldKey, T newKey);
- Changes a key value in the heap. In case of many keys with
the same value, one of them will bubble up or sift down according
to its new value.
- template
changePriority
(P,V) if (is(T == Tuple!(P,V)))
- This will change a value priority (used for priority queues). Works only for priority queues:
binary heap with tuples(priority, value) for keys.
Throws:
RangeError (Range violation) if the key/value does not exist.
See Also:
PriorityQueue.
changePriority
()
- void
changePriority
(V value, P oldPriority, P newPriority);
- This will change a value priority (used for priority queues). Works only for priority queues:
binary heap with tuples(priority, value) for keys.
Throws:
RangeError (Range violation) if the key/value does not exist.
See Also:
PriorityQueue.
changePriority
()
- BinaryHeap!(predicate,T)
binaryHeap
(alias predicate = "a < b", T)(T[] data);
- Helper function to infer type for T and to create a heap from an array of values
|