data-structure-typed 2.6.0 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/.github/workflows/ci.yml +7 -2
  2. package/.github/workflows/release-package.yml +9 -2
  3. package/CHANGELOG.md +9 -1
  4. package/dist/cjs/binary-tree.cjs +2927 -23688
  5. package/dist/cjs/graph.cjs +845 -2634
  6. package/dist/cjs/hash.cjs +185 -616
  7. package/dist/cjs/heap.cjs +266 -818
  8. package/dist/cjs/index.cjs +5116 -31358
  9. package/dist/cjs/linked-list.cjs +644 -2615
  10. package/dist/cjs/matrix.cjs +220 -535
  11. package/dist/cjs/priority-queue.cjs +266 -818
  12. package/dist/cjs/queue.cjs +637 -2343
  13. package/dist/cjs/stack.cjs +124 -530
  14. package/dist/cjs/trie.cjs +145 -592
  15. package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
  16. package/dist/cjs-legacy/graph.cjs +847 -2636
  17. package/dist/cjs-legacy/hash.cjs +181 -612
  18. package/dist/cjs-legacy/heap.cjs +266 -818
  19. package/dist/cjs-legacy/index.cjs +6657 -32899
  20. package/dist/cjs-legacy/linked-list.cjs +640 -2611
  21. package/dist/cjs-legacy/matrix.cjs +220 -535
  22. package/dist/cjs-legacy/priority-queue.cjs +266 -818
  23. package/dist/cjs-legacy/queue.cjs +634 -2340
  24. package/dist/cjs-legacy/stack.cjs +124 -530
  25. package/dist/cjs-legacy/trie.cjs +145 -592
  26. package/dist/esm/binary-tree.mjs +2927 -23688
  27. package/dist/esm/graph.mjs +845 -2634
  28. package/dist/esm/hash.mjs +185 -616
  29. package/dist/esm/heap.mjs +266 -818
  30. package/dist/esm/index.mjs +5116 -31358
  31. package/dist/esm/linked-list.mjs +644 -2615
  32. package/dist/esm/matrix.mjs +220 -535
  33. package/dist/esm/priority-queue.mjs +266 -818
  34. package/dist/esm/queue.mjs +637 -2343
  35. package/dist/esm/stack.mjs +124 -530
  36. package/dist/esm/trie.mjs +145 -592
  37. package/dist/esm-legacy/binary-tree.mjs +4352 -25113
  38. package/dist/esm-legacy/graph.mjs +847 -2636
  39. package/dist/esm-legacy/hash.mjs +181 -612
  40. package/dist/esm-legacy/heap.mjs +266 -818
  41. package/dist/esm-legacy/index.mjs +6657 -32899
  42. package/dist/esm-legacy/linked-list.mjs +640 -2611
  43. package/dist/esm-legacy/matrix.mjs +220 -535
  44. package/dist/esm-legacy/priority-queue.mjs +266 -818
  45. package/dist/esm-legacy/queue.mjs +634 -2340
  46. package/dist/esm-legacy/stack.mjs +124 -530
  47. package/dist/esm-legacy/trie.mjs +145 -592
  48. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
  49. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
  50. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
  51. package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
  52. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
  53. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
  54. package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
  55. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
  56. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
  57. package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
  58. package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
  59. package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
  60. package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
  61. package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
  62. package/dist/types/data-structures/heap/heap.d.ts +194 -746
  63. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
  64. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
  65. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
  66. package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
  67. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
  68. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
  69. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  70. package/dist/types/data-structures/queue/deque.d.ts +196 -804
  71. package/dist/types/data-structures/queue/queue.d.ts +99 -585
  72. package/dist/types/data-structures/stack/stack.d.ts +75 -481
  73. package/dist/types/data-structures/trie/trie.d.ts +98 -584
  74. package/dist/umd/data-structure-typed.js +6580 -32822
  75. package/dist/umd/data-structure-typed.min.js +3 -3
  76. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
  77. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
  78. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
  79. package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
  80. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
  81. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
  82. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
  83. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  84. package/docs-site-docusaurus/docs/api/classes/Deque.md +253 -101
  85. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
  86. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +244 -114
  87. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
  88. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
  89. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  90. package/docs-site-docusaurus/docs/api/classes/HashMap.md +52 -48
  91. package/docs-site-docusaurus/docs/api/classes/Heap.md +119 -64
  92. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +84 -14
  93. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +138 -34
  94. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +149 -41
  95. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
  96. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +172 -92
  97. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
  98. package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
  99. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -62
  100. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +120 -70
  101. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -62
  102. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +125 -75
  103. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +119 -64
  104. package/docs-site-docusaurus/docs/api/classes/Queue.md +158 -74
  105. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
  106. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
  107. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +172 -94
  108. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
  109. package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
  110. package/docs-site-docusaurus/docs/api/classes/Stack.md +112 -50
  111. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
  112. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +90 -121
  113. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +298 -107
  114. package/docs-site-docusaurus/docs/api/classes/Trie.md +116 -58
  115. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  116. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
  117. package/package.json +45 -46
  118. package/src/common/error.ts +15 -32
  119. package/src/common/index.ts +0 -3
  120. package/src/data-structures/base/iterable-element-base.ts +0 -3
  121. package/src/data-structures/base/linear-base.ts +2 -36
  122. package/src/data-structures/binary-tree/avl-tree.ts +31 -529
  123. package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -572
  124. package/src/data-structures/binary-tree/binary-tree.ts +326 -1311
  125. package/src/data-structures/binary-tree/bst.ts +158 -1082
  126. package/src/data-structures/binary-tree/red-black-tree.ts +451 -1290
  127. package/src/data-structures/binary-tree/segment-tree.ts +73 -351
  128. package/src/data-structures/binary-tree/tree-map.ts +462 -5124
  129. package/src/data-structures/binary-tree/tree-multi-map.ts +302 -4914
  130. package/src/data-structures/binary-tree/tree-multi-set.ts +299 -3983
  131. package/src/data-structures/binary-tree/tree-set.ts +338 -4836
  132. package/src/data-structures/graph/abstract-graph.ts +98 -167
  133. package/src/data-structures/graph/directed-graph.ts +137 -562
  134. package/src/data-structures/graph/map-graph.ts +0 -3
  135. package/src/data-structures/graph/undirected-graph.ts +132 -511
  136. package/src/data-structures/hash/hash-map.ts +154 -582
  137. package/src/data-structures/heap/heap.ts +200 -795
  138. package/src/data-structures/linked-list/doubly-linked-list.ts +121 -865
  139. package/src/data-structures/linked-list/singly-linked-list.ts +122 -794
  140. package/src/data-structures/linked-list/skip-linked-list.ts +211 -918
  141. package/src/data-structures/matrix/matrix.ts +179 -518
  142. package/src/data-structures/matrix/navigator.ts +0 -1
  143. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
  144. package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
  145. package/src/data-structures/priority-queue/priority-queue.ts +1 -2
  146. package/src/data-structures/queue/deque.ts +214 -882
  147. package/src/data-structures/queue/queue.ts +102 -625
  148. package/src/data-structures/stack/stack.ts +76 -505
  149. package/src/data-structures/trie/trie.ts +98 -628
  150. package/src/types/common.ts +0 -10
  151. package/src/types/data-structures/binary-tree/bst.ts +0 -7
  152. package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
  153. package/src/types/data-structures/graph/abstract-graph.ts +0 -2
  154. package/src/types/data-structures/hash/hash-map.ts +0 -3
  155. package/src/types/data-structures/hash/index.ts +0 -1
  156. package/src/types/data-structures/matrix/navigator.ts +0 -2
  157. package/src/types/utils/utils.ts +0 -7
  158. package/src/types/utils/validate-type.ts +0 -7
  159. package/src/utils/number.ts +0 -2
  160. package/src/utils/utils.ts +0 -5
