red-black-tree-typed 1.53.7 → 1.54.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 (119) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +52 -0
  3. package/dist/common/index.js +5 -0
  4. package/dist/data-structures/base/iterable-entry-base.js +4 -4
  5. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +213 -0
  6. package/dist/data-structures/binary-tree/avl-tree-counter.js +407 -0
  7. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +71 -170
  8. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +133 -328
  9. package/dist/data-structures/binary-tree/avl-tree.d.ts +103 -69
  10. package/dist/data-structures/binary-tree/avl-tree.js +130 -70
  11. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
  12. package/dist/data-structures/binary-tree/binary-indexed-tree.js +3 -0
  13. package/dist/data-structures/binary-tree/binary-tree.d.ts +268 -202
  14. package/dist/data-structures/binary-tree/binary-tree.js +311 -263
  15. package/dist/data-structures/binary-tree/bst.d.ts +193 -139
  16. package/dist/data-structures/binary-tree/bst.js +248 -164
  17. package/dist/data-structures/binary-tree/index.d.ts +3 -1
  18. package/dist/data-structures/binary-tree/index.js +3 -1
  19. package/dist/data-structures/binary-tree/red-black-tree.d.ts +286 -0
  20. package/dist/data-structures/binary-tree/{rb-tree.js → red-black-tree.js} +176 -107
  21. package/dist/data-structures/binary-tree/tree-counter.d.ts +212 -0
  22. package/dist/data-structures/binary-tree/tree-counter.js +444 -0
  23. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +78 -170
  24. package/dist/data-structures/binary-tree/tree-multi-map.js +145 -367
  25. package/dist/data-structures/graph/abstract-graph.js +2 -2
  26. package/dist/data-structures/graph/directed-graph.d.ts +3 -0
  27. package/dist/data-structures/graph/directed-graph.js +3 -0
  28. package/dist/data-structures/graph/map-graph.d.ts +3 -0
  29. package/dist/data-structures/graph/map-graph.js +3 -0
  30. package/dist/data-structures/graph/undirected-graph.d.ts +3 -0
  31. package/dist/data-structures/graph/undirected-graph.js +3 -0
  32. package/dist/data-structures/hash/hash-map.d.ts +31 -1
  33. package/dist/data-structures/hash/hash-map.js +35 -5
  34. package/dist/data-structures/heap/heap.d.ts +20 -3
  35. package/dist/data-structures/heap/heap.js +31 -11
  36. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +46 -11
  37. package/dist/data-structures/linked-list/doubly-linked-list.js +68 -21
  38. package/dist/data-structures/linked-list/singly-linked-list.d.ts +47 -11
  39. package/dist/data-structures/linked-list/singly-linked-list.js +73 -26
  40. package/dist/data-structures/linked-list/skip-linked-list.d.ts +3 -0
  41. package/dist/data-structures/linked-list/skip-linked-list.js +3 -0
  42. package/dist/data-structures/matrix/matrix.d.ts +3 -0
  43. package/dist/data-structures/matrix/matrix.js +3 -0
  44. package/dist/data-structures/matrix/navigator.d.ts +3 -0
  45. package/dist/data-structures/matrix/navigator.js +3 -0
  46. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
  47. package/dist/data-structures/priority-queue/max-priority-queue.js +3 -0
  48. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
  49. package/dist/data-structures/priority-queue/min-priority-queue.js +3 -0
  50. package/dist/data-structures/queue/deque.d.ts +37 -8
  51. package/dist/data-structures/queue/deque.js +73 -29
  52. package/dist/data-structures/queue/queue.d.ts +41 -1
  53. package/dist/data-structures/queue/queue.js +51 -9
  54. package/dist/data-structures/stack/stack.d.ts +27 -10
  55. package/dist/data-structures/stack/stack.js +39 -20
  56. package/dist/data-structures/trie/trie.d.ts +8 -7
  57. package/dist/data-structures/trie/trie.js +8 -7
  58. package/dist/index.d.ts +4 -4
  59. package/dist/index.js +4 -4
  60. package/dist/interfaces/binary-tree.d.ts +8 -8
  61. package/dist/types/data-structures/base/base.d.ts +1 -1
  62. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  63. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -4
  64. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -3
  65. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -3
  66. package/dist/types/data-structures/binary-tree/bst.d.ts +4 -4
  67. package/dist/types/data-structures/binary-tree/index.d.ts +3 -1
  68. package/dist/types/data-structures/binary-tree/index.js +3 -1
  69. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
  70. package/dist/types/data-structures/binary-tree/red-black-tree.js +2 -0
  71. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  72. package/dist/types/data-structures/binary-tree/tree-counter.js +2 -0
  73. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -5
  74. package/package.json +3 -3
  75. package/src/common/index.ts +7 -1
  76. package/src/data-structures/base/iterable-entry-base.ts +4 -4
  77. package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
  78. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +151 -370
  79. package/src/data-structures/binary-tree/avl-tree.ts +162 -105
  80. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
  81. package/src/data-structures/binary-tree/binary-tree.ts +488 -416
  82. package/src/data-structures/binary-tree/bst.ts +326 -251
  83. package/src/data-structures/binary-tree/index.ts +3 -1
  84. package/src/data-structures/binary-tree/{rb-tree.ts → red-black-tree.ts} +219 -145
  85. package/src/data-structures/binary-tree/tree-counter.ts +504 -0
  86. package/src/data-structures/binary-tree/tree-multi-map.ts +159 -401
  87. package/src/data-structures/graph/abstract-graph.ts +2 -2
  88. package/src/data-structures/graph/directed-graph.ts +3 -0
  89. package/src/data-structures/graph/map-graph.ts +3 -0
  90. package/src/data-structures/graph/undirected-graph.ts +3 -0
  91. package/src/data-structures/hash/hash-map.ts +37 -7
  92. package/src/data-structures/heap/heap.ts +33 -10
  93. package/src/data-structures/linked-list/doubly-linked-list.ts +75 -21
  94. package/src/data-structures/linked-list/singly-linked-list.ts +80 -27
  95. package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
  96. package/src/data-structures/matrix/matrix.ts +3 -0
  97. package/src/data-structures/matrix/navigator.ts +3 -0
  98. package/src/data-structures/priority-queue/max-priority-queue.ts +3 -0
  99. package/src/data-structures/priority-queue/min-priority-queue.ts +3 -0
  100. package/src/data-structures/queue/deque.ts +72 -28
  101. package/src/data-structures/queue/queue.ts +50 -7
  102. package/src/data-structures/stack/stack.ts +39 -20
  103. package/src/data-structures/trie/trie.ts +8 -7
  104. package/src/index.ts +4 -4
  105. package/src/interfaces/binary-tree.ts +10 -21
  106. package/src/types/data-structures/base/base.ts +1 -1
  107. package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
  108. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -6
  109. package/src/types/data-structures/binary-tree/avl-tree.ts +0 -5
  110. package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
  111. package/src/types/data-structures/binary-tree/bst.ts +6 -6
  112. package/src/types/data-structures/binary-tree/index.ts +3 -1
  113. package/src/types/data-structures/binary-tree/red-black-tree.ts +5 -0
  114. package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
  115. package/src/types/data-structures/binary-tree/tree-multi-map.ts +2 -7
  116. package/dist/data-structures/binary-tree/rb-tree.d.ts +0 -209
  117. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +0 -6
  118. package/src/types/data-structures/binary-tree/rb-tree.ts +0 -10
  119. /package/dist/types/data-structures/binary-tree/{rb-tree.js → avl-tree-counter.js} +0 -0
