undirected-graph-typed 2.0.5 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-structures/base/iterable-element-base.d.ts +186 -83
- package/dist/data-structures/base/iterable-element-base.js +149 -107
- package/dist/data-structures/base/iterable-entry-base.d.ts +95 -119
- package/dist/data-structures/base/iterable-entry-base.js +59 -116
- package/dist/data-structures/base/linear-base.d.ts +250 -192
- package/dist/data-structures/base/linear-base.js +137 -274
- package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +126 -158
- package/dist/data-structures/binary-tree/avl-tree-counter.js +171 -205
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +100 -69
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +135 -87
- package/dist/data-structures/binary-tree/avl-tree.d.ts +138 -149
- package/dist/data-structures/binary-tree/avl-tree.js +208 -195
- package/dist/data-structures/binary-tree/binary-tree.d.ts +476 -632
- package/dist/data-structures/binary-tree/binary-tree.js +598 -869
- package/dist/data-structures/binary-tree/bst.d.ts +258 -306
- package/dist/data-structures/binary-tree/bst.js +505 -481
- package/dist/data-structures/binary-tree/red-black-tree.d.ts +107 -179
- package/dist/data-structures/binary-tree/red-black-tree.js +114 -209
- package/dist/data-structures/binary-tree/tree-counter.d.ts +132 -154
- package/dist/data-structures/binary-tree/tree-counter.js +172 -203
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +72 -69
- package/dist/data-structures/binary-tree/tree-multi-map.js +105 -85
- package/dist/data-structures/graph/abstract-graph.d.ts +238 -233
- package/dist/data-structures/graph/abstract-graph.js +267 -237
- package/dist/data-structures/graph/directed-graph.d.ts +108 -224
- package/dist/data-structures/graph/directed-graph.js +146 -233
- package/dist/data-structures/graph/map-graph.d.ts +49 -55
- package/dist/data-structures/graph/map-graph.js +56 -59
- package/dist/data-structures/graph/undirected-graph.d.ts +103 -146
- package/dist/data-structures/graph/undirected-graph.js +129 -149
- package/dist/data-structures/hash/hash-map.d.ts +164 -338
- package/dist/data-structures/hash/hash-map.js +270 -457
- package/dist/data-structures/heap/heap.d.ts +214 -289
- package/dist/data-structures/heap/heap.js +340 -349
- package/dist/data-structures/heap/max-heap.d.ts +11 -47
- package/dist/data-structures/heap/max-heap.js +11 -66
- package/dist/data-structures/heap/min-heap.d.ts +12 -47
- package/dist/data-structures/heap/min-heap.js +11 -66
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +231 -347
- package/dist/data-structures/linked-list/doubly-linked-list.js +368 -494
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +261 -310
- package/dist/data-structures/linked-list/singly-linked-list.js +447 -466
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +0 -107
- package/dist/data-structures/linked-list/skip-linked-list.js +0 -100
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -56
- package/dist/data-structures/priority-queue/max-priority-queue.js +11 -78
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +11 -57
- package/dist/data-structures/priority-queue/min-priority-queue.js +10 -79
- package/dist/data-structures/priority-queue/priority-queue.d.ts +2 -61
- package/dist/data-structures/priority-queue/priority-queue.js +8 -83
- package/dist/data-structures/queue/deque.d.ts +227 -254
- package/dist/data-structures/queue/deque.js +309 -348
- package/dist/data-structures/queue/queue.d.ts +180 -201
- package/dist/data-structures/queue/queue.js +265 -248
- package/dist/data-structures/stack/stack.d.ts +124 -102
- package/dist/data-structures/stack/stack.js +181 -125
- package/dist/data-structures/trie/trie.d.ts +164 -165
- package/dist/data-structures/trie/trie.js +189 -172
- package/dist/interfaces/binary-tree.d.ts +56 -6
- package/dist/interfaces/graph.d.ts +16 -0
- package/dist/types/data-structures/base/base.d.ts +1 -1
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.js +2 -1
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +238 -115
- package/src/data-structures/base/iterable-entry-base.ts +96 -120
- package/src/data-structures/base/linear-base.ts +271 -277
- package/src/data-structures/binary-tree/avl-tree-counter.ts +198 -216
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +192 -101
- package/src/data-structures/binary-tree/avl-tree.ts +239 -206
- package/src/data-structures/binary-tree/binary-tree.ts +664 -893
- package/src/data-structures/binary-tree/bst.ts +568 -570
- package/src/data-structures/binary-tree/red-black-tree.ts +161 -222
- package/src/data-structures/binary-tree/tree-counter.ts +199 -218
- package/src/data-structures/binary-tree/tree-multi-map.ts +131 -97
- package/src/data-structures/graph/abstract-graph.ts +339 -264
- package/src/data-structures/graph/directed-graph.ts +146 -236
- package/src/data-structures/graph/map-graph.ts +63 -60
- package/src/data-structures/graph/undirected-graph.ts +129 -152
- package/src/data-structures/hash/hash-map.ts +274 -496
- package/src/data-structures/heap/heap.ts +389 -402
- package/src/data-structures/heap/max-heap.ts +12 -76
- package/src/data-structures/heap/min-heap.ts +13 -76
- package/src/data-structures/linked-list/doubly-linked-list.ts +426 -530
- package/src/data-structures/linked-list/singly-linked-list.ts +495 -517
- package/src/data-structures/linked-list/skip-linked-list.ts +1 -108
- package/src/data-structures/priority-queue/max-priority-queue.ts +12 -87
- package/src/data-structures/priority-queue/min-priority-queue.ts +11 -88
- package/src/data-structures/priority-queue/priority-queue.ts +3 -92
- package/src/data-structures/queue/deque.ts +381 -357
- package/src/data-structures/queue/queue.ts +310 -264
- package/src/data-structures/stack/stack.ts +217 -131
- package/src/data-structures/trie/trie.ts +240 -175
- package/src/interfaces/binary-tree.ts +240 -6
- package/src/interfaces/graph.ts +37 -0
- package/src/types/data-structures/base/base.ts +5 -5
- package/src/types/data-structures/graph/abstract-graph.ts +5 -0
- package/src/types/utils/utils.ts +2 -0
- package/src/utils/utils.ts +9 -14
|
@@ -7,49 +7,64 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { ElementCallback, TrieOptions } from '../../types';
|
|
9
9
|
import { IterableElementBase } from '../base';
|
|
10
|
+
/**
|
|
11
|
+
* Node used by Trie to store one character and its children.
|
|
12
|
+
* @remarks Time O(1), Space O(1)
|
|
13
|
+
*/
|
|
10
14
|
export declare class TrieNode {
|
|
15
|
+
/**
|
|
16
|
+
* Create a Trie node with a character key.
|
|
17
|
+
* @remarks Time O(1), Space O(1)
|
|
18
|
+
* @returns New TrieNode instance.
|
|
19
|
+
*/
|
|
11
20
|
constructor(key: string);
|
|
12
21
|
protected _key: string;
|
|
13
22
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
23
|
+
* Get the character key of this node.
|
|
24
|
+
* @remarks Time O(1), Space O(1)
|
|
25
|
+
* @returns Character key string.
|
|
16
26
|
*/
|
|
17
27
|
get key(): string;
|
|
18
28
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
29
|
+
* Set the character key of this node.
|
|
30
|
+
* @remarks Time O(1), Space O(1)
|
|
31
|
+
* @param value - New character key.
|
|
32
|
+
* @returns void
|
|
22
33
|
*/
|
|
23
34
|
set key(value: string);
|
|
24
35
|
protected _children: Map<string, TrieNode>;
|
|
25
36
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @
|
|
28
|
-
*
|
|
37
|
+
* Get the child map of this node.
|
|
38
|
+
* @remarks Time O(1), Space O(1)
|
|
39
|
+
* @returns Map from character to child node.
|
|
29
40
|
*/
|
|
30
41
|
get children(): Map<string, TrieNode>;
|
|
31
42
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* current TrieNode.
|
|
43
|
+
* Replace the child map of this node.
|
|
44
|
+
* @remarks Time O(1), Space O(1)
|
|
45
|
+
* @param value - New map of character → node.
|
|
46
|
+
* @returns void
|
|
37
47
|
*/
|
|
38
48
|
set children(value: Map<string, TrieNode>);
|
|
39
49
|
protected _isEnd: boolean;
|
|
40
50
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @
|
|
51
|
+
* Check whether this node marks the end of a word.
|
|
52
|
+
* @remarks Time O(1), Space O(1)
|
|
53
|
+
* @returns True if this node ends a word.
|
|
43
54
|
*/
|
|
44
55
|
get isEnd(): boolean;
|
|
45
56
|
/**
|
|
46
|
-
*
|
|
47
|
-
* @
|
|
48
|
-
*
|
|
57
|
+
* Mark this node as the end of a word or not.
|
|
58
|
+
* @remarks Time O(1), Space O(1)
|
|
59
|
+
* @param value - Whether this node ends a word.
|
|
60
|
+
* @returns void
|
|
49
61
|
*/
|
|
50
62
|
set isEnd(value: boolean);
|
|
51
63
|
}
|
|
52
64
|
/**
|
|
65
|
+
* Prefix tree (Trie) for fast prefix queries and word storage.
|
|
66
|
+
* @remarks Time O(1), Space O(1)
|
|
67
|
+
* @template R
|
|
53
68
|
* 1. Node Structure: Each node in a Trie represents a string (or a part of a string). The root node typically represents an empty string.
|
|
54
69
|
* 2. Child Node Relationship: Each node's children represent the strings that can be formed by adding one character to the string at the current node. For example, if a node represents the string 'ca', one of its children might represent 'cat'.
|
|
55
70
|
* 3. Fast Retrieval: Trie allows retrieval in O(m) time complexity, where m is the length of the string to be searched.
|
|
@@ -145,207 +160,191 @@ export declare class TrieNode {
|
|
|
145
160
|
*/
|
|
146
161
|
export declare class Trie<R = any> extends IterableElementBase<string, R> {
|
|
147
162
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* @param
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
* value.
|
|
154
|
-
* @param [options] - The `options` parameter in the constructor is an optional object that can
|
|
155
|
-
* contain configuration options for the Trie data structure. One of the options it can have is
|
|
156
|
-
* `caseSensitive`, which is a boolean value indicating whether the Trie should be case-sensitive or
|
|
157
|
-
* not. If `caseSensitive` is set to `
|
|
163
|
+
* Create a Trie and optionally bulk-insert words.
|
|
164
|
+
* @remarks Time O(totalChars), Space O(totalChars)
|
|
165
|
+
* @param [words] - Iterable of strings (or raw records if toElementFn is provided).
|
|
166
|
+
* @param [options] - Options such as toElementFn and caseSensitive.
|
|
167
|
+
* @returns New Trie instance.
|
|
158
168
|
*/
|
|
159
169
|
constructor(words?: Iterable<string> | Iterable<R>, options?: TrieOptions<R>);
|
|
160
170
|
protected _size: number;
|
|
161
171
|
/**
|
|
162
|
-
*
|
|
163
|
-
* @
|
|
172
|
+
* Get the number of stored words.
|
|
173
|
+
* @remarks Time O(1), Space O(1)
|
|
174
|
+
* @returns Word count.
|
|
164
175
|
*/
|
|
165
176
|
get size(): number;
|
|
166
177
|
protected _caseSensitive: boolean;
|
|
167
178
|
/**
|
|
168
|
-
*
|
|
169
|
-
* @
|
|
179
|
+
* Get whether comparisons are case-sensitive.
|
|
180
|
+
* @remarks Time O(1), Space O(1)
|
|
181
|
+
* @returns True if case-sensitive.
|
|
170
182
|
*/
|
|
171
183
|
get caseSensitive(): boolean;
|
|
172
184
|
protected _root: TrieNode;
|
|
173
185
|
/**
|
|
174
|
-
*
|
|
175
|
-
* @
|
|
186
|
+
* Get the root node.
|
|
187
|
+
* @remarks Time O(1), Space O(1)
|
|
188
|
+
* @returns Root TrieNode.
|
|
176
189
|
*/
|
|
177
190
|
get root(): TrieNode;
|
|
178
191
|
/**
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
192
|
+
* (Protected) Get total count for base class iteration.
|
|
193
|
+
* @remarks Time O(1), Space O(1)
|
|
194
|
+
* @returns Total number of elements.
|
|
195
|
+
*/
|
|
196
|
+
protected get _total(): number;
|
|
197
|
+
/**
|
|
198
|
+
* Insert one word into the trie.
|
|
199
|
+
* @remarks Time O(L), Space O(L)
|
|
200
|
+
* @param word - Word to insert.
|
|
201
|
+
* @returns True if the word was newly added.
|
|
185
202
|
*/
|
|
186
203
|
add(word: string): boolean;
|
|
187
204
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
* them using a provided function if available, and adds them to a data structure while returning an
|
|
193
|
-
* array of boolean values indicating success.
|
|
194
|
-
* @param {Iterable<string> | Iterable<R>} words - The `words` parameter in the `addMany` function is
|
|
195
|
-
* an iterable that contains either strings or elements of type `R`.
|
|
196
|
-
* @returns The `addMany` method returns an array of boolean values indicating whether each word in
|
|
197
|
-
* the input iterable was successfully added to the data structure.
|
|
205
|
+
* Insert many words from an iterable.
|
|
206
|
+
* @remarks Time O(ΣL), Space O(ΣL)
|
|
207
|
+
* @param words - Iterable of strings (or raw records if toElementFn is provided).
|
|
208
|
+
* @returns Array of per-word 'added' flags.
|
|
198
209
|
*/
|
|
199
210
|
addMany(words: Iterable<string> | Iterable<R>): boolean[];
|
|
200
211
|
/**
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* @param {string} word - The word to check for.
|
|
206
|
-
* @returns {boolean} True if the word is present in the Trie.
|
|
212
|
+
* Check whether a word exists.
|
|
213
|
+
* @remarks Time O(L), Space O(1)
|
|
214
|
+
* @param word - Word to search for.
|
|
215
|
+
* @returns True if present.
|
|
207
216
|
*/
|
|
208
217
|
has(word: string): boolean;
|
|
209
218
|
/**
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
* The isEmpty function checks if the size of the queue is 0.
|
|
214
|
-
* @return True if the size of the queue is 0
|
|
219
|
+
* Check whether the trie is empty.
|
|
220
|
+
* @remarks Time O(1), Space O(1)
|
|
221
|
+
* @returns True if size is 0.
|
|
215
222
|
*/
|
|
216
223
|
isEmpty(): boolean;
|
|
217
224
|
/**
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
* The clear function resets the size of the Trie to 0 and creates a new root TrieNode.
|
|
225
|
+
* Remove all words and reset to a fresh root.
|
|
226
|
+
* @remarks Time O(1), Space O(1)
|
|
227
|
+
* @returns void
|
|
222
228
|
*/
|
|
223
229
|
clear(): void;
|
|
224
230
|
/**
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* @param{string} word - The word to delete.
|
|
230
|
-
* @returns {boolean} True if the word was successfully removed.
|
|
231
|
+
* Delete one word if present.
|
|
232
|
+
* @remarks Time O(L), Space O(1)
|
|
233
|
+
* @param word - Word to delete.
|
|
234
|
+
* @returns True if a word was removed.
|
|
231
235
|
*/
|
|
232
236
|
delete(word: string): boolean;
|
|
233
237
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
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.
|
|
238
|
+
* Compute the height (max depth) of the trie.
|
|
239
|
+
* @remarks Time O(N), Space O(H)
|
|
240
|
+
* @returns Maximum depth from root to a leaf.
|
|
242
241
|
*/
|
|
243
242
|
getHeight(): number;
|
|
244
243
|
/**
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* @param {string} input - The input string to check.
|
|
250
|
-
* @returns {boolean} True if it's an absolute prefix in the Trie.
|
|
244
|
+
* Check whether input is a proper prefix of at least one word.
|
|
245
|
+
* @remarks Time O(L), Space O(1)
|
|
246
|
+
* @param input - String to test as prefix.
|
|
247
|
+
* @returns True if input is a prefix but not a full word.
|
|
251
248
|
*/
|
|
252
249
|
hasPurePrefix(input: string): boolean;
|
|
253
250
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* @param {string} input - The input string representing the prefix to check.
|
|
259
|
-
* @returns {boolean} True if it's a prefix in the Trie.
|
|
251
|
+
* Check whether any word starts with input.
|
|
252
|
+
* @remarks Time O(L), Space O(1)
|
|
253
|
+
* @param input - String to test as prefix.
|
|
254
|
+
* @returns True if input matches a path from root.
|
|
260
255
|
*/
|
|
261
256
|
hasPrefix(input: string): boolean;
|
|
262
257
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
* @param {string} input - The input string representing the common prefix to check for.
|
|
268
|
-
* @returns {boolean} True if it's a common prefix in the Trie.
|
|
258
|
+
* Check whether the trie’s longest common prefix equals input.
|
|
259
|
+
* @remarks Time O(min(H,L)), Space O(1)
|
|
260
|
+
* @param input - Candidate longest common prefix.
|
|
261
|
+
* @returns True if input equals the common prefix.
|
|
269
262
|
*/
|
|
270
263
|
hasCommonPrefix(input: string): boolean;
|
|
271
264
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
* Get the longest common prefix among all the words stored in the Trie.
|
|
276
|
-
* @returns {string} The longest common prefix found in the Trie.
|
|
265
|
+
* Return the longest common prefix among all words.
|
|
266
|
+
* @remarks Time O(H), Space O(1)
|
|
267
|
+
* @returns The longest common prefix string.
|
|
277
268
|
*/
|
|
278
269
|
getLongestCommonPrefix(): string;
|
|
279
270
|
/**
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* @param
|
|
285
|
-
*
|
|
286
|
-
* @param {number} max - The max count of words will be found
|
|
287
|
-
* @param isAllWhenEmptyPrefix - If true, when the prefix provided as '', returns all the words in the trie.
|
|
288
|
-
* @returns {string[]} an array of strings.
|
|
271
|
+
* Collect words under a prefix up to a maximum count.
|
|
272
|
+
* @remarks Time O(K·L), Space O(K·L)
|
|
273
|
+
* @param [prefix] - Prefix to match; default empty string for root.
|
|
274
|
+
* @param [max] - Maximum number of words to return; default is Number.MAX_SAFE_INTEGER.
|
|
275
|
+
* @param [isAllWhenEmptyPrefix] - When true, collect from root even if prefix is empty.
|
|
276
|
+
* @returns Array of collected words (at most max).
|
|
289
277
|
*/
|
|
290
278
|
getWords(prefix?: string, max?: number, isAllWhenEmptyPrefix?: boolean): string[];
|
|
291
279
|
/**
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* @
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
* @
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
* @param
|
|
322
|
-
*
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
*
|
|
327
|
-
* @
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
|
|
280
|
+
* Deep clone this trie by iterating and inserting all words.
|
|
281
|
+
* @remarks Time O(ΣL), Space O(ΣL)
|
|
282
|
+
* @returns A new trie with the same words and options.
|
|
283
|
+
*/
|
|
284
|
+
clone(): this;
|
|
285
|
+
/**
|
|
286
|
+
* Filter words into a new trie of the same class.
|
|
287
|
+
* @remarks Time O(ΣL), Space O(ΣL)
|
|
288
|
+
* @param predicate - Predicate (word, index, trie) → boolean to keep word.
|
|
289
|
+
* @param [thisArg] - Value for `this` inside the predicate.
|
|
290
|
+
* @returns A new trie containing words that satisfy the predicate.
|
|
291
|
+
*/
|
|
292
|
+
filter(predicate: ElementCallback<string, R, boolean>, thisArg?: any): this;
|
|
293
|
+
map<RM>(callback: ElementCallback<string, R, string>, options?: TrieOptions<RM>, thisArg?: any): Trie<RM>;
|
|
294
|
+
/**
|
|
295
|
+
* Map words into a new trie (possibly different record type).
|
|
296
|
+
* @remarks Time O(ΣL), Space O(ΣL)
|
|
297
|
+
* @template EM
|
|
298
|
+
* @template RM
|
|
299
|
+
* @param callback - Mapping function (word, index, trie) → newWord (string).
|
|
300
|
+
* @param [options] - Options for the output trie (e.g., toElementFn, caseSensitive).
|
|
301
|
+
* @param [thisArg] - Value for `this` inside the callback.
|
|
302
|
+
* @returns A new Trie constructed from mapped words.
|
|
303
|
+
*/
|
|
304
|
+
map<EM, RM>(callback: ElementCallback<string, R, EM>, options?: TrieOptions<RM>, thisArg?: any): IterableElementBase<EM, RM>;
|
|
305
|
+
/**
|
|
306
|
+
* Map words into a new trie of the same element type.
|
|
307
|
+
* @remarks Time O(ΣL), Space O(ΣL)
|
|
308
|
+
* @param callback - Mapping function (word, index, trie) → string.
|
|
309
|
+
* @param [thisArg] - Value for `this` inside the callback.
|
|
310
|
+
* @returns A new trie with mapped words.
|
|
311
|
+
*/
|
|
312
|
+
mapSame(callback: ElementCallback<string, R, string>, thisArg?: any): this;
|
|
313
|
+
/**
|
|
314
|
+
* (Protected) Create an empty instance of the same concrete class.
|
|
315
|
+
* @remarks Time O(1), Space O(1)
|
|
316
|
+
* @param [options] - Options forwarded to the constructor.
|
|
317
|
+
* @returns An empty like-kind trie instance.
|
|
318
|
+
*/
|
|
319
|
+
protected _createInstance(options?: TrieOptions<R>): this;
|
|
320
|
+
/**
|
|
321
|
+
* (Protected) Create a like-kind trie and seed it from an iterable.
|
|
322
|
+
* @remarks Time O(ΣL), Space O(ΣL)
|
|
323
|
+
* @template RM
|
|
324
|
+
* @param [elements] - Iterable used to seed the new trie.
|
|
325
|
+
* @param [options] - Options forwarded to the constructor.
|
|
326
|
+
* @returns A like-kind Trie instance.
|
|
327
|
+
*/
|
|
328
|
+
protected _createLike<RM>(elements?: Iterable<string> | Iterable<RM>, options?: TrieOptions<RM>): Trie<RM>;
|
|
329
|
+
/**
|
|
330
|
+
* (Protected) Spawn an empty like-kind trie instance.
|
|
331
|
+
* @remarks Time O(1), Space O(1)
|
|
332
|
+
* @template RM
|
|
333
|
+
* @param [options] - Options forwarded to the constructor.
|
|
334
|
+
* @returns An empty like-kind Trie instance.
|
|
335
|
+
*/
|
|
336
|
+
protected _spawnLike<RM>(options?: TrieOptions<RM>): Trie<RM>;
|
|
337
|
+
/**
|
|
338
|
+
* (Protected) Iterate all words in lexicographic order of edges.
|
|
339
|
+
* @remarks Time O(ΣL), Space O(H)
|
|
340
|
+
* @returns Iterator of words.
|
|
340
341
|
*/
|
|
341
342
|
protected _getIterator(): IterableIterator<string>;
|
|
342
|
-
protected get _total(): number;
|
|
343
343
|
/**
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
* @
|
|
348
|
-
* @protected
|
|
344
|
+
* (Protected) Normalize a string according to case sensitivity.
|
|
345
|
+
* @remarks Time O(L), Space O(L)
|
|
346
|
+
* @param str - Input string to normalize.
|
|
347
|
+
* @returns Normalized string based on caseSensitive.
|
|
349
348
|
*/
|
|
350
349
|
protected _caseProcess(str: string): string;
|
|
351
350
|
}
|