max-priority-queue-typed 2.5.1 → 2.5.3

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 (75) hide show
  1. package/dist/cjs/index.cjs +207 -71
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +206 -70
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +207 -72
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +206 -71
  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 +86 -2
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +189 -13
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +270 -3
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1089 -161
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1243 -350
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +980 -255
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1174 -284
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
  24. package/dist/types/data-structures/heap/heap.d.ts +140 -12
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +126 -0
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +127 -0
  30. package/dist/types/data-structures/queue/queue.d.ts +97 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +72 -2
  32. package/dist/types/data-structures/trie/trie.d.ts +84 -0
  33. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  34. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  35. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  36. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  37. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  38. package/dist/umd/max-priority-queue-typed.js +204 -69
  39. package/dist/umd/max-priority-queue-typed.js.map +1 -1
  40. package/dist/umd/max-priority-queue-typed.min.js +1 -1
  41. package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
  42. package/package.json +2 -2
  43. package/src/common/error.ts +19 -1
  44. package/src/common/index.ts +1 -1
  45. package/src/data-structures/base/iterable-element-base.ts +3 -2
  46. package/src/data-structures/binary-tree/avl-tree.ts +99 -5
  47. package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
  48. package/src/data-structures/binary-tree/binary-tree.ts +239 -78
  49. package/src/data-structures/binary-tree/bst.ts +542 -13
  50. package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
  51. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  52. package/src/data-structures/binary-tree/tree-map.ts +1223 -261
  53. package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
  54. package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
  55. package/src/data-structures/binary-tree/tree-set.ts +1018 -99
  56. package/src/data-structures/graph/abstract-graph.ts +2 -2
  57. package/src/data-structures/graph/directed-graph.ts +71 -1
  58. package/src/data-structures/graph/undirected-graph.ts +64 -1
  59. package/src/data-structures/hash/hash-map.ts +102 -16
  60. package/src/data-structures/heap/heap.ts +153 -23
  61. package/src/data-structures/heap/max-heap.ts +2 -2
  62. package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
  63. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  64. package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
  65. package/src/data-structures/matrix/matrix.ts +65 -9
  66. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  67. package/src/data-structures/queue/deque.ts +130 -0
  68. package/src/data-structures/queue/queue.ts +109 -0
  69. package/src/data-structures/stack/stack.ts +75 -5
  70. package/src/data-structures/trie/trie.ts +86 -2
  71. package/src/interfaces/binary-tree.ts +1 -9
  72. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  73. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  74. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  75. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
@@ -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.
@@ -308,6 +308,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
308
308
 
309
309
 
310
310
 
311
+
312
+
313
+
314
+
315
+
316
+
317
+
311
318
 
312
319
 
313
320
 
@@ -379,6 +386,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
379
386
 
380
387
 
381
388
 
389
+
390
+
391
+
392
+
393
+
394
+
395
+
382
396
 
383
397
 
384
398
 
@@ -437,6 +451,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
437
451
 
438
452
 
439
453
 
454
+
455
+
456
+
457
+
458
+
459
+
460
+
440
461
 
441
462
 
442
463
 
@@ -490,6 +511,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
490
511
 
491
512
 
492
513
 
514
+
515
+
516
+
517
+
518
+
519
+
520
+
493
521
 
494
522
 
495
523
 
@@ -535,6 +563,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
535
563
 
536
564
 
537
565
 
566
+
567
+
568
+
569
+
570
+
571
+
572
+
538
573
 
539
574
 
540
575
 
@@ -584,6 +619,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
584
619
 
585
620
 
586
621
 
622
+
623
+
624
+
625
+
626
+
627
+
628
+
587
629
 
588
630
 
589
631
 
@@ -720,6 +762,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
720
762
 
721
763
 
722
764
 
765
+
766
+
767
+
768
+
769
+
770
+
771
+
723
772
 
724
773
 
725
774
 
@@ -797,6 +846,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
797
846
 
798
847
 
799
848
 
849
+
850
+
851
+
852
+
853
+
854
+
855
+
800
856
 
801
857
 
802
858
 
@@ -855,6 +911,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
855
911
 
856
912
 
857
913
 
914
+
915
+
916
+
917
+
918
+
919
+
920
+
858
921
 
859
922
 
860
923
 
@@ -936,6 +999,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
936
999
 
937
1000
 
938
1001
 
1002
+
1003
+
1004
+
1005
+
1006
+
1007
+
1008
+
939
1009
 
940
1010
 
941
1011
 
@@ -985,6 +1055,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
985
1055
 
986
1056
 
987
1057
 
1058
+
1059
+
1060
+
1061
+
1062
+
1063
+
1064
+
988
1065
 
989
1066
 
990
1067
 
@@ -1035,6 +1112,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
1035
1112
 
1036
1113
 
1037
1114
 
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+
1121
+
1038
1122
 
1039
1123
 
1040
1124
 
@@ -1074,7 +1158,7 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
1074
1158
  for (const x of this) {
1075
1159
  const v = thisArg === undefined ? callback(x, i++, this) : callback.call(thisArg, x, i++, this);
1076
1160
  if (typeof v !== 'string') {
1077
- throw new TypeError(ERR.callbackReturnType('string', typeof v, 'Trie.map'));
1161
+ raise(TypeError, ERR.callbackReturnType('string', typeof v, 'Trie.map'));
1078
1162
  }
1079
1163
  newTrie.add(v);
1080
1164
  }
@@ -1,6 +1,5 @@
1
1
  import { BinaryTreeNode } from '../data-structures';
2
2
  import type {
3
- BinaryTreeDeleteResult,
4
3
  BinaryTreeOptions,
5
4
  BTNRep,
6
5
  DFSOrderPattern,
@@ -51,7 +50,7 @@ export interface IBinaryTree<K = any, V = any, R = any> {
51
50
  // Accept BTNRep, predicate, or raw R for deletion
52
51
  delete(
53
52
  keyNodeEntryRawOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V> | null>
54
- ): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
53
+ ): boolean;
55
54
 
56
55
  clear(): void;
57
56
 
@@ -242,11 +241,4 @@ export interface IBinaryTree<K = any, V = any, R = any> {
242
241
 
243
242
  // ---- bulk / interop ----
244
243
  merge(anotherTree: IBinaryTree<K, V, R>): void;
245
-
246
- refill(
247
- keysNodesEntriesOrRaws: Iterable<
248
- K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R
249
- >,
250
- values?: Iterable<V | undefined>
251
- ): void;
252
244
  }
@@ -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>`.