feat(core): improve priority queue performance (#11559)

This commit is contained in:
EYHN
2025-04-09 14:56:32 +00:00
parent e58f230354
commit 1bd31b67cd
6 changed files with 532 additions and 14 deletions
@@ -1,4 +1,4 @@
import { BinarySearchTree } from '@datastructures-js/binary-search-tree';
import { BinarySearchTree } from './binary-search-tree';
export class PriorityQueue {
tree = new BinarySearchTree<{ id: string; priority: number }>((a, b) => {
@@ -39,8 +39,8 @@ export class PriorityQueue {
return id;
}
remove(id: string, priority?: number) {
priority ??= this.priorityMap.get(id);
remove(id: string) {
const priority = this.priorityMap.get(id);
if (priority === undefined) {
return false;
}