astar 注释

This commit is contained in:
yhh
2020-07-09 16:36:42 +08:00
parent a80bb4b6f3
commit 877fc4c9bf
10 changed files with 153 additions and 3 deletions

View File

@@ -61,6 +61,7 @@ declare class PriorityQueue<T extends PriorityQueueNode> {
constructor(maxNodes: number);
clear(): void;
readonly count: number;
readonly maxSize: number;
contains(node: T): boolean;
enqueue(node: T, priority: number): void;
dequeue(): T;

View File

@@ -418,7 +418,22 @@ var PriorityQueue = (function () {
enumerable: true,
configurable: true
});
Object.defineProperty(PriorityQueue.prototype, "maxSize", {
get: function () {
return this._nodes.length - 1;
},
enumerable: true,
configurable: true
});
PriorityQueue.prototype.contains = function (node) {
if (!node) {
console.error("node cannot be null");
return false;
}
if (node.queueIndex < 0 || node.queueIndex >= this._nodes.length) {
console.error("node.QueueIndex has been corrupted. Did you change it manually? Or add this node to another queue?");
return false;
}
return (this._nodes[node.queueIndex] == node);
};
PriorityQueue.prototype.enqueue = function (node, priority) {

File diff suppressed because one or more lines are too long