mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 02:01:22 +01:00
removed priority queue in favor of simple array extension as it will be easier to migrate to esm
This commit is contained in:
parent
2ec2c9f773
commit
2e5cca0879
2 changed files with 36 additions and 1 deletions
1
libs/priority-queue.min.js
vendored
1
libs/priority-queue.min.js
vendored
File diff suppressed because one or more lines are too long
36
modules/priority-queue.js
Normal file
36
modules/priority-queue.js
Normal 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;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue