Class BinaryHeap

Public

Binary heap implementation.

Binary heaps are really fast for ordering nodes in a way that makes it possible to get the node with the lowest F score. Also known as a priority queue.

This has actually been rewritten as a 4-ary heap for performance, but it's the same principle.

Inner Types

Item in the heap.

Public Methods

Add (node)

Adds a node to the heap.

Public
BinaryHeap (capacity)

Create a new heap with the specified initial capacity.

Public
Clear ()

Removes all elements from the heap.

Public
Rebuild ()

Rebuilds the heap by trickeling down all items.

Public
Remove ()

Returns the node with the lowest F score from the heap.

Public

Public Variables

growthFactor

The tree will grow by at least this factor every time it is expanded.

Public
isEmpty

True if the heap does not contain any elements.

Public
NotInHeap
Public
numberOfItems

Number of items in the tree.

Public

Private/Protected Members

D

Number of children of each node in the tree.

Private
DecreaseKey (node, index)
Private
Expand ()

Expands to a larger backing array when the current one is too small.

Private
GetNode (i)
Package
heap

Internal backing array for the heap.

Private
RoundUpToNextMultipleMod1 (v)

Rounds up v so that it has remainder 1 when divided by D.

Private Static
SetF (i, f)
Package
SortGScores

Sort nodes by G score if there is a tie when comparing the F score.

Private
Validate ()
Private