DOTS Geometry
 
Loading...
Searching...
No Matches
BinaryHeap< T > Class Template Reference

Binary heap, using an array implementation. More...

Public Member Functions

 BinaryHeap (IComparer< T > comparer)
 
override int Count ()
 
override void Insert (T value)
 Inserts a value into the heap. The heap property is restored.
 
override bool IsEmpty ()
 
override T Peek ()
 
override T Remove ()
 Removes the root-node of the tree and restructures the tree accordingly.
 
- Public Member Functions inherited from AHeap< T >
 AHeap (IComparer< T > comparer)
 
int Count ()
 
void Insert (T value)
 
bool IsEmpty ()
 
Peek ()
 
Remove ()
 

Additional Inherited Members

- Protected Attributes inherited from AHeap< T >
IComparer< T > comparer
 

Detailed Description

Binary heap, using an array implementation.

Template Parameters
T

Constructor & Destructor Documentation

◆ BinaryHeap()

BinaryHeap ( IComparer< T > comparer)
Parameters
comparerCompares each element for heap ordering. If you use default-sorting, the structure is a max-heap. If you reverse the comparison function it becomes a min-heap

Member Function Documentation

◆ Count()

override int Count ( )
Returns
The number of elements within the heap

◆ Insert()

override void Insert ( T value)

Inserts a value into the heap. The heap property is restored.

Parameters
value

◆ IsEmpty()

override bool IsEmpty ( )
Returns
True if the heap contains no element, or false otherwise

◆ Peek()

override T Peek ( )
Returns
Returns the value of the root-node of the tree without removing it

◆ Remove()

override T Remove ( )

Removes the root-node of the tree and restructures the tree accordingly.

Returns
The value stored at the root-node (same as Peek())