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.
Files changed (73) hide show
  1. package/dist/cjs/index.cjs +104 -55
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +103 -54
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +104 -56
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +103 -55
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/common/error.d.ts +9 -0
  10. package/dist/types/common/index.d.ts +1 -1
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +77 -2
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +171 -0
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +409 -0
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +411 -6
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +339 -6
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +391 -0
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
  24. package/dist/types/data-structures/heap/heap.d.ts +42 -0
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +51 -0
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +45 -0
  30. package/dist/types/data-structures/queue/queue.d.ts +36 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +30 -0
  32. package/dist/types/data-structures/trie/trie.d.ts +36 -0
  33. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  34. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  35. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  36. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  37. package/dist/umd/max-priority-queue-typed.js +101 -53
  38. package/dist/umd/max-priority-queue-typed.js.map +1 -1
  39. package/dist/umd/max-priority-queue-typed.min.js +1 -1
  40. package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
  41. package/package.json +2 -2
  42. package/src/common/error.ts +19 -1
  43. package/src/common/index.ts +1 -1
  44. package/src/data-structures/base/iterable-element-base.ts +3 -2
  45. package/src/data-structures/binary-tree/avl-tree.ts +47 -0
  46. package/src/data-structures/binary-tree/binary-indexed-tree.ts +46 -4
  47. package/src/data-structures/binary-tree/binary-tree.ts +79 -4
  48. package/src/data-structures/binary-tree/bst.ts +441 -6
  49. package/src/data-structures/binary-tree/red-black-tree.ts +73 -0
  50. package/src/data-structures/binary-tree/segment-tree.ts +18 -0
  51. package/src/data-structures/binary-tree/tree-map.ts +434 -9
  52. package/src/data-structures/binary-tree/tree-multi-map.ts +426 -5
  53. package/src/data-structures/binary-tree/tree-multi-set.ts +350 -6
  54. package/src/data-structures/binary-tree/tree-set.ts +410 -8
  55. package/src/data-structures/graph/abstract-graph.ts +2 -2
  56. package/src/data-structures/graph/directed-graph.ts +30 -0
  57. package/src/data-structures/graph/undirected-graph.ts +27 -0
  58. package/src/data-structures/hash/hash-map.ts +35 -4
  59. package/src/data-structures/heap/heap.ts +46 -4
  60. package/src/data-structures/heap/max-heap.ts +2 -2
  61. package/src/data-structures/linked-list/doubly-linked-list.ts +51 -0
  62. package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
  63. package/src/data-structures/linked-list/skip-linked-list.ts +59 -5
  64. package/src/data-structures/matrix/matrix.ts +33 -9
  65. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  66. package/src/data-structures/queue/deque.ts +45 -0
  67. package/src/data-structures/queue/queue.ts +36 -0
  68. package/src/data-structures/stack/stack.ts +30 -0
  69. package/src/data-structures/trie/trie.ts +38 -2
  70. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  71. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  72. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  73. 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
- throw new TypeError(ERR.callbackReturnType('string', typeof v, 'Trie.map'));
1113
+ raise(TypeError, ERR.callbackReturnType('string', typeof v, 'Trie.map'));
1078
1114
  }
1079
1115
  newTrie.add(v);
1080
1116
  }
@@ -5,6 +5,7 @@ type BSTBaseOptions<K, V, R> = Omit<BinaryTreeOptions<K, V, R>, 'isDuplicate'>;
5
5
 
6
6
  export type BSTOptions<K, V, R> = BSTBaseOptions<K, V, R> & {
7
7
  comparator?: Comparator<K>;
8
+ enableOrderStatistic?: boolean;
8
9
  }
9
10
 
10
11
  export type BSTNOptKey<K> = K | undefined;
@@ -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>`.