Enhanced C#
Language of your choice: library documentation
|
Encapsulates algorithms for a max-heap, i.e. a priority queue that always knows the largest 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 max-heap, i.e. a priority queue that always knows the largest 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 largest item, and Pop() or TryPop(out bool) to remove the largest item.
Most users will want to use the derived classes MaxHeap<T> or MaxHeapInList<T> to avoid dealing with three type parameters. Ideally this type would be a struct in order to maximize performance. It is a class in order to allow derived classes including MinHeap<T>.
TList | : | IList<T> | |
TComparer | : | IComparer<T> |