Enhanced C#
Language of your choice: library documentation
|
Encapsulates algorithms for a min-heap, i.e. a priority queue that always knows the smallest item and can remove it in O(log Count) time, or add a new item in O(log Count) time. More...
Encapsulates algorithms for a min-heap, i.e. a priority queue that always knows the smallest item and can remove it in O(log Count) time, or add a new item in O(log Count) time.
T | Item type |
TList | List type that the heap object is a wrapper for |
TComparer | Type used to compare items; an instance of this type must be provided to the constructor. |
Call Push(T) to add a new item, Peek() to get the smallest item, and Pop() or TryPop(out bool) to remove the smallest item.
Most users will want to use the derived classes MinHeap<T> or MinHeapInList<T> to avoid dealing with three type parameters. Ideally this type would be a struct in order to maximize performance. It is a class so that it can re-use the code in MaxHeap<T, TList, TComparer>.
TList | : | IList<T> | |
TComparer | : | IComparer<T> |