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

This commit is contained in:
RyanGuild 2024-10-22 14:54:57 -04:00
parent 2ec2c9f773
commit 2e5cca0879
2 changed files with 36 additions and 1 deletions

File diff suppressed because one or more lines are too long

36
modules/priority-queue.js Normal file
View file

@ -0,0 +1,36 @@
/**
* @template T
*/
class PriorityQueue extends Array {
/**
* @param {{comparator: (a:T, B:T) => number | boolean}} options
*/
constructor({comparator}) {
super();
}
/**
* @param {T} value
*/
enqueue(value) {
this.push(value);
this.sort(comparator);
}
/**
* @returns {T}
*/
dequeue() {
return this.shift();
}
}
globalThis.PriorityQueue = PriorityQueue;