Class BinaryArrayHeap<T>
Array-based binary {min,max} heap implementation.
Inheritance
System.Object
BinaryArrayHeap<T>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Mars.Common.Collections
Assembly: Mars.Common.dll
Syntax
public class BinaryArrayHeap<T>
where T : struct, IComparable
Type Parameters
Name | Description |
---|---|
T | Kind of thing being stored in the heap. |
Constructors
| Improve this Doc View SourceBinaryArrayHeap(Int32, Boolean)
Create a new heap.
Declaration
public BinaryArrayHeap(int minSize, bool isMaxHeap = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | minSize | The minimum number of elements the heap is expected to hold. |
System.Boolean | isMaxHeap | If "true", this is a Max Heap, where the largest values rise to the top. Otherwise, this is a Min Heap. |
Properties
| Improve this Doc View SourceCount
Current size of the Heap.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsEmpty
Test to see if the Heap is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceInsert(T)
Add a new value to the Heap.
Declaration
public void Insert(T val)
Parameters
Type | Name | Description |
---|---|---|
T | val |
Peek()
View the value currently at the top of the Heap.
Declaration
public T Peek()
Returns
Type | Description |
---|---|
T |
Remove()
Remove the value currently at the top of the Heap and return it.
Declaration
public T Remove()
Returns
Type | Description |
---|---|
T |