@@ -218,63 +218,21 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
218
218
  * @remarks Time O(L), Space O(L)
219
219
  * @param word - Word to insert.
220
220
  * @returns True if the word was newly added.
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
-
229
-
230
-
231
-
232
-
233
-
234
-
235
-
236
-
237
-
238
-
239
-
240
-
241
-
242
-
243
-
244
-
245
-
246
-
247
-
248
-
249
-
250
-
251
-
252
-
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
-
262
-
263
- * @example
264
- * // basic Trie creation and add words
265
- * // Create a simple Trie with initial words
266
- * const trie = new Trie(['apple', 'app', 'apply']);
267
- *
268
- * // Verify size
269
- * console.log(trie.size); // 3;
270
- *
271
- * // Check if words exist
272
- * console.log(trie.has('apple')); // true;
273
- * console.log(trie.has('app')); // true;
274
- *
275
- * // Add a new word
276
- * trie.add('application');
277
- * console.log(trie.size); // 4;
221
+ * @example
222
+ * // basic Trie creation and add words
223
+ * // Create a simple Trie with initial words
224
+ * const trie = new Trie(['apple', 'app', 'apply']);
225
+ *
226
+ * // Verify size
227
+ * console.log(trie.size); // 3;
228
+ *
229
+ * // Check if words exist
230
+ * console.log(trie.has('apple')); // true;
231
+ * console.log(trie.has('app')); // true;
232
+ *
233
+ * // Add a new word
234
+ * trie.add('application');
235
+ * console.log(trie.size); // 4;
278
236
  */
