Class MaxBinaryHeap<TKey, TValue>
Implements a Max Binary Heap, and its main operations.
Implements
IBinaryHeap<TKey, TValue>
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: AlgorithmsAndDataStructures.DataStructures.BinaryHeaps
Assembly: AlgorithmsAndDataStructures.dll
Syntax
[DataStructure("MaxBinaryHeap")]
public class MaxBinaryHeap<TKey, TValue> : BinaryHeapBase<TKey, TValue>, IBinaryHeap<TKey, TValue> where TKey : IComparable<TKey>
Type Parameters
Name | Description |
---|---|
TKey | |
TValue |
Constructors
| Improve this Doc View SourceMaxBinaryHeap(List<KeyValuePair<TKey, TValue>>)
Constructor.
Declaration
public MaxBinaryHeap(List<KeyValuePair<TKey, TValue>> array)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<TKey, TValue>> | array | An array containing key-value pairs |
Methods
| Improve this Doc View SourceBubbleDown_Iteratively(Int32, Int32)
Declaration
public override void BubbleDown_Iteratively(int rootIndex, int heapArrayLength)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rootIndex | |
System.Int32 | heapArrayLength | The length of the heap array. |
Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.BubbleDown_Iteratively(System.Int32, System.Int32)
|
Improve this Doc
View Source
BubbleDown_Recursively(Int32, Int32)
Declaration
public override void BubbleDown_Recursively(int rootIndex, int heapArrayLength)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rootIndex | |
System.Int32 | heapArrayLength | The length of the heap array. |
Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.BubbleDown_Recursively(System.Int32, System.Int32)
|
Improve this Doc
View Source
BubbleUp_Iteratively(Int32, Int32)
Declaration
public override void BubbleUp_Iteratively(int index, int heapArrayLength)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | |
System.Int32 | heapArrayLength | The length/size of the heap array. |
Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.BubbleUp_Iteratively(System.Int32, System.Int32)
|
Improve this Doc
View Source
BuildHeap_Iteratively(Int32)
Is the iterative version of BuildHeap_Recursively. Expect to see exact same results for these two methods.
Declaration
public override void BuildHeap_Iteratively(int heapArrayLength)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | heapArrayLength | The length of the heap array. |
Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.BuildHeap_Iteratively(System.Int32)
|
Improve this Doc
View Source
BuildHeap_Recursively(Int32)
Builds an in-place max heap on the given array.
Declaration
public override void BuildHeap_Recursively(int heapArrayLength)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | heapArrayLength | The length of the heap array. |
Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.BuildHeap_Recursively(System.Int32)
|
Improve this Doc
View Source
Insert(KeyValuePair<TKey, TValue>, Int32)
Inserts a new value into the Max Heap.
Declaration
public override void Insert(KeyValuePair<TKey, TValue> value, int heapArrayLength)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<TKey, TValue> | value | The new value to be inserted in the tree. |
System.Int32 | heapArrayLength | The length/size of the heap array. |
Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.Insert(System.Collections.Generic.KeyValuePair<TKey, TValue>, System.Int32)
|
Improve this Doc
View Source
TryFindRoot(out KeyValuePair<TKey, TValue>, Int32)
Declaration
public override bool TryFindRoot(out KeyValuePair<TKey, TValue> keyValue, int heapArrayLength)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<TKey, TValue> | keyValue | |
System.Int32 | heapArrayLength | The length of the heap array. |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.TryFindRoot(System.Collections.Generic.KeyValuePair<TKey, TValue>, System.Int32)
|
Improve this Doc
View Source
TryRemoveRoot(out KeyValuePair<TKey, TValue>, Int32)
Removes the max element from the heap.
Declaration
public override bool TryRemoveRoot(out KeyValuePair<TKey, TValue> keyValue, int heapArrayLength)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<TKey, TValue> | keyValue | If the operation is successful, contains the maximum element in the array. |
System.Int32 | heapArrayLength | The length of the heap array. |
Returns
Type | Description |
---|---|
System.Boolean | True in case of success, and false otherwise |
Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.TryRemoveRoot(System.Collections.Generic.KeyValuePair<TKey, TValue>, System.Int32)