stack-typed 2.0.4 → 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.
Files changed (101) hide show
  1. package/dist/data-structures/base/iterable-element-base.d.ts +186 -83
  2. package/dist/data-structures/base/iterable-element-base.js +149 -107
  3. package/dist/data-structures/base/iterable-entry-base.d.ts +95 -119
  4. package/dist/data-structures/base/iterable-entry-base.js +59 -116
  5. package/dist/data-structures/base/linear-base.d.ts +250 -192
  6. package/dist/data-structures/base/linear-base.js +137 -274
  7. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +126 -158
  8. package/dist/data-structures/binary-tree/avl-tree-counter.js +171 -205
  9. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +100 -69
  10. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +135 -87
  11. package/dist/data-structures/binary-tree/avl-tree.d.ts +138 -149
  12. package/dist/data-structures/binary-tree/avl-tree.js +208 -195
  13. package/dist/data-structures/binary-tree/binary-tree.d.ts +476 -632
  14. package/dist/data-structures/binary-tree/binary-tree.js +612 -879
  15. package/dist/data-structures/binary-tree/bst.d.ts +258 -306
  16. package/dist/data-structures/binary-tree/bst.js +505 -481
  17. package/dist/data-structures/binary-tree/red-black-tree.d.ts +107 -179
  18. package/dist/data-structures/binary-tree/red-black-tree.js +114 -209
  19. package/dist/data-structures/binary-tree/tree-counter.d.ts +132 -154
  20. package/dist/data-structures/binary-tree/tree-counter.js +172 -203
  21. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +72 -69
  22. package/dist/data-structures/binary-tree/tree-multi-map.js +105 -85
  23. package/dist/data-structures/graph/abstract-graph.d.ts +238 -233
  24. package/dist/data-structures/graph/abstract-graph.js +267 -237
  25. package/dist/data-structures/graph/directed-graph.d.ts +108 -224
  26. package/dist/data-structures/graph/directed-graph.js +146 -233
  27. package/dist/data-structures/graph/map-graph.d.ts +49 -55
  28. package/dist/data-structures/graph/map-graph.js +56 -59
  29. package/dist/data-structures/graph/undirected-graph.d.ts +103 -146
  30. package/dist/data-structures/graph/undirected-graph.js +129 -149
  31. package/dist/data-structures/hash/hash-map.d.ts +164 -338
  32. package/dist/data-structures/hash/hash-map.js +270 -457
  33. package/dist/data-structures/heap/heap.d.ts +214 -289
  34. package/dist/data-structures/heap/heap.js +340 -349
  35. package/dist/data-structures/heap/max-heap.d.ts +11 -47
  36. package/dist/data-structures/heap/max-heap.js +11 -66
  37. package/dist/data-structures/heap/min-heap.d.ts +12 -47
  38. package/dist/data-structures/heap/min-heap.js +11 -66
  39. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +231 -347
  40. package/dist/data-structures/linked-list/doubly-linked-list.js +368 -494
  41. package/dist/data-structures/linked-list/singly-linked-list.d.ts +261 -310
  42. package/dist/data-structures/linked-list/singly-linked-list.js +447 -466
  43. package/dist/data-structures/linked-list/skip-linked-list.d.ts +0 -107
  44. package/dist/data-structures/linked-list/skip-linked-list.js +0 -100
  45. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -56
  46. package/dist/data-structures/priority-queue/max-priority-queue.js +11 -78
  47. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +11 -57
  48. package/dist/data-structures/priority-queue/min-priority-queue.js +10 -79
  49. package/dist/data-structures/priority-queue/priority-queue.d.ts +2 -61
  50. package/dist/data-structures/priority-queue/priority-queue.js +8 -83
  51. package/dist/data-structures/queue/deque.d.ts +227 -254
  52. package/dist/data-structures/queue/deque.js +309 -348
  53. package/dist/data-structures/queue/queue.d.ts +180 -201
  54. package/dist/data-structures/queue/queue.js +265 -248
  55. package/dist/data-structures/stack/stack.d.ts +124 -102
  56. package/dist/data-structures/stack/stack.js +181 -125
  57. package/dist/data-structures/trie/trie.d.ts +164 -165
  58. package/dist/data-structures/trie/trie.js +189 -172
  59. package/dist/interfaces/binary-tree.d.ts +56 -6
  60. package/dist/interfaces/graph.d.ts +16 -0
  61. package/dist/types/data-structures/base/base.d.ts +1 -1
  62. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -0
  63. package/dist/types/utils/utils.d.ts +6 -6
  64. package/dist/utils/utils.d.ts +110 -49
  65. package/dist/utils/utils.js +148 -73
  66. package/package.json +2 -2
  67. package/src/data-structures/base/iterable-element-base.ts +238 -115
  68. package/src/data-structures/base/iterable-entry-base.ts +96 -120
  69. package/src/data-structures/base/linear-base.ts +271 -277
  70. package/src/data-structures/binary-tree/avl-tree-counter.ts +198 -216
  71. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +192 -101
  72. package/src/data-structures/binary-tree/avl-tree.ts +239 -206
  73. package/src/data-structures/binary-tree/binary-tree.ts +681 -905
  74. package/src/data-structures/binary-tree/bst.ts +568 -570
  75. package/src/data-structures/binary-tree/red-black-tree.ts +161 -222
  76. package/src/data-structures/binary-tree/tree-counter.ts +199 -218
  77. package/src/data-structures/binary-tree/tree-multi-map.ts +131 -97
  78. package/src/data-structures/graph/abstract-graph.ts +339 -264
  79. package/src/data-structures/graph/directed-graph.ts +146 -236
  80. package/src/data-structures/graph/map-graph.ts +63 -60
  81. package/src/data-structures/graph/undirected-graph.ts +129 -152
  82. package/src/data-structures/hash/hash-map.ts +274 -496
  83. package/src/data-structures/heap/heap.ts +389 -402
  84. package/src/data-structures/heap/max-heap.ts +12 -76
  85. package/src/data-structures/heap/min-heap.ts +13 -76
  86. package/src/data-structures/linked-list/doubly-linked-list.ts +426 -530
  87. package/src/data-structures/linked-list/singly-linked-list.ts +495 -517
  88. package/src/data-structures/linked-list/skip-linked-list.ts +1 -108
  89. package/src/data-structures/priority-queue/max-priority-queue.ts +12 -87
  90. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -88
  91. package/src/data-structures/priority-queue/priority-queue.ts +3 -92
  92. package/src/data-structures/queue/deque.ts +381 -357
  93. package/src/data-structures/queue/queue.ts +310 -264
  94. package/src/data-structures/stack/stack.ts +217 -131
  95. package/src/data-structures/trie/trie.ts +240 -175
  96. package/src/interfaces/binary-tree.ts +240 -6
  97. package/src/interfaces/graph.ts +37 -0
  98. package/src/types/data-structures/base/base.ts +5 -5
  99. package/src/types/data-structures/graph/abstract-graph.ts +5 -0
  100. package/src/types/utils/utils.ts +9 -5
  101. package/src/utils/utils.ts +152 -86