279
237
  add(word: string): boolean;
280
238
  /**
@@ -282,52 +240,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
282
240
  * @remarks Time O(ΣL), Space O(ΣL)
283
241
  * @param words - Iterable of strings (or raw records if toElementFn is provided).
284
242
  * @returns Array of per-word 'added' flags.
285
-
286
-
287
-
288
-
289
-
290
-
291
-
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
-
322
-
323
-
324
- * @example
325
- * // Add multiple words
326
- * const trie = new Trie();
327
- * trie.addMany(['cat', 'car', 'card']);
328
- * console.log(trie.has('cat')); // true;
329
- * console.log(trie.has('car')); // true;
330
- * console.log(trie.size); // 3;
243
+ * @example
244
+ * // Add multiple words
245
+ * const trie = new Trie();
246
+ * trie.addMany(['cat', 'car', 'card']);
247
+ * console.log(trie.has('cat')); // true;
248
+ * console.log(trie.has('car')); // true;
249
+ * console.log(trie.size); // 3;
331
250
  */
332
251
  addMany(words: Iterable<string> | Iterable<R>): boolean[];
333
252
  /**
@@ -335,156 +254,36 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
335
254
  * @remarks Time O(L), Space O(1)
336
255
  * @param word - Word to search for.
337
256
  * @returns True if present.
338
-
339
-
340
-
341
-
342
-
343
-
344
-
345
-
346
-
347
-
348
-
349
-
350
-
351
-
352
-
353
-
354
-
355
-
356
-
357
-
358
-
359
-
360
-
361
-
362
-
363
-
364
-
365
-
366
-
367
-
368
-
369
-
370
-
371
-
372
-
373
-
374
-
375
-
376
-
377
-
378
-
379
-
380
- * @example
381
- * // Check if a word exists
382
- * const dict = new Trie(['apple', 'app', 'application']);
383
- *
384
- * console.log(dict.has('app')); // true;
385
- * console.log(dict.has('apple')); // true;
386
- * console.log(dict.has('ap')); // false;
257
+ * @example
258
+ * // Check if a word exists
259
+ * const dict = new Trie(['apple', 'app', 'application']);
260
+ *
261
+ * console.log(dict.has('app')); // true;
262
+ * console.log(dict.has('apple')); // true;
263
+ * console.log(dict.has('ap')); // false;
387
264
  */
388
265
  has(word: string): boolean;
