max-priority-queue-typed 2.5.1 → 2.5.2
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 +104 -55
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +103 -54
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +104 -56
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +103 -55
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +77 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +171 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +409 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +411 -6
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +339 -6
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +391 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
- package/dist/types/data-structures/heap/heap.d.ts +42 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +51 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
- package/dist/types/data-structures/queue/deque.d.ts +45 -0
- package/dist/types/data-structures/queue/queue.d.ts +36 -0
- package/dist/types/data-structures/stack/stack.d.ts +30 -0
- package/dist/types/data-structures/trie/trie.d.ts +36 -0
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/umd/max-priority-queue-typed.js +101 -53
- package/dist/umd/max-priority-queue-typed.js.map +1 -1
- package/dist/umd/max-priority-queue-typed.min.js +1 -1
- package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/binary-tree/avl-tree.ts +47 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +46 -4
- package/src/data-structures/binary-tree/binary-tree.ts +79 -4
- package/src/data-structures/binary-tree/bst.ts +441 -6
- package/src/data-structures/binary-tree/red-black-tree.ts +73 -0
- package/src/data-structures/binary-tree/segment-tree.ts +18 -0
- package/src/data-structures/binary-tree/tree-map.ts +434 -9
- package/src/data-structures/binary-tree/tree-multi-map.ts +426 -5
- package/src/data-structures/binary-tree/tree-multi-set.ts +350 -6
- package/src/data-structures/binary-tree/tree-set.ts +410 -8
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +30 -0
- package/src/data-structures/graph/undirected-graph.ts +27 -0
- package/src/data-structures/hash/hash-map.ts +35 -4
- package/src/data-structures/heap/heap.ts +46 -4
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +51 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +59 -5
- package/src/data-structures/matrix/matrix.ts +33 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +45 -0
- package/src/data-structures/queue/queue.ts +36 -0
- package/src/data-structures/stack/stack.ts +30 -0
- package/src/data-structures/trie/trie.ts +38 -2
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
|
@@ -185,6 +185,9 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
185
185
|
|
|
186
186
|
|
|
187
187
|
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
188
191
|
|
|
189
192
|
|
|
190
193
|
|
|
@@ -234,6 +237,9 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
234
237
|
|
|
235
238
|
|
|
236
239
|
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
237
243
|
|
|
238
244
|
|
|
239
245
|
|
|
@@ -303,6 +309,9 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
303
309
|
|
|
304
310
|
|
|
305
311
|
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
306
315
|
|
|
307
316
|
|
|
308
317
|
|
|
@@ -364,6 +373,9 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
364
373
|
|
|
365
374
|
|
|
366
375
|
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
367
379
|
|
|
368
380
|
|
|
369
381
|
|
|
@@ -434,6 +446,9 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
434
446
|
|
|
435
447
|
|
|
436
448
|
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
|
|
437
452
|
|
|
438
453
|
|
|
439
454
|
|
|
@@ -492,6 +507,9 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
492
507
|
|
|
493
508
|
|
|
494
509
|
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
495
513
|
|
|
496
514
|
|
|
497
515
|
|
|
@@ -543,6 +561,9 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
543
561
|
|
|
544
562
|
|
|
545
563
|
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
546
567
|
|
|
547
568
|
|
|
548
569
|
|
|
@@ -643,6 +664,9 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
643
664
|
|
|
644
665
|
|
|
645
666
|
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
|
|
646
670
|
|
|
647
671
|
|
|
648
672
|
|
|
@@ -688,6 +712,9 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
688
712
|
|
|
689
713
|
|
|
690
714
|
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
|
|
691
718
|
|
|
692
719
|
|
|
693
720
|
|
|
@@ -762,6 +789,9 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
762
789
|
|
|
763
790
|
|
|
764
791
|
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
|
|
765
795
|
|
|
766
796
|
|
|
767
797
|
|
|
@@ -814,6 +844,9 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
814
844
|
|
|
815
845
|
|
|
816
846
|
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
|
|
817
850
|
|
|
818
851
|
|
|
819
852
|
|
|
@@ -870,6 +903,9 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
870
903
|
|
|
871
904
|
|
|
872
905
|
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
873
909
|
|
|
874
910
|
|
|
875
911
|
|
|
@@ -190,6 +190,9 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
190
190
|
|
|
191
191
|
|
|
192
192
|
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
193
196
|
|
|
194
197
|
|
|
195
198
|
|
|
@@ -255,6 +258,9 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
255
258
|
|
|
256
259
|
|
|
257
260
|
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
258
264
|
|
|
259
265
|
|
|
260
266
|
|
|
@@ -303,6 +309,9 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
303
309
|
|
|
304
310
|
|
|
305
311
|
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
306
315
|
|
|
307
316
|
|
|
308
317
|
|
|
@@ -351,6 +360,9 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
351
360
|
|
|
352
361
|
|
|
353
362
|
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
354
366
|
|
|
355
367
|
|
|
356
368
|
|
|
@@ -408,6 +420,9 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
408
420
|
|
|
409
421
|
|
|
410
422
|
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
411
426
|
|
|
412
427
|
|
|
413
428
|
|
|
@@ -482,6 +497,9 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
482
497
|
|
|
483
498
|
|
|
484
499
|
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
485
503
|
|
|
486
504
|
|
|
487
505
|
|
|
@@ -558,6 +576,9 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
558
576
|
|
|
559
577
|
|
|
560
578
|
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
|
|
561
582
|
|
|
562
583
|
|
|
563
584
|
|
|
@@ -603,6 +624,9 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
603
624
|
|
|
604
625
|
|
|
605
626
|
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
606
630
|
|
|
607
631
|
|
|
608
632
|
|
|
@@ -654,6 +678,9 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
654
678
|
|
|
655
679
|
|
|
656
680
|
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
657
684
|
|
|
658
685
|
|
|
659
686
|
|
|
@@ -727,6 +754,9 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
727
754
|
|
|
728
755
|
|
|
729
756
|
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
730
760
|
|
|
731
761
|
|
|
732
762
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import type { ElementCallback, TrieOptions } from '../../types';
|
|
10
10
|
import { IterableElementBase } from '../base';
|
|
11
|
-
import { ERR } from '../../common';
|
|
11
|
+
import { ERR, raise } from '../../common';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Node used by Trie to store one character and its children.
|
|
@@ -312,6 +312,9 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
312
312
|
|
|
313
313
|
|
|
314
314
|
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
315
318
|
|
|
316
319
|
|
|
317
320
|
|
|
@@ -383,6 +386,9 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
383
386
|
|
|
384
387
|
|
|
385
388
|
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
386
392
|
|
|
387
393
|
|
|
388
394
|
|
|
@@ -441,6 +447,9 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
441
447
|
|
|
442
448
|
|
|
443
449
|
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
|
|
444
453
|
|
|
445
454
|
|
|
446
455
|
|
|
@@ -494,6 +503,9 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
494
503
|
|
|
495
504
|
|
|
496
505
|
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
497
509
|
|
|
498
510
|
|
|
499
511
|
|
|
@@ -539,6 +551,9 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
539
551
|
|
|
540
552
|
|
|
541
553
|
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
542
557
|
|
|
543
558
|
|
|
544
559
|
|
|
@@ -588,6 +603,9 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
588
603
|
|
|
589
604
|
|
|
590
605
|
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
591
609
|
|
|
592
610
|
|
|
593
611
|
|
|
@@ -724,6 +742,9 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
724
742
|
|
|
725
743
|
|
|
726
744
|
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
727
748
|
|
|
728
749
|
|
|
729
750
|
|
|
@@ -801,6 +822,9 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
801
822
|
|
|
802
823
|
|
|
803
824
|
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
804
828
|
|
|
805
829
|
|
|
806
830
|
|
|
@@ -859,6 +883,9 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
859
883
|
|
|
860
884
|
|
|
861
885
|
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
862
889
|
|
|
863
890
|
|
|
864
891
|
|
|
@@ -940,6 +967,9 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
940
967
|
|
|
941
968
|
|
|
942
969
|
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
|
|
943
973
|
|
|
944
974
|
|
|
945
975
|
|
|
@@ -989,6 +1019,9 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
989
1019
|
|
|
990
1020
|
|
|
991
1021
|
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
992
1025
|
|
|
993
1026
|
|
|
994
1027
|
|
|
@@ -1039,6 +1072,9 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
1039
1072
|
|
|
1040
1073
|
|
|
1041
1074
|
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
|
|
1042
1078
|
|
|
1043
1079
|
|
|
1044
1080
|
|
|
@@ -1074,7 +1110,7 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
1074
1110
|
for (const x of this) {
|
|
1075
1111
|
const v = thisArg === undefined ? callback(x, i++, this) : callback.call(thisArg, x, i++, this);
|
|
1076
1112
|
if (typeof v !== 'string') {
|
|
1077
|
-
|
|
1113
|
+
raise(TypeError, ERR.callbackReturnType('string', typeof v, 'Trie.map'));
|
|
1078
1114
|
}
|
|
1079
1115
|
newTrie.add(v);
|
|
1080
1116
|
}
|
|
@@ -11,6 +11,12 @@ export interface TreeMapOptions<K, V, R = [K, V]> {
|
|
|
11
11
|
*/
|
|
12
12
|
isMapMode?: boolean;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Enable order-statistic operations (select, rank, rangeByRank).
|
|
16
|
+
* When true, subtree counts are maintained on every node.
|
|
17
|
+
*/
|
|
18
|
+
enableOrderStatistic?: boolean;
|
|
19
|
+
|
|
14
20
|
/**
|
|
15
21
|
* Transform raw elements into `[key, value]` entries.
|
|
16
22
|
* When provided, the constructor accepts `Iterable<R>` instead of `Iterable<[K, V]>`.
|
|
@@ -11,6 +11,11 @@ export interface TreeMultiSetOptions<K, R = K> {
|
|
|
11
11
|
*/
|
|
12
12
|
isMapMode?: boolean;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Enable order-statistic operations (select, rank, rangeByRank).
|
|
16
|
+
*/
|
|
17
|
+
enableOrderStatistic?: boolean;
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* Transform raw elements into keys.
|
|
16
21
|
* When provided, the constructor accepts `Iterable<R>` instead of `Iterable<K>`.
|
|
@@ -11,6 +11,11 @@ export interface TreeSetOptions<K, R = K> {
|
|
|
11
11
|
*/
|
|
12
12
|
isMapMode?: boolean;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Enable order-statistic operations (select, rank, rangeByRank).
|
|
16
|
+
*/
|
|
17
|
+
enableOrderStatistic?: boolean;
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* Transform raw elements into keys.
|
|
16
21
|
* When provided, the constructor accepts `Iterable<R>` instead of `Iterable<K>`.
|