@@ -28,10 +28,6 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
28
28
  * @returns The size of the elements array.
29
29
  */
30
30
  get size(): number;
31
- /**
32
- * Time Complexity: O(n)
33
- * Space Complexity: O(n)
34
- */
35
31
  /**
36
32
  * Time Complexity: O(n)
37
33
  * Space Complexity: O(n)
@@ -43,6 +39,9 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
43
39
  */
44
40
  static fromArray<E>(elements: E[]): Stack<E>;
45
41
  /**
42
+ * Time Complexity: O(1)
43
+ * Space Complexity: O(1)
44
+ *
46
45
  * The function checks if an array is empty and returns a boolean value.
47
46
  * @returns A boolean value indicating whether the `_elements` array is empty or not.
48
47
  */
@@ -74,15 +73,33 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
74
73
  */
75
74
  pop(): E | undefined;
76
75
  /**
77
- * The delete function removes an element from the stack.
78
- * @param element: E Specify the element to be deleted
79
- * @return A boolean value indicating whether the element was successfully deleted or not
76
+ * Time Complexity: O(k)
77
+ * Space Complexity: O(1)
78
+ *
79
+ * The function `pushMany` iterates over elements and pushes them into an array after applying a
80
+ * transformation function if provided.
81
+ * @param {Iterable<E> | Iterable<R>} elements - The `elements` parameter in the `pushMany` function
82
+ * is an iterable containing elements of type `E` or `R`. The function iterates over each element in
83
+ * the iterable and pushes it into the data structure. If a transformation function `toElementFn` is
84
+ * provided, it is used to
85
+ * @returns The `pushMany` function is returning an array of boolean values indicating whether each
86
+ * element was successfully pushed into the data structure.
87
+ */
88
+ pushMany(elements: Iterable<E> | Iterable<R>): boolean[];
89
+ /**
90
+ * Time Complexity: O(n)
91
+ * Space Complexity: O(1)
92
+ *
93
+ * The toArray function returns a copy of the elements in an array.
94
+ * @returns An array of type E.
80
95
  */