389
266
  /**
390
267
  * Check whether the trie is empty.
391
268
  * @remarks Time O(1), Space O(1)
392
269
  * @returns True if size is 0.
393
-
394
-
395
-
396
-
397
-
398
-
399
-
400
-
401
-
402
-
403
-
404
-
405
-
406
-
407
-
408
-
409
-
410
-
411
-
412
-
413
-
414
-
415
-
416
-
417
-
418
-
419
-
420
-
421
-
422
-
423
-
424
-
425
-
426
-
427
-
428
-
429
-
430
-
431
-
432
- * @example
433
- * // Check if empty
434
- * const trie = new Trie();
435
- * console.log(trie.isEmpty()); // true;
436
- * trie.add('word');
437
- * console.log(trie.isEmpty()); // false;
270
+ * @example
271
+ * // Check if empty
272
+ * const trie = new Trie();
273
+ * console.log(trie.isEmpty()); // true;
274
+ * trie.add('word');
275
+ * console.log(trie.isEmpty()); // false;
438
276
  */
439
277
  isEmpty(): boolean;
440
278
  /**
441
279
  * Remove all words and reset to a fresh root.
442
280
  * @remarks Time O(1), Space O(1)
443
281
  * @returns void
444
-
445
-
446
-
447
-
448
-
449
-
450
-
451
-
452
-
453
-
454
-
455
-
456
-
457
-
458
-
459
-
460
-
461
-
462
-
463
-
464
-
465
-
466
-
467
-
468
-
469
-
470
-
471
-
472
-
473
-
474
-
475
-
476
-
477
-
478
-
479
-
480
-
481
-
482
-
483
- * @example
484
- * // Remove all words
485
- * const trie = new Trie(['a', 'b', 'c']);
486
- * trie.clear();
487
- * console.log(trie.isEmpty()); // true;
282
+ * @example
283
+ * // Remove all words
284
+ * const trie = new Trie(['a', 'b', 'c']);
285
+ * trie.clear();
286
+ * console.log(trie.isEmpty()); // true;
488
287
  */
489
288
  clear(): void;
490
289
  /**
@@ -492,65 +291,23 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
492
291
  * @remarks Time O(L), Space O(1)
493
292
  * @param word - Word to delete.
494
293
  * @returns True if a word was removed.
495
-
496
-
497
-
498
-
499
-
500
-
501
-
502
-
503
-
504
-
505
-
506
-
507
-
508
-
509
-
510
-
511
-
512
-
513
-
514
-
515
-
516
-
517
-
518
-
519
-
520
-
521
-
522
-
523
-
524
-
525
-
526
-
527
-
528
-
529
-
530
-
531
-
532
-
533
-
534
-
535
-
536
-
537
- * @example
538
- * // Trie delete and iteration
539
- * const trie = new Trie(['car', 'card', 'care', 'careful', 'can', 'cat']);
540
- *
541
- * // Delete a word
542
- * trie.delete('card');
543
- * console.log(trie.has('card')); // false;
544
- *
545
- * // Word with same prefix still exists
546
- * console.log(trie.has('care')); // true;
547
- *
548
- * // Size decreased
549
- * console.log(trie.size); // 5;
550
- *
551
- * // Iterate through all words
552
- * const allWords = [...trie];
553
- * console.log(allWords.length); // 5;
294
+ * @example
295
+ * // Trie delete and iteration
296
+ * const trie = new Trie(['car', 'card', 'care', 'careful', 'can', 'cat']);
297
+ *
298
+ * // Delete a word
299
+ * trie.delete('card');
300
+ * console.log(trie.has('card')); // false;
301
+ *
302
+ * // Word with same prefix still exists
303
+ * console.log(trie.has('care')); // true;
304
+ *
305
+ * // Size decreased
306
+ * console.log(trie.size); // 5;
307
+ *
308
+ * // Iterate through all words
309
+ * const allWords = [...trie];
310
+ * console.log(allWords.length); // 5;
554
311
  */
555
312
  delete(word: string): boolean;
