A priority queue is a data structure that stores elements in a specific order. The user has the power to define the order of priority.
import { PriorityQueue } from 'gis-tools-ts';
// Create a priority queue that sorts numbers in ascending order
const queue = new PriorityQueue<number>([], (a, b) => a - b);
queue.push(1);
queue.push(2);
const current = queue.peek(); // 1
console.log(queue.length); // 2
let next = queue.pop(); // 1
console.log(queue.length); // 1
next = queue.pop(); // 2
console.log(queue.length); // 0