Enhanced C#
Language of your choice: library documentation
Loyc.Collections.MinHeap< T, TList, TComparer > Class Template Reference

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...


Source file:

Remarks

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.

Template Parameters
TItem type
TListList type that the heap object is a wrapper for
TComparerType 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>.

See also
MinHeap<T>
Type Constraints
TList :IList<T> 
TComparer :IComparer<T>