556
313
  /**
@@ -571,55 +328,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
571
328
  * @remarks Time O(L), Space O(1)
572
329
  * @param input - String to test as prefix.
573
330
  * @returns True if input matches a path from root.
574
-
575
-
576
-
577
-
578
-
579
-
580
-
581
-
582
-
583
-
584
-
585
-
586
-
587
-
588
-
589
-
590
-
591
-
592
-
593
-
594
-
595
-
596
-
597
-
598
-
599
-
600
-
601
-
602
-
603
-
604
-
605
-
606
-
607
-
608
-
609
-
610
-
611
-
612
-
613
-
614
-
615
-
616
- * @example
617
- * // Check if a prefix exists
618
- * const trie = new Trie(['hello', 'help', 'world']);
619
- *
620
- * console.log(trie.hasPrefix('hel')); // true;
621
- * console.log(trie.hasPrefix('wor')); // true;
622
- * console.log(trie.hasPrefix('xyz')); // false;
331
+ * @example
332
+ * // Check if a prefix exists
333
+ * const trie = new Trie(['hello', 'help', 'world']);
334
+ *
335
+ * console.log(trie.hasPrefix('hel')); // true;
336
+ * console.log(trie.hasPrefix('wor')); // true;
337
+ * console.log(trie.hasPrefix('xyz')); // false;
623
338
  */
624
339
  hasPrefix(input: string): boolean;
625
340
  /**
@@ -633,53 +348,11 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
633
348
  * Return the longest common prefix among all words.
634
349
  * @remarks Time O(H), Space O(1)
635
350
  * @returns The longest common prefix string.
636
-
637
-
638
-
639
-
640
-
641
-
642
-
643
-
644
-
645
-
646
-
647
-
648
-
649
-
650
-
651
-
652
-
653
-
654
-
655
-
656
-
657
-
658
-
659
-
660
-
661
-
662
-
663
-
664
-
665
-
666
-
667
-
668
-
669
-
670
-
671
-
672
-
673
-
674
-
675
-
676
-
677
-
678
- * @example
679
- * // Find shared prefix
680
- * const trie = new Trie(['flower', 'flow', 'flight']);
681
- *
682
- * console.log(trie.getLongestCommonPrefix()); // 'fl';
351
+ * @example
352
+ * // Find shared prefix
353
+ * const trie = new Trie(['flower', 'flow', 'flight']);
354
+ *
355
+ * console.log(trie.getLongestCommonPrefix()); // 'fl';
683
356
  */
684
357
  getLongestCommonPrefix(): string;
685
358
  /**
@@ -689,110 +362,29 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
689
362
  * @param [max] - Maximum number of words to return; default is Number.MAX_SAFE_INTEGER.
690
363
  * @param [isAllWhenEmptyPrefix] - When true, collect from root even if prefix is empty.
691
364
  * @returns Array of collected words (at most max).
692
-
693
-
694
-
695
-
696
-
697
-
698
-
699
-
700
-
701
-
702
-
703
-
704
-
705
-
706
-
707
-
708
-
709
-
710
-
711
-
712
-
713
-
714
-
715
-
716
-
717
-
718
-
719
-
720
-
721
-
722
-
723
-
724
-
725
-
726
-
727
-
728
-
729
-
730
-
731
-
732
-
733
-
734
- * @example
735
- * // Trie getWords and prefix search
736
- * const trie = new Trie(['apple', 'app', 'apply', 'application', 'apricot']);
737
- *
738
- * // Get all words with prefix 'app'
739
- * const appWords = trie.getWords('app');
740
- * console.log(appWords); // contains 'app';
741
- * console.log(appWords); // contains 'apple';
742
- * console.log(appWords); // contains 'apply';
743
- * console.log(appWords); // contains 'application';
744
- * expect(appWords).not.toContain('apricot');
365
+ * @example
366
+ * // Trie getWords and prefix search
367
+ * const trie = new Trie(['apple', 'app', 'apply', 'application', 'apricot']);
368
+ *
369
+ * // Get all words with prefix 'app'
370
+ * const appWords = trie.getWords('app');
371
+ * console.log(appWords); // contains 'app';
372
+ * console.log(appWords); // contains 'apple';
373
+ * console.log(appWords); // contains 'apply';
374
+ * console.log(appWords); // contains 'application';
375
+ * expect(appWords).not.toContain('apricot');
745
376
  */
