Class BMaxHeap<T>
A binary max heap implementation.
Assembly: Advanced.Algorithms.dll
Syntax
public class BMaxHeap<T> : IEnumerable<T> where T : IComparable
Type Parameters
Constructors
BMaxHeap()
Declaration
BMaxHeap(IComparer<T>)
Declaration
public BMaxHeap(IComparer<T> comparer)
Parameters
Type |
Name |
Description |
IComparer<T> |
comparer |
|
BMaxHeap(IEnumerable<T>)
Declaration
public BMaxHeap(IEnumerable<T> initial)
Parameters
Type |
Name |
Description |
IEnumerable<T> |
initial |
|
BMaxHeap(IEnumerable<T>, IComparer<T>)
Time complexity: O(n) if initial is provided. Otherwise O(1).
Declaration
public BMaxHeap(IEnumerable<T> initial, IComparer<T> comparer)
Parameters
Type |
Name |
Description |
IEnumerable<T> |
initial |
The initial items in the heap.
|
IComparer<T> |
comparer |
|
Properties
Count
Declaration
public int Count { get; }
Property Value
Methods
Delete(T)
Declaration
public void Delete(T value)
Parameters
Type |
Name |
Description |
T |
value |
|
Exists(T)
Declaration
public bool Exists(T value)
Parameters
Type |
Name |
Description |
T |
value |
|
Returns
Time complexity: O(log(n)).
Declaration
Returns
GetEnumerator()
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type |
Description |
IEnumerator<T> |
|
Insert(T)
Time complexity: O(log(n)).
Declaration
public void Insert(T newItem)
Parameters
Type |
Name |
Description |
T |
newItem |
|
PeekMax()
Declaration
Returns