priority-queue-typed 2.5.2 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +174 -16
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +174 -16
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +174 -16
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +174 -16
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
- package/dist/types/data-structures/base/linear-base.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +191 -15
- package/dist/types/data-structures/binary-tree/bst.d.ts +171 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1061 -167
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1232 -355
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +916 -194
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1078 -141
- package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
- package/dist/types/data-structures/heap/heap.d.ts +140 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +150 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
- package/dist/types/data-structures/queue/deque.d.ts +171 -0
- package/dist/types/data-structures/queue/queue.d.ts +97 -0
- package/dist/types/data-structures/stack/stack.d.ts +72 -2
- package/dist/types/data-structures/trie/trie.d.ts +84 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/umd/priority-queue-typed.js +174 -16
- package/dist/umd/priority-queue-typed.js.map +1 -1
- package/dist/umd/priority-queue-typed.min.js +1 -1
- package/dist/umd/priority-queue-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +32 -0
- package/src/data-structures/base/linear-base.ts +11 -0
- package/src/data-structures/binary-tree/avl-tree.ts +88 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +98 -0
- package/src/data-structures/binary-tree/binary-tree.ts +242 -81
- package/src/data-structures/binary-tree/bst.ts +173 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +139 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +948 -36
- package/src/data-structures/binary-tree/tree-multi-map.ts +893 -13
- package/src/data-structures/binary-tree/tree-multi-set.ts +761 -33
- package/src/data-structures/binary-tree/tree-set.ts +1260 -251
- package/src/data-structures/graph/directed-graph.ts +71 -1
- package/src/data-structures/graph/undirected-graph.ts +64 -1
- package/src/data-structures/hash/hash-map.ts +100 -12
- package/src/data-structures/heap/heap.ts +149 -19
- package/src/data-structures/linked-list/doubly-linked-list.ts +178 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +126 -0
- package/src/data-structures/matrix/matrix.ts +56 -0
- package/src/data-structures/queue/deque.ts +187 -0
- package/src/data-structures/queue/queue.ts +109 -0
- package/src/data-structures/stack/stack.ts +75 -5
- package/src/data-structures/trie/trie.ts +84 -0
- package/src/interfaces/binary-tree.ts +1 -9
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import { BST } from './bst';
|
|
10
10
|
import type {
|
|
11
11
|
AVLTreeOptions,
|
|
12
|
-
BinaryTreeDeleteResult,
|
|
13
12
|
BinaryTreeOptions,
|
|
14
13
|
BSTNOptKeyOrNode,
|
|
15
14
|
EntryCallback,
|
|
@@ -471,6 +470,34 @@ export class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> implements
|
|
|
471
470
|
|
|
472
471
|
|
|
473
472
|
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
|
|
474
501
|
|
|
475
502
|
|
|
476
503
|
|
|
@@ -600,6 +627,27 @@ export class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> implements
|
|
|
600
627
|
|
|
601
628
|
|
|
602
629
|
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
|
|
603
651
|
|
|
604
652
|
|
|
605
653
|
|
|
@@ -630,15 +678,15 @@ export class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> implements
|
|
|
630
678
|
*/
|
|
631
679
|
override delete(
|
|
632
680
|
keyNodeOrEntry: K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined
|
|
633
|
-
):
|
|
634
|
-
const deletedResults =
|
|
681
|
+
): boolean {
|
|
682
|
+
const deletedResults = this._deleteInternal(keyNodeOrEntry);
|
|
635
683
|
// After deletion, balance the path from the parent of the *physically deleted* node.
|
|
636
684
|
for (const { needBalanced } of deletedResults) {
|
|
637
685
|
if (needBalanced) {
|
|
638
|
-
this._balancePath(needBalanced);
|
|
686
|
+
this._balancePath(needBalanced as AVLTreeNode<K, V>);
|
|
639
687
|
}
|
|
640
688
|
}
|
|
641
|
-
return deletedResults;
|
|
689
|
+
return deletedResults.length > 0;
|
|
642
690
|
}
|
|
643
691
|
|
|
644
692
|
/**
|
|
@@ -693,6 +741,20 @@ export class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> implements
|
|
|
693
741
|
|
|
694
742
|
|
|
695
743
|
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
696
758
|
|
|
697
759
|
|
|
698
760
|
|
|
@@ -830,6 +892,27 @@ export class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> implements
|
|
|
830
892
|
|
|
831
893
|
|
|
832
894
|
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
|
|
833
916
|
|
|
834
917
|
|
|
835
918
|
|
|
@@ -103,6 +103,20 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
106
120
|
|
|
107
121
|
|
|
108
122
|
|
|
@@ -180,6 +194,20 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
180
194
|
|
|
181
195
|
|
|
182
196
|
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
183
211
|
|
|
184
212
|
|
|
185
213
|
|
|
@@ -257,6 +285,20 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
257
285
|
|
|
258
286
|
|
|
259
287
|
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
260
302
|
|
|
261
303
|
|
|
262
304
|
|
|
@@ -334,6 +376,20 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
334
376
|
|
|
335
377
|
|
|
336
378
|
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
337
393
|
|
|
338
394
|
|
|
339
395
|
|
|
@@ -409,6 +465,20 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
409
465
|
|
|
410
466
|
|
|
411
467
|
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
412
482
|
|
|
413
483
|
|
|
414
484
|
|
|
@@ -492,6 +562,20 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
492
562
|
|
|
493
563
|
|
|
494
564
|
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
495
579
|
|
|
496
580
|
|
|
497
581
|
|
|
@@ -552,6 +636,13 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
552
636
|
|
|
553
637
|
|
|
554
638
|
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
555
646
|
|
|
556
647
|
|
|
557
648
|
|
|
@@ -621,6 +712,13 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
621
712
|
|
|
622
713
|
|
|
623
714
|
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
|
|
624
722
|
|
|
625
723
|
|
|
626
724
|
|