Binary heap implementation.
More...
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.
- See Also
- http://en.wikipedia.org/wiki/Binary_heap
-
https://en.wikipedia.org/wiki/D-ary_heap
|
| BinaryHeap (int capacity) |
| Create a new heap with the specified initial capacity.
|
|
void | Add (PathNode node) |
| Adds a node to the heap.
|
|
void | Clear () |
| Removes all elements from the heap.
|
|
void | Rebuild () |
| Rebuilds the heap by trickeling down all items.
|
|
PathNode | Remove () |
| Returns the node with the lowest F score from the heap.
|
|
|
float | growthFactor = 2 |
| The tree will grow by at least this factor every time it is expanded.
|
|
const ushort | NotInHeap = 0xFFFF |
|
int | numberOfItems |
| Number of items in the tree.
|
|
|
bool | isEmpty [get] |
| True if the heap does not contain any elements.
|
|
|
const int | D = 4 |
| Number of children of each node in the tree.
|
|
Tuple[] | heap |
| Internal backing array for the heap.
|
|
const bool | SortGScores = true |
| Sort nodes by G score if there is a tie when comparing the F score.
|
|
Create a new heap with the specified initial capacity.
Removes all elements from the heap.
void DecreaseKey |
( |
Tuple |
node, |
|
|
ushort |
index |
|
) |
| |
|
private |
Expands to a larger backing array when the current one is too small.
Rebuilds the heap by trickeling down all items.
Usually called after the hTarget on a path has been changed
Returns the node with the lowest F score from the heap.
static int RoundUpToNextMultipleMod1 |
( |
int |
v | ) |
|
|
staticprivate |
Rounds up v so that it has remainder 1 when divided by D.
I.e it is of the form n*D + 1 where n is any non-negative integer.
void SetF |
( |
int |
i, |
|
|
uint |
f |
|
) |
| |
|
package |
The tree will grow by at least this factor every time it is expanded.
Internal backing array for the heap.
const ushort NotInHeap = 0xFFFF |
Number of items in the tree.
const bool SortGScores = true |
|
private |
Sort nodes by G score if there is a tie when comparing the F score.
Disabling this will improve pathfinding performance with around 2.5% but may break ties between paths that have the same length in a less desirable manner (only relevant for grid graphs).
True if the heap does not contain any elements.
The documentation for this class was generated from the following file:
- /Users/arong/Unity/a-pathfinding-project/Assets/AstarPathfindingProject/Core/Misc/BinaryHeap.cs