Removed priority queue in favor of FlatQueue (#1157)

* removed priority queue in favor of simple array extension as it will be easier to migrate to esm

* patch: bump version

* spacing

* moved references to globalThis

* demonstrate module interop

* added version to priority-queue and moved to utils to follow dom loading pattern

* removed PriorityQueue in favor of FlatQueue

* update index.html

* never mind that force push I don't know how to amend commits right

* missing capitalization

* priority set to 0 on 541

---------

Co-authored-by: RyanGuild <ryan.guild@us-ignite.org>
This commit is contained in:
Ryan D. Guild 2024-10-26 08:26:59 -04:00 committed by GitHub
parent 54491cfd09
commit d7f5cae229
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 40 additions and 39 deletions

View file

@ -209,11 +209,11 @@ window.Zones = (function () {
const cost = [];
const maxCells = rand(20, 40);
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
queue.queue({e: burg.cell, p: 0});
const queue = new FlatQueue();
queue.push({e: burg.cell, p: 0}, 0);
while (queue.length) {
const next = queue.dequeue();
const next = queue.pop();
if (cells.burg[next.e] || cells.pop[next.e]) cellsArray.push(next.e);
usedCells[next.e] = 1;
@ -224,7 +224,7 @@ window.Zones = (function () {
if (!cost[nextCellId] || p < cost[nextCellId]) {
cost[nextCellId] = p;
queue.queue({e: nextCellId, p});
queue.push({e: nextCellId, p}, p);
}
});
}
@ -251,11 +251,11 @@ window.Zones = (function () {
const cost = [];
const maxCells = rand(5, 25);
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
queue.queue({e: burg.cell, p: 0});
const queue = new FlatQueue();
queue.push({e: burg.cell, p: 0}, 0);
while (queue.length) {
const next = queue.dequeue();
const next = queue.pop();
if (cells.burg[next.e] || cells.pop[next.e]) cellsArray.push(next.e);
usedCells[next.e] = 1;
@ -266,7 +266,7 @@ window.Zones = (function () {
if (!cost[e] || p < cost[e]) {
cost[e] = p;
queue.queue({e, p});
queue.push({e, p}), p;
}
});
}