ocean.util.container.more.Heap

Members

Functions

defaultHeapSwap
void defaultHeapSwap(T t, size_t index)
Undocumented in source. Be warned that the author may not have intended to support it.
maxHeapCompare
bool maxHeapCompare(T a, T b)
Undocumented in source. Be warned that the author may not have intended to support it.
minHeapCompare
bool minHeapCompare(T a, T b)
Undocumented in source. Be warned that the author may not have intended to support it.
onMove
void onMove(long a, size_t b)
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

Heap
struct Heap(T, alias Compare = minHeapCompare!(T), alias Move = defaultHeapSwap!(T))

A heap is a data structure where you can insert items in random order and extract them in sorted order. * Pushing an element into the heap takes O(lg n) and popping the top of the heap takes O(lg n). Heaps are * thus popular for sorting, among other things. * * No opApply is provided, since most people would expect this to return the contents in sorted order, * not do significant heap allocation, not modify the collection, and complete in linear time. This * combination is not possible with a heap. * * Note: always pass by reference when modifying a heap. * * The template arguments to the heap are: * T = the element type * Compare = a function called when ordering elements. Its signature should be bool(T, T). * see minHeapCompare() and maxHeapCompare() for examples. * Move = a function called when swapping elements. Its signature should be void(T, uint). * The default does nothing, and should suffice for most users. You * probably want to keep this function small; it's called O(log N) * times per insertion or removal.

Templates

MaxHeap
template MaxHeap(T)

A maxheap implementation. This will have the largest item as the top of the heap. * * Note: always pass by reference when modifying a heap. *

MinHeap
template MinHeap(T)

A minheap implementation. This will have the smallest item as the top of the heap. * * Note: always pass by reference when modifying a heap. *

Variables

indices
size_t[] indices;
Undocumented in source.
swapped
long[] swapped;
Undocumented in source.

Meta

License

Tango Dual License: 3-Clause BSD License / Academic Free License v3.0. See LICENSE_TANGO.txt for details.

Version

Oct 2008: Initial release

Authors

Chris Wright, aka dhasenan