81
96
  delete(element: E): boolean;
82
97
  /**
83
- * The deleteAt function deletes the element at a given index.
84
- * @param index: number Determine the index of the element to be deleted
85
- * @return A boolean value
98
+ * Time Complexity: O(n)
99
+ * Space Complexity: O(1)
100
+ *
101
+ * The toArray function returns a copy of the elements in an array.
102
+ * @returns An array of type E.
86
103
  */
87
104
  deleteAt(index: number): boolean;
88
105
  /**
@@ -14,16 +14,7 @@ class Stack extends base_1.IterableElementBase {
14
14
  constructor(elements = [], options) {
15
15
  super(options);
16
16
  this._elements = [];
17
- if (elements) {
18
- for (const el of elements) {
19
- if (this.toElementFn) {
20
- this.push(this.toElementFn(el));
21
- }
22
- else {
23
- this.push(el);
24
- }
25
- }
26
- }
17
+ this.pushMany(elements);
27
18
  }
28
19
  /**
29
20
  * The elements function returns the elements of this set.
@@ -39,10 +30,6 @@ class Stack extends base_1.IterableElementBase {
39
30
  get size() {
40
31
  return this.elements.length;
41
32
  }
42
- /**
43
- * Time Complexity: O(n)
44
- * Space Complexity: O(n)
45
- */
46
33
  /**
47
34
  * Time Complexity: O(n)
48
35
  * Space Complexity: O(n)
@@ -56,6 +43,9 @@ class Stack extends base_1.IterableElementBase {
56
43
  return new Stack(elements);
57
44
  }
58
45
  /**
46
+ * Time Complexity: O(1)
47
+ * Space Complexity: O(1)
48
+ *
59
49
  * The function checks if an array is empty and returns a boolean value.
60
50
  * @returns A boolean value indicating whether the `_elements` array is empty or not.
61
51
  */
@@ -100,18 +90,47 @@ class Stack extends base_1.IterableElementBase {
100
90
  return this.elements.pop();
101
91
  }
102
92
  /**
103
- * The delete function removes an element from the stack.
104
- * @param element: E Specify the element to be deleted
105
- * @return A boolean value indicating whether the element was successfully deleted or not
93
+ * Time Complexity: O(k)
94
+ * Space Complexity: O(1)
95
+ *
96
+ * The function `pushMany` iterates over elements and pushes them into an array after applying a
97
+ * transformation function if provided.
98
+ * @param {Iterable<E> | Iterable<R>} elements - The `elements` parameter in the `pushMany` function
99
+ * is an iterable containing elements of type `E` or `R`. The function iterates over each element in
100
+ * the iterable and pushes it into the data structure. If a transformation function `toElementFn` is
101
+ * provided, it is used to
102
+ * @returns The `pushMany` function is returning an array of boolean values indicating whether each
103
+ * element was successfully pushed into the data structure.
104
+ */
105
+ pushMany(elements) {
106
+ const ans = [];
107
+ for (const el of elements) {
108
+ if (this.toElementFn) {
109
+ ans.push(this.push(this.toElementFn(el)));
110
+ }
111
+ else {
112
+ ans.push(this.push(el));
113
+ }
114
+ }
115
+ return ans;
116
+ }
117
+ /**
118
+ * Time Complexity: O(n)
119
+ * Space Complexity: O(1)
120
+ *
121
+ * The toArray function returns a copy of the elements in an array.
122
+ * @returns An array of type E.
106
123
  */