746
377
  getWords(prefix?: string, max?: number, isAllWhenEmptyPrefix?: boolean): string[];
747
378
  /**
748
379
  * Deep clone this trie by iterating and inserting all words.
749
380
  * @remarks Time O(ΣL), Space O(ΣL)
750
381
  * @returns A new trie with the same words and options.
751
-
752
-
753
-
754
-
755
-
756
-
757
-
758
-
759
-
760
-
761
-
762
-
763
-
764
-
765
-
766
-
767
-
768
-
769
-
770
-
771
-
772
-
773
-
774
-
775
-
776
-
777
-
778
-
779
-
780
-
781
-
782
-
783
-
784
-
785
-
786
-
787
-
788
-
789
-
790
- * @example
791
- * // Create independent copy
792
- * const trie = new Trie(['hello', 'world']);
793
- * const copy = trie.clone();
794
- * copy.delete('hello');
795
- * console.log(trie.has('hello')); // true;
382
+ * @example
383
+ * // Create independent copy
384
+ * const trie = new Trie(['hello', 'world']);
385
+ * const copy = trie.clone();
386
+ * copy.delete('hello');
387
+ * console.log(trie.has('hello')); // true;
796
388
  */
797
389
  clone(): this;
798
390
  /**
@@ -801,99 +393,21 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
801
393
  * @param predicate - Predicate (word, index, trie) → boolean to keep word.
802
394
  * @param [thisArg] - Value for `this` inside the predicate.
803
395
  * @returns A new trie containing words that satisfy the predicate.
804
-
805
-
806
-
807
-
808
-
809
-
810
-
811
-
812
-
813
-
814
-
815
-
816
-
817
-
818
-
819
-
820
-
821
-
822
-
823
-
824
-
825
-
826
-
827
-
828
-
829
-
830
-
831
-
832
-
833
-
834
-
835
-
836
-
837
-
838
-
839
-
840
-
841
-
842
-
843
- * @example
844
- * // Filter words
845
- * const trie = new Trie(['cat', 'car', 'dog', 'card']);
846
- * const result = trie.filter(w => w.startsWith('ca'));
847
- * console.log(result.size); // 3;
396
+ * @example
397
+ * // Filter words
398
+ * const trie = new Trie(['cat', 'car', 'dog', 'card']);
399
+ * const result = trie.filter(w => w.startsWith('ca'));
400
+ * console.log(result.size); // 3;
848
401
  */
849
402
  filter(predicate: ElementCallback<string, R, boolean>, thisArg?: unknown): this;
850
403
  /**
851
- * Transform words
852
-
853
-
854
-
855
-
856
-
857
-
858
-
859
-
860
-
861
-
862
-
863
-
864
-
865
-
866
-
867
-
868
-
869
-
870
-
871
-
872
-
873
-
874
-
875
-
876
-
877
-
878
-
879
-
880
-
881
-
882
-
883
-
884
-
885
-
886
-
887
-
888
-
889
-
890
-
891
- * @example
892
- * // Transform words
893
- * const trie = new Trie(['hello', 'world']);
894
- * const upper = trie.map(w => w.toUpperCase());
895
- * console.log(upper.has('HELLO')); // true;
896
- */
404
+ * Transform words
405
+ * @example
406
+ * // Transform words
407
+ * const trie = new Trie(['hello', 'world']);
408
+ * const upper = trie.map(w => w.toUpperCase());
409
+ * console.log(upper.has('HELLO')); // true;
410
+ */
897
411
  map<RM>(callback: ElementCallback<string, R, string>, options?: TrieOptions<RM>, thisArg?: unknown): Trie<RM>;
898
412
  /**
899
413
  * Map words into a new trie (possibly different record type).