@@ -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
- * The function returns the value of the protected variable _key.
15
- * @returns The value of the `_key` property, which is a string.
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
- * The above function sets the value of a protected variable called "key".
20
- * @param {string} value - The value parameter is a string that represents the value to be assigned
21
- * to the key.
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
- * The function returns the children of a TrieNode as a Map.
27
- * @returns The `children` property of the TrieNode object, which is a Map containing string keys and
28
- * TrieNode values.
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
- * The function sets the value of the `_children` property of a TrieNode object.
33
- * @param value - The value parameter is a Map object that represents the children of a TrieNode. The
34
- * keys of the map are strings, which represent the characters that are associated with each child
35
- * TrieNode. The values of the map are TrieNode objects, which represent the child nodes of the
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
- * The function returns a boolean value indicating whether a certain condition is met.
42
- * @returns The method is returning a boolean value, specifically the value of the variable `_isEnd`.
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
- * The function sets the value of the "_isEnd" property.
47
- * @param {boolean} value - The value parameter is a boolean value that indicates whether the current
48
- * state is the end state or not.
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
- * The constructor initializes a Trie data structure with optional options and words provided as
149
- * input.
150
- * @param {Iterable<string> | Iterable<R>} words - The `words` parameter in the constructor is an
151
- * iterable containing either strings or elements of type `R`. It is used to initialize the Trie with
152
- * a list of words or elements. If no `words` are provided, an empty iterable is used as the default
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
- * The size function returns the size of the stack.
163
- * @return The number of elements in the list
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
- * The caseSensitive function is a getter that returns the value of the protected _caseSensitive property.
169
- * @return The value of the _caseSensitive protected variable
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
- * The root function returns the root node of the tree.
175
- * @return The root node
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
- * Time Complexity: O(l), where l is the length of the word being added.
180
- * Space Complexity: O(l) - Each character in the word adds a TrieNode.
181
- *
182
- * Add a word to the Trie structure.
183
- * @param {string} word - The word to add.
184
- * @returns {boolean} True if the word was successfully added.
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
- * Time Complexity: O(n * l)
189
- * Space Complexity: O(1)
190
- *
191
- * The `addMany` function in TypeScript takes an iterable of strings or elements of type R, converts
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
- * Time Complexity: O(l), where l is the length of the input word.
202
- * Space Complexity: O(1) - Constant space.
203
- *
204
- * Check if the Trie contains a given word.
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
- * Time Complexity: O(1)
211
- * Space Complexity: O(1)
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
- * Time Complexity: O(1)
219
- * Space Complexity: O(1)
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
- * Time Complexity: O(l), where l is the length of the word being deleted.
226
- * Space Complexity: O(n) - Due to the recursive DFS approach.
227
- *
228
- * Remove a word from the Trie structure.
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
- * Time Complexity: O(n)
235
- * Space Complexity: O(1)
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
- * Time Complexity: O(l), where l is the length of the input prefix.
246
- * Space Complexity: O(1) - Constant space.
247
- *
248
- * Check if a given input string has an absolute prefix in the Trie, meaning it's not a complete word.
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
- * Time Complexity: O(l), where l is the length of the input prefix.
255
- * Space Complexity: O(1) - Constant space.
256
- *
257
- * Check if a given input string is a prefix of any existing word in the Trie, whether as an absolute prefix or a complete word.
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
- * Time Complexity: O(n), where n is the total number of nodes in the trie.
264
- * Space Complexity: O(l), where l is the length of the input prefix.
265
- *
266
- * Check if the input string is a common prefix in the Trie, meaning it's a prefix shared by all words in the Trie.
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
- * Time Complexity: O(n), where n is the total number of nodes in the trie.
273
- * Space Complexity: O(l), where l is the length of the longest common prefix.
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
- * Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
281
- * Space Complexity: O(w * l) - The space required for the output array.
282
- *
283
- * The `getAll` function returns an array of all words in a Trie data structure that start with a given prefix.
284
- * @param {string} prefix - The `prefix` parameter is a string that represents the prefix that we want to search for in the
285
- * trie. It is an optional parameter, so if no prefix is provided, it will default to an empty string.
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
- * Time Complexity: O(n)
293
- * Space Complexity: O(n)
294
- *
295
- * The `clone` function returns a new instance of the Trie class with the same values and case
296
- * sensitivity as the original Trie.
297
- * @returns A new instance of the Trie class is being returned.
298
- */
299
- clone(): Trie<R>;
300
- /**
301
- * Time Complexity: O(n)
302
- * Space Complexity: O(n)
303
- *
304
- * The `filter` function takes a predicate function and returns a new array containing all the
305
- * elements for which the predicate function returns true.
306
- * @param predicate - The `predicate` parameter is a callback function that takes three arguments:
307
- * `word`, `index`, and `this`. It should return a boolean value indicating whether the current
308
- * element should be included in the filtered results or not.
309
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
310
- * specify the value of `this` within the `predicate` function. It is used when you want to bind a
311
- * specific object as the context for the `predicate` function. If `thisArg` is provided, it will be
312
- * @returns The `filter` method is returning an array of strings (`string[]`).
313
- */
314
- filter(predicate: ElementCallback<string, R, boolean>, thisArg?: any): Trie<R>;
315
- /**
316
- * Time Complexity: O(n)
317
- * Space Complexity: O(n)
318
- *
319
- * The `map` function creates a new Trie by applying a callback function to each element in the
320
- * current Trie.
321
- * @param callback - The callback parameter is a function that will be called for each element in the
322
- * Trie. It takes four arguments:
323
- * @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
324
- * convert the raw element (`RM`) into a string representation. This can be useful if the raw element
325
- * is not already a string or if you want to customize how the element is converted into a string. If
326
- * this parameter is
327
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
328
- * specify the value of `this` within the callback function. It is used to set the context or scope
329
- * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
330
- * value of
331
- * @returns a new Trie object.
332
- */
333
- map<RM>(callback: ElementCallback<string, R, string>, toElementFn?: (rawElement: RM) => string, thisArg?: any): Trie<RM>;
334
- /**
335
- * Time Complexity: O(n)
336
- * Space Complexity: O(n)
337
- *
338
- * The function `_getIterator` returns an iterable iterator that performs a depth-first search on a
339
- * trie data structure and yields all the paths to the end nodes.
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
- * Time Complexity: O(l), where l is the length of the input string.
345
- * Space Complexity: O(1) - Constant space.
346
- *
347
- * @param str
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
  }