107
124
  delete(element) {
108
125
  const index = this.elements.indexOf(element);
109
126
  return this.deleteAt(index);
110
127
  }
111
128
  /**
112
- * The deleteAt function deletes the element at a given index.
113
- * @param index: number Determine the index of the element to be deleted
114
- * @return A boolean value
129
+ * Time Complexity: O(n)
130
+ * Space Complexity: O(1)
131
+ *
132
+ * The toArray function returns a copy of the elements in an array.
133
+ * @returns An array of type E.
115
134
  */
116
135
  deleteAt(index) {
117
136
  const spliced = this.elements.splice(index, 1);
@@ -7,10 +7,6 @@
7
7
  */
8
8
  import type { ElementCallback, TrieOptions } from '../../types';
9
9
  import { IterableElementBase } from '../base';
10
- /**
11
- * TrieNode represents a node in the Trie data structure. It holds a character key, a map of children nodes,
12
- * and a flag indicating whether it's the end of a word.
13
- */
14
10
  export declare class TrieNode {
15
11
  constructor(key: string);
16
12
  protected _key: string;
@@ -200,7 +196,7 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
200
196
  * @returns The `addMany` method returns an array of boolean values indicating whether each word in
201
197
  * the input iterable was successfully added to the data structure.
202
198
  */
203
- addMany(words?: Iterable<string> | Iterable<R>): boolean[];
199
+ addMany(words: Iterable<string> | Iterable<R>): boolean[];
204
200
  /**
205
201
  * Time Complexity: O(l), where l is the length of the input word.
206
202
  * Space Complexity: O(1) - Constant space.
@@ -235,9 +231,14 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
235
231
  */
236
232
  delete(word: string): boolean;
237
233
  /**
238
- * Time Complexity: O(n), where n is the total number of nodes in the trie.
239
- * Space Complexity: O(1) - Constant space.
234
+ * Time Complexity: O(n)
235
+ * Space Complexity: O(1)
240
236
  *
237
+ * The function `getHeight` calculates the height of a trie data structure starting from the root
238
+ * node.
239
+ * @returns The `getHeight` method returns the maximum depth or height of the trie tree starting from
240
+ * the root node. It calculates the depth using a breadth-first search (BFS) traversal of the trie
241
+ * tree and returns the maximum depth found.
241
242
  */
242
243
  getHeight(): number;
243
244
  /**
@@ -2,10 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Trie = exports.TrieNode = void 0;
4
4
  const base_1 = require("../base");
5
- /**
6
- * TrieNode represents a node in the Trie data structure. It holds a character key, a map of children nodes,
7
- * and a flag indicating whether it's the end of a word.
8
- */
9
5
  class TrieNode {
10
6
  constructor(key) {
11
7
  this._key = key;
@@ -243,7 +239,7 @@ class Trie extends base_1.IterableElementBase {
243
239
  * @returns The `addMany` method returns an array of boolean values indicating whether each word in
244
240
  * the input iterable was successfully added to the data structure.
245
241
  */
246
- addMany(words = []) {
242
+ addMany(words) {
247
243
  const ans = [];
248
244
  for (const word of words) {
249
245
  if (this.toElementFn) {
@@ -338,9 +334,14 @@ class Trie extends base_1.IterableElementBase {
338
334
  return isDeleted;
339
335
  }
340
336
  /**
341
- * Time Complexity: O(n), where n is the total number of nodes in the trie.
342
- * Space Complexity: O(1) - Constant space.
337
+ * Time Complexity: O(n)
338
+ * Space Complexity: O(1)
343
339
  *
340
+ * The function `getHeight` calculates the height of a trie data structure starting from the root
341
+ * node.
342
+ * @returns The `getHeight` method returns the maximum depth or height of the trie tree starting from
343
+ * the root node. It calculates the depth using a breadth-first search (BFS) traversal of the trie
344
+ * tree and returns the maximum depth found.
344
345
  */
345
346
  getHeight() {
346
347
  const startNode = this.root;
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * data-structure-typed
3
3
  *
4
- * @author Tyler Zeng
5
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
4
+ * @author Pablo Zeng
5
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- export * from './data-structures/binary-tree/rb-tree';
8
+ export * from './data-structures/binary-tree/red-black-tree';
9
9
  export * from './data-structures/binary-tree/bst';
10
10
  export * from './data-structures/binary-tree/binary-tree';
11
- export * from './types/data-structures/binary-tree/rb-tree';
11
+ export * from './types/data-structures/binary-tree/red-black-tree';
12
12
  export * from './types/data-structures/binary-tree/bst';
13
13
  export * from './types/data-structures/binary-tree/binary-tree';
14
14
  export * from './types/common';
package/dist/index.js CHANGED
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  /**
18
18
  * data-structure-typed
19
19
  *
20
- * @author Tyler Zeng
21
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
20
+ * @author Pablo Zeng
21
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
22
22
  * @license MIT License
23
23
  */
24
- __exportStar(require("./data-structures/binary-tree/rb-tree"), exports);
24
+ __exportStar(require("./data-structures/binary-tree/red-black-tree"), exports);
25
25
  __exportStar(require("./data-structures/binary-tree/bst"), exports);
26
26
  __exportStar(require("./data-structures/binary-tree/binary-tree"), exports);
27
- __exportStar(require("./types/data-structures/binary-tree/rb-tree"), exports);
27
+ __exportStar(require("./types/data-structures/binary-tree/red-black-tree"), exports);
28
28
  __exportStar(require("./types/data-structures/binary-tree/bst"), exports);
29
29
  __exportStar(require("./types/data-structures/binary-tree/binary-tree"), exports);
30
30
  __exportStar(require("./types/common"), exports);
@@ -1,9 +1,9 @@
1
- import { BinaryTree, BinaryTreeNode } from '../data-structures';
2
- import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNRep, NodePredicate } from '../types';
3
- export interface IBinaryTree<K = any, V = any, R = object, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, R, NODE, TREE> = BinaryTreeNested<K, V, R, NODE>> {
4
- createNode(key: K, value?: NODE['value']): NODE;
5
- createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;
6
- add(keyOrNodeOrEntryOrRawElement: BTNRep<K, V, NODE>, value?: V, count?: number): boolean;
7
- addMany(nodes: Iterable<BTNRep<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
8
- delete(predicate: R | BTNRep<K, V, NODE> | NodePredicate<NODE>): BinaryTreeDeleteResult<NODE>[];
1
+ import { BinaryTreeNode } from '../data-structures';
2
+ import type { BinaryTreeDeleteResult, BinaryTreeOptions, BTNRep, NodePredicate } from '../types';
3
+ export interface IBinaryTree<K = any, V = any, R = object, MK = any, MV = any, MR = object> {
4
+ createNode(key: K, value?: BinaryTreeNode['value']): BinaryTreeNode;
5
+ createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): IBinaryTree<K, V, R, MK, MV, MR>;
6
+ add(keyOrNodeOrEntryOrRawElement: BTNRep<K, V, BinaryTreeNode<K, V>>, value?: V, count?: number): boolean;
7
+ addMany(nodes: Iterable<BTNRep<K, V, BinaryTreeNode<K, V>>>, values?: Iterable<V | undefined>): boolean[];
8
+ delete(predicate: R | BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
9
9
  }
@@ -1,5 +1,5 @@
1
1
  import { IterableElementBase, IterableEntryBase } from '../../../data-structures';
2
- export type EntryCallback<K, V, R> = (value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
2
+ export type EntryCallback<K, V, R> = (key: K, value: V, index: number, container: IterableEntryBase<K, V>) => R;
3
3
  export type ElementCallback<E, R, RT, C> = (element: E, index: number, container: IterableElementBase<E, R, C>) => RT;
4
4
  export type ReduceEntryCallback<K, V, R> = (accumulator: R, value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
5
5
  export type ReduceElementCallback<E, R, RT, C> = (accumulator: RT, element: E, index: number, container: IterableElementBase<E, R, C>) => RT;
@@ -0,0 +1,2 @@
1
+ import { AVLTreeOptions } from './avl-tree';
2
+ export type AVLTreeCounterOptions<K, V, R> = AVLTreeOptions<K, V, R> & {};
@@ -1,5 +1,2 @@
1
- import { AVLTreeMultiMap, AVLTreeMultiMapNode } from '../../../data-structures';
2
1
  import type { AVLTreeOptions } from './avl-tree';
3
- export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
- export type AVLTreeMultiMapNested<K, V, R, NODE extends AVLTreeMultiMapNode<K, V, NODE>> = AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
- export type AVLTreeMultiMapOptions<K, V, R> = AVLTreeOptions<K, V, R> & {};
2
+ export type AVLTreeMultiMapOptions<K, V, R> = Omit<AVLTreeOptions<K, V, R>, 'isMapMode'> & {};
@@ -1,5 +1,2 @@
1
- import { AVLTree, AVLTreeNode } from '../../../data-structures';
2
1
  import { BSTOptions } from './bst';
3
- export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
- export type AVLTreeNested<K, V, R, NODE extends AVLTreeNode<K, V, NODE>> = AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
2
  export type AVLTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
@@ -1,8 +1,5 @@
1
- import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
2
1
  import { IterationType, OptValue } from '../../common';
3
2
  import { DFSOperation } from '../../../common';
4
- export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
- export type BinaryTreeNested<K, V, R, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
3
  export type ToEntryFn<K, V, R> = (rawElement: R) => BTNEntry<K, V>;
7
4
  export type BinaryTreeOptions<K, V, R> = {
8
5
  iterationType?: IterationType;
@@ -1,12 +1,12 @@
1
- import { BST, BSTNode } from '../../../data-structures';
2
1
  import type { BinaryTreeOptions } from './binary-tree';
3
2
  import { Comparable } from '../../utils';
4
- export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
- export type BSTNested<K, V, R, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
3
+ import { OptValue } from '../../common';
6
4
  export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {
7
- extractComparable?: (key: K) => Comparable;
5
+ specifyComparable?: (key: K) => Comparable;
8
6
  isReverse?: boolean;
9
7
  };
10
8
  export type BSTNOptKey<K> = K | undefined;
11
9
  export type OptNode<NODE> = NODE | undefined;
10
+ export type BSTNEntry<K, V> = [BSTNOptKey<K>, OptValue<V>];
12
11
  export type BSTNOptKeyOrNode<K, NODE> = BSTNOptKey<K> | NODE;
12
+ export type BSTNRep<K, V, NODE> = BSTNEntry<K, V> | BSTNOptKeyOrNode<K, NODE>;
@@ -3,5 +3,7 @@ export * from './bst';
3
3
  export * from './avl-tree';
4
4
  export * from './segment-tree';
5
5
  export * from './avl-tree-multi-map';
6
- export * from './rb-tree';
6
+ export * from './red-black-tree';
7
7
  export * from './tree-multi-map';
8
+ export * from './tree-counter';
9
+ export * from './avl-tree-counter';
@@ -19,5 +19,7 @@ __exportStar(require("./bst"), exports);
19
19
  __exportStar(require("./avl-tree"), exports);
20
20
  __exportStar(require("./segment-tree"), exports);
21
21
  __exportStar(require("./avl-tree-multi-map"), exports);
22
- __exportStar(require("./rb-tree"), exports);
22
+ __exportStar(require("./red-black-tree"), exports);
23
23
  __exportStar(require("./tree-multi-map"), exports);
24
+ __exportStar(require("./tree-counter"), exports);
25
+ __exportStar(require("./avl-tree-counter"), exports);
@@ -0,0 +1,3 @@
1
+ import type { BSTOptions } from './bst';
2
+ export type RBTNColor = 'RED' | 'BLACK';
3
+ export type RedBlackTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import type { RedBlackTreeOptions } from './red-black-tree';
2
+ export type TreeCounterOptions<K, V, R> = RedBlackTreeOptions<K, V, R> & {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,2 @@
1
- import { TreeMultiMap, TreeMultiMapNode } from '../../../data-structures';
2
- import type { RBTreeOptions } from './rb-tree';
3
- export type TreeMultiMapNodeNested<K, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
- export type TreeMultiMapNested<K, V, R, NODE extends TreeMultiMapNode<K, V, NODE>> = TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
- export type TreeMultiMapOptions<K, V, R> = RBTreeOptions<K, V, R> & {};
1
+ import type { RedBlackTreeOptions } from './red-black-tree';
2
+ export type TreeMultiMapOptions<K, V, R> = Omit<RedBlackTreeOptions<K, V, R>, 'isMapMode'> & {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "red-black-tree-typed",
3
- "version": "1.53.7",
3
+ "version": "1.54.2",
4
4
  "description": "RedBlackTree. Javascript & Typescript Data Structure.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -118,7 +118,7 @@
118
118
  "collection",
119
119
  "collections"
120
120
  ],
121
- "author": "Tyler Zeng zrwusa@gmail.com",
121
+ "author": "Pablo Zeng zrwusa@gmail.com",
122
122
  "license": "MIT",
123
123
  "bugs": {
124
124
  "url": "https://github.com/zrwusa/data-structure-typed/issues"
@@ -142,6 +142,6 @@
142
142
  "typescript": "^4.9.5"
143
143
  },
144
144
  "dependencies": {
145
- "data-structure-typed": "^1.53.7"
145
+ "data-structure-typed": "^1.54.2"
146
146
  }
147
147
  }
@@ -1,14 +1,20 @@
1
+ import { isComparable } from '../utils';
2
+
1
3
  export enum DFSOperation {
2
4
  VISIT = 0,
3
5
  PROCESS = 1
4
6
  }
7
+
5
8
  export class Range<K> {
6
9
  constructor(
7
10
  public low: K,
8
11
  public high: K,
9
12
  public includeLow: boolean = true,
10
13
  public includeHigh: boolean = true
11
- ) {}
14
+ ) {
15
+ if (!(isComparable(low) && isComparable(high))) throw new RangeError('low or high is not comparable');
16
+ if (low > high) throw new RangeError('low must be less than or equal to high');
17
+ }
12
18
 
13
19
  // Determine whether a key is within the range
14
20
  isInRange(key: K, comparator: (a: K, b: K) => number): boolean {
@@ -70,7 +70,7 @@ export abstract class IterableEntryBase<K = any, V = any> {
70
70
  every(predicate: EntryCallback<K, V, boolean>, thisArg?: any): boolean {
71
71
  let index = 0;
72
72
  for (const item of this) {
73
- if (!predicate.call(thisArg, item[1], item[0], index++, this)) {
73
+ if (!predicate.call(thisArg, item[0], item[1], index++, this)) {
74
74
  return false;
75
75
  }
76
76
  }
@@ -95,7 +95,7 @@ export abstract class IterableEntryBase<K = any, V = any> {
95
95
  some(predicate: EntryCallback<K, V, boolean>, thisArg?: any): boolean {
96
96
  let index = 0;
97
97
  for (const item of this) {
98
- if (predicate.call(thisArg, item[1], item[0], index++, this)) {
98
+ if (predicate.call(thisArg, item[0], item[1], index++, this)) {
99
99
  return true;
100
100
  }
101
101
  }
@@ -119,7 +119,7 @@ export abstract class IterableEntryBase<K = any, V = any> {
119
119
  let index = 0;
120
120
  for (const item of this) {
121
121
  const [key, value] = item;
122
- callbackfn.call(thisArg, value, key, index++, this);
122
+ callbackfn.call(thisArg, key, value, index++, this);
123
123
  }
124
124
  }
125
125
 
@@ -144,7 +144,7 @@ export abstract class IterableEntryBase<K = any, V = any> {
144
144
  let index = 0;
145
145
  for (const item of this) {
146
146
  const [key, value] = item;
147
- if (callbackfn.call(thisArg, value, key, index++, this)) return item;
147
+ if (callbackfn.call(thisArg, key, value, index++, this)) return item;
148
148
  }
149
149
  return;
150
150
  }