data-structure-typed 1.48.1 → 1.48.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.
- package/CHANGELOG.md +1 -1
- package/README.md +24 -18
- package/benchmark/report.html +16 -16
- package/benchmark/report.json +172 -172
- package/dist/cjs/data-structures/base/index.d.ts +1 -0
- package/dist/cjs/data-structures/base/index.js +18 -0
- package/dist/cjs/data-structures/base/index.js.map +1 -0
- package/dist/cjs/data-structures/base/iterable-base.d.ts +232 -0
- package/dist/cjs/data-structures/base/iterable-base.js +313 -0
- package/dist/cjs/data-structures/base/iterable-base.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +16 -16
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +7 -7
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +121 -152
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +140 -182
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +28 -47
- package/dist/cjs/data-structures/binary-tree/bst.js +54 -57
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +15 -15
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +7 -7
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +22 -22
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js +11 -11
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +44 -6
- package/dist/cjs/data-structures/graph/abstract-graph.js +50 -27
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +59 -100
- package/dist/cjs/data-structures/hash/hash-map.js +69 -173
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.d.ts +50 -7
- package/dist/cjs/data-structures/heap/heap.js +60 -30
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/index.d.ts +1 -0
- package/dist/cjs/data-structures/index.js +1 -0
- package/dist/cjs/data-structures/index.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +38 -51
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +46 -73
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +32 -51
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +40 -73
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +29 -51
- package/dist/cjs/data-structures/queue/deque.js +36 -71
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +49 -48
- package/dist/cjs/data-structures/queue/queue.js +69 -82
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/stack/stack.d.ts +43 -10
- package/dist/cjs/data-structures/stack/stack.js +50 -31
- package/dist/cjs/data-structures/stack/stack.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.d.ts +41 -6
- package/dist/cjs/data-structures/trie/trie.js +53 -32
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/interfaces/binary-tree.d.ts +6 -6
- package/dist/cjs/types/common.d.ts +11 -8
- package/dist/cjs/types/common.js +6 -1
- package/dist/cjs/types/common.js.map +1 -1
- package/dist/cjs/types/data-structures/base/base.d.ts +5 -0
- package/dist/cjs/types/data-structures/base/base.js +3 -0
- package/dist/cjs/types/data-structures/base/base.js.map +1 -0
- package/dist/cjs/types/data-structures/base/index.d.ts +1 -0
- package/dist/cjs/types/data-structures/base/index.js +18 -0
- package/dist/cjs/types/data-structures/base/index.js.map +1 -0
- package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -3
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +4 -4
- package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +6 -6
- package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +3 -3
- package/dist/cjs/types/data-structures/binary-tree/tree-multimap.d.ts +3 -3
- package/dist/cjs/types/data-structures/index.d.ts +1 -0
- package/dist/cjs/types/data-structures/index.js +1 -0
- package/dist/cjs/types/data-structures/index.js.map +1 -1
- package/dist/mjs/data-structures/base/index.d.ts +1 -0
- package/dist/mjs/data-structures/base/index.js +1 -0
- package/dist/mjs/data-structures/base/iterable-base.d.ts +232 -0
- package/dist/mjs/data-structures/base/iterable-base.js +307 -0
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +16 -16
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +7 -7
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +121 -152
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +140 -182
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +28 -47
- package/dist/mjs/data-structures/binary-tree/bst.js +55 -57
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +15 -15
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +7 -7
- package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +22 -22
- package/dist/mjs/data-structures/binary-tree/tree-multimap.js +11 -11
- package/dist/mjs/data-structures/graph/abstract-graph.d.ts +44 -6
- package/dist/mjs/data-structures/graph/abstract-graph.js +52 -27
- package/dist/mjs/data-structures/hash/hash-map.d.ts +59 -100
- package/dist/mjs/data-structures/hash/hash-map.js +69 -173
- package/dist/mjs/data-structures/heap/heap.d.ts +50 -7
- package/dist/mjs/data-structures/heap/heap.js +60 -30
- package/dist/mjs/data-structures/index.d.ts +1 -0
- package/dist/mjs/data-structures/index.js +1 -0
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +38 -51
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +46 -73
- package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +32 -51
- package/dist/mjs/data-structures/linked-list/singly-linked-list.js +40 -73
- package/dist/mjs/data-structures/queue/deque.d.ts +29 -51
- package/dist/mjs/data-structures/queue/deque.js +36 -71
- package/dist/mjs/data-structures/queue/queue.d.ts +49 -48
- package/dist/mjs/data-structures/queue/queue.js +66 -79
- package/dist/mjs/data-structures/stack/stack.d.ts +43 -10
- package/dist/mjs/data-structures/stack/stack.js +50 -31
- package/dist/mjs/data-structures/trie/trie.d.ts +41 -6
- package/dist/mjs/data-structures/trie/trie.js +53 -32
- package/dist/mjs/interfaces/binary-tree.d.ts +6 -6
- package/dist/mjs/types/common.d.ts +11 -8
- package/dist/mjs/types/common.js +5 -0
- package/dist/mjs/types/data-structures/base/base.d.ts +5 -0
- package/dist/mjs/types/data-structures/base/base.js +1 -0
- package/dist/mjs/types/data-structures/base/index.d.ts +1 -0
- package/dist/mjs/types/data-structures/base/index.js +1 -0
- package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -3
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +4 -4
- package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +6 -6
- package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +3 -3
- package/dist/mjs/types/data-structures/binary-tree/tree-multimap.d.ts +3 -3
- package/dist/mjs/types/data-structures/index.d.ts +1 -0
- package/dist/mjs/types/data-structures/index.js +1 -0
- package/dist/umd/data-structure-typed.js +991 -848
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/index.ts +1 -0
- package/src/data-structures/base/iterable-base.ts +329 -0
- package/src/data-structures/binary-tree/avl-tree.ts +20 -21
- package/src/data-structures/binary-tree/binary-tree.ts +222 -267
- package/src/data-structures/binary-tree/bst.ts +86 -82
- package/src/data-structures/binary-tree/rb-tree.ts +25 -26
- package/src/data-structures/binary-tree/tree-multimap.ts +30 -35
- package/src/data-structures/graph/abstract-graph.ts +55 -28
- package/src/data-structures/hash/hash-map.ts +76 -185
- package/src/data-structures/heap/heap.ts +63 -36
- package/src/data-structures/index.ts +1 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +50 -79
- package/src/data-structures/linked-list/singly-linked-list.ts +45 -80
- package/src/data-structures/queue/deque.ts +40 -82
- package/src/data-structures/queue/queue.ts +72 -87
- package/src/data-structures/stack/stack.ts +53 -34
- package/src/data-structures/trie/trie.ts +58 -35
- package/src/interfaces/binary-tree.ts +5 -6
- package/src/types/common.ts +11 -8
- package/src/types/data-structures/base/base.ts +6 -0
- package/src/types/data-structures/base/index.ts +1 -0
- package/src/types/data-structures/binary-tree/avl-tree.ts +3 -3
- package/src/types/data-structures/binary-tree/binary-tree.ts +6 -5
- package/src/types/data-structures/binary-tree/bst.ts +6 -6
- package/src/types/data-structures/binary-tree/rb-tree.ts +3 -3
- package/src/types/data-structures/binary-tree/tree-multimap.ts +3 -3
- package/src/types/data-structures/index.ts +1 -0
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +13 -13
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +16 -16
- package/test/unit/data-structures/binary-tree/bst.test.ts +20 -19
- package/test/unit/data-structures/binary-tree/overall.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +9 -9
- package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +15 -15
- package/test/unit/data-structures/graph/directed-graph.test.ts +4 -4
- package/test/unit/data-structures/hash/hash-map.test.ts +2 -2
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +28 -0
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +25 -0
- package/test/unit/data-structures/queue/deque.test.ts +25 -0
- package/test/unit/unrestricted-interconversion.test.ts +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { IterableElementBase } from "../base";
|
|
2
|
+
import { ElementCallback } from "../../types";
|
|
1
3
|
/**
|
|
2
4
|
* @license MIT
|
|
3
5
|
* @copyright Tyler Zeng <zrwusa@gmail.com>
|
|
4
6
|
* @class
|
|
5
7
|
*/
|
|
6
|
-
export declare class Stack<E = any> {
|
|
8
|
+
export declare class Stack<E = any> extends IterableElementBase<E> {
|
|
7
9
|
/**
|
|
8
10
|
* The constructor initializes an array of elements, which can be provided as an optional parameter.
|
|
9
11
|
* @param {E[]} [elements] - The `elements` parameter is an optional parameter of type `E[]`, which represents an array
|
|
@@ -104,17 +106,48 @@ export declare class Stack<E = any> {
|
|
|
104
106
|
*/
|
|
105
107
|
clone(): Stack<E>;
|
|
106
108
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
+
* Time Complexity: O(n)
|
|
110
|
+
* Space Complexity: O(n)
|
|
109
111
|
*/
|
|
110
|
-
[Symbol.iterator](): Generator<E, void, unknown>;
|
|
111
112
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
113
|
+
* Time Complexity: O(n)
|
|
114
|
+
* Space Complexity: O(n)
|
|
115
|
+
*
|
|
116
|
+
* The `filter` function creates a new stack containing elements from the original stack that satisfy
|
|
117
|
+
* a given predicate function.
|
|
118
|
+
* @param predicate - The `predicate` parameter is a callback function that takes three arguments:
|
|
119
|
+
* the current element being iterated over, the index of the current element, and the stack itself.
|
|
120
|
+
* It should return a boolean value indicating whether the element should be included in the filtered
|
|
121
|
+
* stack or not.
|
|
122
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
123
|
+
* to be used as `this` when executing the `predicate` function. If `thisArg` is provided, it will be
|
|
124
|
+
* passed as the `this` value to the `predicate` function. If `thisArg` is
|
|
125
|
+
* @returns The `filter` method is returning a new `Stack` object that contains the elements that
|
|
126
|
+
* satisfy the given predicate function.
|
|
127
|
+
*/
|
|
128
|
+
filter(predicate: ElementCallback<E, boolean>, thisArg?: any): Stack<E>;
|
|
129
|
+
/**
|
|
130
|
+
* Time Complexity: O(n)
|
|
131
|
+
* Space Complexity: O(n)
|
|
114
132
|
*/
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Time Complexity: O(n)
|
|
135
|
+
* Space Complexity: O(n)
|
|
136
|
+
*
|
|
137
|
+
* The `map` function takes a callback function and applies it to each element in the stack,
|
|
138
|
+
* returning a new stack with the results.
|
|
139
|
+
* @param callback - The `callback` parameter is a function that will be called for each element in
|
|
140
|
+
* the stack. It takes three arguments:
|
|
141
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
142
|
+
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
|
|
143
|
+
* passed as the `this` value to the `callback` function. If `thisArg` is
|
|
144
|
+
* @returns The `map` method is returning a new `Stack` object.
|
|
145
|
+
*/
|
|
146
|
+
map<T>(callback: ElementCallback<E, T>, thisArg?: any): Stack<T>;
|
|
119
147
|
print(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Custom iterator for the Stack class.
|
|
150
|
+
* @returns An iterator object.
|
|
151
|
+
*/
|
|
152
|
+
protected _getIterator(): Generator<E, void, unknown>;
|
|
120
153
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { IterableElementBase } from "../base";
|
|
1
2
|
/**
|
|
2
3
|
* @license MIT
|
|
3
4
|
* @copyright Tyler Zeng <zrwusa@gmail.com>
|
|
4
5
|
* @class
|
|
5
6
|
*/
|
|
6
|
-
export class Stack {
|
|
7
|
+
export class Stack extends IterableElementBase {
|
|
7
8
|
/**
|
|
8
9
|
* The constructor initializes an array of elements, which can be provided as an optional parameter.
|
|
9
10
|
* @param {E[]} [elements] - The `elements` parameter is an optional parameter of type `E[]`, which represents an array
|
|
@@ -11,6 +12,7 @@ export class Stack {
|
|
|
11
12
|
* is provided and is an array, it is assigned to the `_elements
|
|
12
13
|
*/
|
|
13
14
|
constructor(elements) {
|
|
15
|
+
super();
|
|
14
16
|
this._elements = [];
|
|
15
17
|
if (elements) {
|
|
16
18
|
for (const el of elements) {
|
|
@@ -136,55 +138,72 @@ export class Stack {
|
|
|
136
138
|
return new Stack(this.elements.slice());
|
|
137
139
|
}
|
|
138
140
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
+
* Time Complexity: O(n)
|
|
142
|
+
* Space Complexity: O(n)
|
|
141
143
|
*/
|
|
142
|
-
*[Symbol.iterator]() {
|
|
143
|
-
for (let i = 0; i < this.elements.length; i++) {
|
|
144
|
-
yield this.elements[i];
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
144
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
145
|
+
* Time Complexity: O(n)
|
|
146
|
+
* Space Complexity: O(n)
|
|
147
|
+
*
|
|
148
|
+
* The `filter` function creates a new stack containing elements from the original stack that satisfy
|
|
149
|
+
* a given predicate function.
|
|
150
|
+
* @param predicate - The `predicate` parameter is a callback function that takes three arguments:
|
|
151
|
+
* the current element being iterated over, the index of the current element, and the stack itself.
|
|
152
|
+
* It should return a boolean value indicating whether the element should be included in the filtered
|
|
153
|
+
* stack or not.
|
|
154
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
155
|
+
* to be used as `this` when executing the `predicate` function. If `thisArg` is provided, it will be
|
|
156
|
+
* passed as the `this` value to the `predicate` function. If `thisArg` is
|
|
157
|
+
* @returns The `filter` method is returning a new `Stack` object that contains the elements that
|
|
158
|
+
* satisfy the given predicate function.
|
|
159
|
+
*/
|
|
160
|
+
filter(predicate, thisArg) {
|
|
159
161
|
const newStack = new Stack();
|
|
160
162
|
let index = 0;
|
|
161
163
|
for (const el of this) {
|
|
162
|
-
if (predicate(el, index, this)) {
|
|
164
|
+
if (predicate.call(thisArg, el, index, this)) {
|
|
163
165
|
newStack.push(el);
|
|
164
166
|
}
|
|
165
167
|
index++;
|
|
166
168
|
}
|
|
167
169
|
return newStack;
|
|
168
170
|
}
|
|
169
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Time Complexity: O(n)
|
|
173
|
+
* Space Complexity: O(n)
|
|
174
|
+
*/
|
|
175
|
+
/**
|
|
176
|
+
* Time Complexity: O(n)
|
|
177
|
+
* Space Complexity: O(n)
|
|
178
|
+
*
|
|
179
|
+
* The `map` function takes a callback function and applies it to each element in the stack,
|
|
180
|
+
* returning a new stack with the results.
|
|
181
|
+
* @param callback - The `callback` parameter is a function that will be called for each element in
|
|
182
|
+
* the stack. It takes three arguments:
|
|
183
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
184
|
+
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
|
|
185
|
+
* passed as the `this` value to the `callback` function. If `thisArg` is
|
|
186
|
+
* @returns The `map` method is returning a new `Stack` object.
|
|
187
|
+
*/
|
|
188
|
+
map(callback, thisArg) {
|
|
170
189
|
const newStack = new Stack();
|
|
171
190
|
let index = 0;
|
|
172
191
|
for (const el of this) {
|
|
173
|
-
newStack.push(callback(el, index, this));
|
|
192
|
+
newStack.push(callback.call(thisArg, el, index, this));
|
|
174
193
|
index++;
|
|
175
194
|
}
|
|
176
195
|
return newStack;
|
|
177
196
|
}
|
|
178
|
-
reduce(callback, initialValue) {
|
|
179
|
-
let accumulator = initialValue;
|
|
180
|
-
let index = 0;
|
|
181
|
-
for (const el of this) {
|
|
182
|
-
accumulator = callback(accumulator, el, index, this);
|
|
183
|
-
index++;
|
|
184
|
-
}
|
|
185
|
-
return accumulator;
|
|
186
|
-
}
|
|
187
197
|
print() {
|
|
188
198
|
console.log([...this]);
|
|
189
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Custom iterator for the Stack class.
|
|
202
|
+
* @returns An iterator object.
|
|
203
|
+
*/
|
|
204
|
+
*_getIterator() {
|
|
205
|
+
for (let i = 0; i < this.elements.length; i++) {
|
|
206
|
+
yield this.elements[i];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
190
209
|
}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
+
import { IterableElementBase } from "../base";
|
|
9
|
+
import { ElementCallback } from "../../types";
|
|
8
10
|
/**
|
|
9
11
|
* TrieNode represents a node in the Trie data structure. It holds a character key, a map of children nodes,
|
|
10
12
|
* and a flag indicating whether it's the end of a word.
|
|
@@ -18,7 +20,7 @@ export declare class TrieNode {
|
|
|
18
20
|
/**
|
|
19
21
|
* Trie represents a Trie data structure. It provides basic Trie operations and additional methods.
|
|
20
22
|
*/
|
|
21
|
-
export declare class Trie {
|
|
23
|
+
export declare class Trie extends IterableElementBase<string> {
|
|
22
24
|
constructor(words?: string[], caseSensitive?: boolean);
|
|
23
25
|
protected _size: number;
|
|
24
26
|
get size(): number;
|
|
@@ -142,12 +144,45 @@ export declare class Trie {
|
|
|
142
144
|
* @returns {string[]} an array of strings.
|
|
143
145
|
*/
|
|
144
146
|
getWords(prefix?: string, max?: number, isAllWhenEmptyPrefix?: boolean): string[];
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Time Complexity: O(n)
|
|
149
|
+
* Space Complexity: O(n)
|
|
150
|
+
*/
|
|
151
|
+
/**
|
|
152
|
+
* Time Complexity: O(n)
|
|
153
|
+
* Space Complexity: O(n)
|
|
154
|
+
*
|
|
155
|
+
* The `filter` function takes a predicate function and returns a new array containing all the
|
|
156
|
+
* elements for which the predicate function returns true.
|
|
157
|
+
* @param predicate - The `predicate` parameter is a callback function that takes three arguments:
|
|
158
|
+
* `word`, `index`, and `this`. It should return a boolean value indicating whether the current
|
|
159
|
+
* element should be included in the filtered results or not.
|
|
160
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
|
|
161
|
+
* specify the value of `this` within the `predicate` function. It is used when you want to bind a
|
|
162
|
+
* specific object as the context for the `predicate` function. If `thisArg` is provided, it will be
|
|
163
|
+
* @returns The `filter` method is returning an array of strings (`string[]`).
|
|
164
|
+
*/
|
|
165
|
+
filter(predicate: ElementCallback<string, boolean>, thisArg?: any): string[];
|
|
166
|
+
/**
|
|
167
|
+
* Time Complexity: O(n)
|
|
168
|
+
* Space Complexity: O(n)
|
|
169
|
+
*/
|
|
170
|
+
/**
|
|
171
|
+
* Time Complexity: O(n)
|
|
172
|
+
* Space Complexity: O(n)
|
|
173
|
+
*
|
|
174
|
+
* The `map` function creates a new Trie by applying a callback function to each element in the Trie.
|
|
175
|
+
* @param callback - The callback parameter is a function that will be called for each element in the
|
|
176
|
+
* Trie. It takes three arguments: the current element in the Trie, the index of the current element,
|
|
177
|
+
* and the Trie itself. The callback function should return a new value for the element.
|
|
178
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
179
|
+
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
|
|
180
|
+
* passed as the `this` value to the `callback` function. If `thisArg` is
|
|
181
|
+
* @returns The `map` function is returning a new Trie object.
|
|
182
|
+
*/
|
|
183
|
+
map(callback: ElementCallback<string, string>, thisArg?: any): Trie;
|
|
150
184
|
print(): void;
|
|
185
|
+
protected _getIterator(): IterableIterator<string>;
|
|
151
186
|
/**
|
|
152
187
|
* Time Complexity: O(M), where M is the length of the input string.
|
|
153
188
|
* Space Complexity: O(1) - Constant space.
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
+
import { IterableElementBase } from "../base";
|
|
8
9
|
/**
|
|
9
10
|
* TrieNode represents a node in the Trie data structure. It holds a character key, a map of children nodes,
|
|
10
11
|
* and a flag indicating whether it's the end of a word.
|
|
@@ -22,8 +23,9 @@ export class TrieNode {
|
|
|
22
23
|
/**
|
|
23
24
|
* Trie represents a Trie data structure. It provides basic Trie operations and additional methods.
|
|
24
25
|
*/
|
|
25
|
-
export class Trie {
|
|
26
|
+
export class Trie extends IterableElementBase {
|
|
26
27
|
constructor(words, caseSensitive = true) {
|
|
28
|
+
super();
|
|
27
29
|
this._root = new TrieNode('');
|
|
28
30
|
this._caseSensitive = caseSensitive;
|
|
29
31
|
this._size = 0;
|
|
@@ -319,56 +321,75 @@ export class Trie {
|
|
|
319
321
|
dfs(startNode, prefix);
|
|
320
322
|
return words;
|
|
321
323
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
filter(predicate) {
|
|
324
|
+
/**
|
|
325
|
+
* Time Complexity: O(n)
|
|
326
|
+
* Space Complexity: O(n)
|
|
327
|
+
*/
|
|
328
|
+
/**
|
|
329
|
+
* Time Complexity: O(n)
|
|
330
|
+
* Space Complexity: O(n)
|
|
331
|
+
*
|
|
332
|
+
* The `filter` function takes a predicate function and returns a new array containing all the
|
|
333
|
+
* elements for which the predicate function returns true.
|
|
334
|
+
* @param predicate - The `predicate` parameter is a callback function that takes three arguments:
|
|
335
|
+
* `word`, `index`, and `this`. It should return a boolean value indicating whether the current
|
|
336
|
+
* element should be included in the filtered results or not.
|
|
337
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
|
|
338
|
+
* specify the value of `this` within the `predicate` function. It is used when you want to bind a
|
|
339
|
+
* specific object as the context for the `predicate` function. If `thisArg` is provided, it will be
|
|
340
|
+
* @returns The `filter` method is returning an array of strings (`string[]`).
|
|
341
|
+
*/
|
|
342
|
+
filter(predicate, thisArg) {
|
|
341
343
|
const results = [];
|
|
342
344
|
let index = 0;
|
|
343
345
|
for (const word of this) {
|
|
344
|
-
if (predicate(word, index, this)) {
|
|
346
|
+
if (predicate.call(thisArg, word, index, this)) {
|
|
345
347
|
results.push(word);
|
|
346
348
|
}
|
|
347
349
|
index++;
|
|
348
350
|
}
|
|
349
351
|
return results;
|
|
350
352
|
}
|
|
351
|
-
|
|
353
|
+
/**
|
|
354
|
+
* Time Complexity: O(n)
|
|
355
|
+
* Space Complexity: O(n)
|
|
356
|
+
*/
|
|
357
|
+
/**
|
|
358
|
+
* Time Complexity: O(n)
|
|
359
|
+
* Space Complexity: O(n)
|
|
360
|
+
*
|
|
361
|
+
* The `map` function creates a new Trie by applying a callback function to each element in the Trie.
|
|
362
|
+
* @param callback - The callback parameter is a function that will be called for each element in the
|
|
363
|
+
* Trie. It takes three arguments: the current element in the Trie, the index of the current element,
|
|
364
|
+
* and the Trie itself. The callback function should return a new value for the element.
|
|
365
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
366
|
+
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
|
|
367
|
+
* passed as the `this` value to the `callback` function. If `thisArg` is
|
|
368
|
+
* @returns The `map` function is returning a new Trie object.
|
|
369
|
+
*/
|
|
370
|
+
map(callback, thisArg) {
|
|
352
371
|
const newTrie = new Trie();
|
|
353
372
|
let index = 0;
|
|
354
373
|
for (const word of this) {
|
|
355
|
-
newTrie.add(callback(word, index, this));
|
|
374
|
+
newTrie.add(callback.call(thisArg, word, index, this));
|
|
356
375
|
index++;
|
|
357
376
|
}
|
|
358
377
|
return newTrie;
|
|
359
378
|
}
|
|
360
|
-
reduce(callback, initialValue) {
|
|
361
|
-
let accumulator = initialValue;
|
|
362
|
-
let index = 0;
|
|
363
|
-
for (const word of this) {
|
|
364
|
-
accumulator = callback(accumulator, word, index, this);
|
|
365
|
-
index++;
|
|
366
|
-
}
|
|
367
|
-
return accumulator;
|
|
368
|
-
}
|
|
369
379
|
print() {
|
|
370
380
|
console.log([...this]);
|
|
371
381
|
}
|
|
382
|
+
*_getIterator() {
|
|
383
|
+
function* _dfs(node, path) {
|
|
384
|
+
if (node.isEnd) {
|
|
385
|
+
yield path;
|
|
386
|
+
}
|
|
387
|
+
for (const [char, childNode] of node.children) {
|
|
388
|
+
yield* _dfs(childNode, path + char);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
yield* _dfs(this.root, '');
|
|
392
|
+
}
|
|
372
393
|
/**
|
|
373
394
|
* Time Complexity: O(M), where M is the length of the input string.
|
|
374
395
|
* Space Complexity: O(1) - Constant space.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BinaryTree, BinaryTreeNode } from '../data-structures';
|
|
2
|
-
import { BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BiTreeDeleteResult, BTNCallback,
|
|
3
|
-
export interface IBinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNodeNested<V>, TREE extends BinaryTree<V, N, TREE> = BinaryTreeNested<V, N>> {
|
|
4
|
-
createNode(key:
|
|
5
|
-
createTree(options?: Partial<BinaryTreeOptions
|
|
6
|
-
add(keyOrNodeOrEntry: BTNodeExemplar<V, N>, count?: number): N | null | undefined;
|
|
7
|
-
addMany(nodes: Iterable<BTNodeExemplar<V, N>>): (N | null | undefined)[];
|
|
2
|
+
import { BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BiTreeDeleteResult, BTNCallback, BTNodeExemplar } from '../types';
|
|
3
|
+
export interface IBinaryTree<K = number, V = any, N extends BinaryTreeNode<K, V, N> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, N, TREE> = BinaryTreeNested<K, V, N>> {
|
|
4
|
+
createNode(key: K, value?: N['value']): N;
|
|
5
|
+
createTree(options?: Partial<BinaryTreeOptions<K>>): TREE;
|
|
6
|
+
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, count?: number): N | null | undefined;
|
|
7
|
+
addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>): (N | null | undefined)[];
|
|
8
8
|
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BiTreeDeleteResult<N>[];
|
|
9
9
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
export type Comparator<K> = (a: K, b: K) => number;
|
|
2
|
+
export declare enum BSTVariant {
|
|
3
|
+
MIN = "MIN",
|
|
4
|
+
MAX = "MAX"
|
|
5
|
+
}
|
|
3
6
|
export type DFSOrderPattern = 'pre' | 'in' | 'post';
|
|
4
7
|
export type BTNCallback<N, D = any> = (node: N) => D;
|
|
5
8
|
export declare enum CP {
|
|
@@ -19,9 +22,9 @@ export type BinaryTreePrintOptions = {
|
|
|
19
22
|
isShowNull?: boolean;
|
|
20
23
|
isShowRedBlackNIL?: boolean;
|
|
21
24
|
};
|
|
22
|
-
export type BTNodeEntry<
|
|
23
|
-
export type BTNodeKeyOrNode<N> =
|
|
24
|
-
export type BTNodeExemplar<
|
|
25
|
-
export type BTNodePureExemplar<
|
|
26
|
-
export type BTNodePureKeyOrNode<N> =
|
|
27
|
-
export type BSTNodeKeyOrNode<N> =
|
|
25
|
+
export type BTNodeEntry<K, V> = [K | null | undefined, V | undefined];
|
|
26
|
+
export type BTNodeKeyOrNode<K, N> = K | null | undefined | N;
|
|
27
|
+
export type BTNodeExemplar<K, V, N> = BTNodeEntry<K, V> | BTNodeKeyOrNode<K, N>;
|
|
28
|
+
export type BTNodePureExemplar<K, V, N> = [K, V | undefined] | BTNodePureKeyOrNode<K, N>;
|
|
29
|
+
export type BTNodePureKeyOrNode<K, N> = K | N;
|
|
30
|
+
export type BSTNodeKeyOrNode<K, N> = K | undefined | N;
|
package/dist/mjs/types/common.js
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IterableElementBase, IterablePairBase } from "../../../data-structures";
|
|
2
|
+
export type PairCallback<K, V, R> = (value: V, key: K, index: number, container: IterablePairBase<K, V>) => R;
|
|
3
|
+
export type ElementCallback<V, R> = (element: V, index: number, container: IterableElementBase<V>) => R;
|
|
4
|
+
export type ReducePairCallback<K, V, R> = (accumulator: R, value: V, key: K, index: number, container: IterablePairBase<K, V>) => R;
|
|
5
|
+
export type ReduceElementCallback<V, R> = (accumulator: R, element: V, index: number, container: IterableElementBase<V>) => R;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './base';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './base';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AVLTree, AVLTreeNode } from '../../../data-structures';
|
|
2
2
|
import { BSTOptions } from './bst';
|
|
3
|
-
export type AVLTreeNodeNested<
|
|
4
|
-
export type AVLTreeNested<
|
|
5
|
-
export type AVLTreeOptions = BSTOptions & {};
|
|
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, N extends AVLTreeNode<K, V, N>> = AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
5
|
+
export type AVLTreeOptions<K> = BSTOptions<K> & {};
|
|
@@ -18,14 +18,14 @@ export declare enum FamilyPosition {
|
|
|
18
18
|
ISOLATED = "ISOLATED",
|
|
19
19
|
MAL_NODE = "MAL_NODE"
|
|
20
20
|
}
|
|
21
|
-
export type BTNKey = number;
|
|
22
21
|
export type BiTreeDeleteResult<N> = {
|
|
23
22
|
deleted: N | null | undefined;
|
|
24
23
|
needBalanced: N | null | undefined;
|
|
25
24
|
};
|
|
26
|
-
export type BinaryTreeNodeNested<
|
|
27
|
-
export type BinaryTreeNested<
|
|
28
|
-
export type BinaryTreeOptions = {
|
|
25
|
+
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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
26
|
+
export type BinaryTreeNested<K, V, N extends BinaryTreeNode<K, V, N>> = BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
27
|
+
export type BinaryTreeOptions<K> = {
|
|
29
28
|
iterationType: IterationType;
|
|
29
|
+
extractor: (key: K) => number;
|
|
30
30
|
};
|
|
31
31
|
export type NodeDisplayLayout = [string[], number, number, number];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BST, BSTNode } from '../../../data-structures';
|
|
2
|
-
import type { BinaryTreeOptions
|
|
3
|
-
import {
|
|
4
|
-
export type BSTNodeNested<
|
|
5
|
-
export type BSTNested<
|
|
6
|
-
export type BSTOptions = BinaryTreeOptions & {
|
|
7
|
-
|
|
2
|
+
import type { BinaryTreeOptions } from './binary-tree';
|
|
3
|
+
import { BSTVariant } from "../../common";
|
|
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, N extends BSTNode<K, V, N>> = BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
6
|
+
export type BSTOptions<K> = BinaryTreeOptions<K> & {
|
|
7
|
+
variant: BSTVariant;
|
|
8
8
|
};
|
|
@@ -4,6 +4,6 @@ export declare enum RBTNColor {
|
|
|
4
4
|
RED = 1,
|
|
5
5
|
BLACK = 0
|
|
6
6
|
}
|
|
7
|
-
export type RedBlackTreeNodeNested<
|
|
8
|
-
export type RedBlackTreeNested<
|
|
9
|
-
export type RBTreeOptions = BSTOptions & {};
|
|
7
|
+
export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
8
|
+
export type RedBlackTreeNested<K, V, N extends RedBlackTreeNode<K, V, N>> = RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
9
|
+
export type RBTreeOptions<K> = BSTOptions<K> & {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TreeMultimap, TreeMultimapNode } from '../../../data-structures';
|
|
2
2
|
import { AVLTreeOptions } from './avl-tree';
|
|
3
|
-
export type TreeMultimapNodeNested<
|
|
4
|
-
export type TreeMultimapNested<
|
|
5
|
-
export type TreeMultimapOptions = Omit<AVLTreeOptions
|
|
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, N extends TreeMultimapNode<K, V, N>> = TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
5
|
+
export type TreeMultimapOptions<K> = Omit<AVLTreeOptions<K>, 'isMergeDuplicatedNodeByKey'> & {};
|