Enhanced C#
Loyc library documentation
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Static Public Member Functions | List of all members
Loyc.Collections.Heap Class Reference

Source file:

Static Public Member Functions

static MaxHeapInList< T > AsMaxHeap< T > (this IList< T > list, IComparer< T >?compare=null, bool heapify=false)
 Returns a MaxHeapInList wrapper object, which treats the list as a binary max-heap (priority queue). This function assumes that the given list already represents a binary max-heap in which the child nodes of list[x] are list[x*2+1] and list[x*2+2]. If this is not the case, you can either use ToMaxHeap() to make a copy with the heap property, or call Heapify() on the result of this function. More...
 
static MaxHeap< T > ToMaxHeap< T > (this IList< T > list, IComparer< T >?compare=null, bool heapify=true)
 Copies the list into a new object with the items arranged as a max-heap (priority queue). Complexity: O(N). More...
 
static MinHeapInList< T > AsMinHeap< T > (this IList< T > list, IComparer< T >?compare=null, bool heapify=false)
 Returns a MinHeapInList wrapper object, which treats the list as a binary min-heap (priority queue). This function assumes that the given list already represents a binary min-heap in which the child nodes of list[x] are list[x*2+1] and list[x*2+2]. If this is not true, you can either use ToMinHeap() to make a copy with the heap property, or call Heapify() on the result of this function. More...
 
static MinHeap< T > ToMinHeap< T > (this IList< T > list, IComparer< T >?compare=null, bool heapify=true)
 Copies the list into a new object with the items arranged as a min-heap (priority queue). Complexity: O(N). More...
 

Member Function Documentation

static MaxHeapInList<T> Loyc.Collections.Heap.AsMaxHeap< T > ( this IList< T >  list,
IComparer< T >?  compare = null,
bool  heapify = false 
)
inlinestatic

Returns a MaxHeapInList wrapper object, which treats the list as a binary max-heap (priority queue). This function assumes that the given list already represents a binary max-heap in which the child nodes of list[x] are list[x*2+1] and list[x*2+2]. If this is not the case, you can either use ToMaxHeap() to make a copy with the heap property, or call Heapify() on the result of this function.

Parameters
compareAn object to be used to compare T values.
heapifyWhether to rearrange items so that they have the heap property.
static MinHeapInList<T> Loyc.Collections.Heap.AsMinHeap< T > ( this IList< T >  list,
IComparer< T >?  compare = null,
bool  heapify = false 
)
inlinestatic

Returns a MinHeapInList wrapper object, which treats the list as a binary min-heap (priority queue). This function assumes that the given list already represents a binary min-heap in which the child nodes of list[x] are list[x*2+1] and list[x*2+2]. If this is not true, you can either use ToMinHeap() to make a copy with the heap property, or call Heapify() on the result of this function.

Parameters
compareAn object to be used to compare T values.
heapifyWhether to rearrange items so that they have the heap property.
static MaxHeap<T> Loyc.Collections.Heap.ToMaxHeap< T > ( this IList< T >  list,
IComparer< T >?  compare = null,
bool  heapify = true 
)
inlinestatic

Copies the list into a new object with the items arranged as a max-heap (priority queue). Complexity: O(N).

Parameters
compareAn object to be used to compare T values.
heapifyWhether to rearrange items so that they have the heap property. If the items are already arranged with the heap property, you can skip heapification by setting this to false.
static MinHeap<T> Loyc.Collections.Heap.ToMinHeap< T > ( this IList< T >  list,
IComparer< T >?  compare = null,
bool  heapify = true 
)
inlinestatic

Copies the list into a new object with the items arranged as a min-heap (priority queue). Complexity: O(N).

Parameters
compareAn object to be used to compare T values.
heapifyWhether to rearrange items so that they have the heap property. If the items are already arranged with the heap property, you can skip heapification by setting this to false.