data-structure-typed 2.5.0 → 2.5.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 (246) hide show
  1. package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +12984 -0
  2. package/.vitepress/cache/deps_temp_51f5f1b0/package.json +3 -0
  3. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +4505 -0
  4. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +9731 -0
  5. package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +347 -0
  6. package/CHANGELOG.md +5 -1
  7. package/README.md +124 -29
  8. package/dist/cjs/binary-tree.cjs +26282 -0
  9. package/dist/cjs/graph.cjs +5422 -0
  10. package/dist/cjs/hash.cjs +1310 -0
  11. package/dist/cjs/heap.cjs +1602 -0
  12. package/dist/cjs/index.cjs +31257 -14673
  13. package/dist/cjs/linked-list.cjs +4576 -0
  14. package/dist/cjs/matrix.cjs +1080 -0
  15. package/dist/cjs/priority-queue.cjs +1376 -0
  16. package/dist/cjs/queue.cjs +4264 -0
  17. package/dist/cjs/stack.cjs +907 -0
  18. package/dist/cjs/trie.cjs +1223 -0
  19. package/dist/cjs-legacy/binary-tree.cjs +26319 -0
  20. package/dist/cjs-legacy/graph.cjs +5420 -0
  21. package/dist/cjs-legacy/hash.cjs +1310 -0
  22. package/dist/cjs-legacy/heap.cjs +1599 -0
  23. package/dist/cjs-legacy/index.cjs +31268 -14679
  24. package/dist/cjs-legacy/linked-list.cjs +4582 -0
  25. package/dist/cjs-legacy/matrix.cjs +1083 -0
  26. package/dist/cjs-legacy/priority-queue.cjs +1374 -0
  27. package/dist/cjs-legacy/queue.cjs +4262 -0
  28. package/dist/cjs-legacy/stack.cjs +907 -0
  29. package/dist/cjs-legacy/trie.cjs +1222 -0
  30. package/dist/esm/binary-tree.mjs +26267 -0
  31. package/dist/esm/graph.mjs +5409 -0
  32. package/dist/esm/hash.mjs +1307 -0
  33. package/dist/esm/heap.mjs +1596 -0
  34. package/dist/esm/index.mjs +31254 -14674
  35. package/dist/esm/linked-list.mjs +4569 -0
  36. package/dist/esm/matrix.mjs +1076 -0
  37. package/dist/esm/priority-queue.mjs +1372 -0
  38. package/dist/esm/queue.mjs +4260 -0
  39. package/dist/esm/stack.mjs +905 -0
  40. package/dist/esm/trie.mjs +1220 -0
  41. package/dist/esm-legacy/binary-tree.mjs +26304 -0
  42. package/dist/esm-legacy/graph.mjs +5407 -0
  43. package/dist/esm-legacy/hash.mjs +1307 -0
  44. package/dist/esm-legacy/heap.mjs +1593 -0
  45. package/dist/esm-legacy/index.mjs +31265 -14680
  46. package/dist/esm-legacy/linked-list.mjs +4575 -0
  47. package/dist/esm-legacy/matrix.mjs +1079 -0
  48. package/dist/esm-legacy/priority-queue.mjs +1370 -0
  49. package/dist/esm-legacy/queue.mjs +4258 -0
  50. package/dist/esm-legacy/stack.mjs +905 -0
  51. package/dist/esm-legacy/trie.mjs +1219 -0
  52. package/dist/types/common/error.d.ts +9 -0
  53. package/dist/types/common/index.d.ts +1 -1
  54. package/dist/types/data-structures/base/index.d.ts +1 -0
  55. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  56. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  57. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +288 -0
  58. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
  59. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
  60. package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
  61. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
  62. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
  63. package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
  64. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
  65. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
  66. package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
  67. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  68. package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
  69. package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
  70. package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
  71. package/dist/types/data-structures/heap/heap.d.ts +336 -0
  72. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
  73. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
  74. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
  75. package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
  76. package/dist/types/data-structures/queue/deque.d.ts +364 -4
  77. package/dist/types/data-structures/queue/queue.d.ts +288 -0
  78. package/dist/types/data-structures/stack/stack.d.ts +240 -0
  79. package/dist/types/data-structures/trie/trie.d.ts +292 -4
  80. package/dist/types/interfaces/graph.d.ts +1 -1
  81. package/dist/types/types/common.d.ts +2 -2
  82. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  83. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  84. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  85. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  86. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  87. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  88. package/dist/types/types/utils/validate-type.d.ts +4 -4
  89. package/dist/umd/data-structure-typed.js +31196 -14608
  90. package/dist/umd/data-structure-typed.min.js +11 -5
  91. package/docs-site-docusaurus/README.md +41 -0
  92. package/docs-site-docusaurus/docs/api/README.md +52 -0
  93. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +6644 -0
  94. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +282 -0
  95. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +2266 -0
  96. package/docs-site-docusaurus/docs/api/classes/BST.md +6293 -0
  97. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +333 -0
  98. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +455 -0
  99. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +4647 -0
  100. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +331 -0
  101. package/docs-site-docusaurus/docs/api/classes/Deque.md +2767 -0
  102. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +2999 -0
  103. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +2685 -0
  104. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +221 -0
  105. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +253 -0
  106. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +21 -0
  107. package/docs-site-docusaurus/docs/api/classes/HashMap.md +1333 -0
  108. package/docs-site-docusaurus/docs/api/classes/Heap.md +1881 -0
  109. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +800 -0
  110. package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +644 -0
  111. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +1632 -0
  112. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +1853 -0
  113. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +1108 -0
  114. package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +156 -0
  115. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +2824 -0
  116. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +2929 -0
  117. package/docs-site-docusaurus/docs/api/classes/Matrix.md +1026 -0
  118. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +1866 -0
  119. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +1883 -0
  120. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +1879 -0
  121. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +1882 -0
  122. package/docs-site-docusaurus/docs/api/classes/Navigator.md +109 -0
  123. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +1839 -0
  124. package/docs-site-docusaurus/docs/api/classes/Queue.md +2244 -0
  125. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +6888 -0
  126. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +372 -0
  127. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +2897 -0
  128. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +169 -0
  129. package/docs-site-docusaurus/docs/api/classes/SkipList.md +1229 -0
  130. package/docs-site-docusaurus/docs/api/classes/Stack.md +1573 -0
  131. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +1389 -0
  132. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +1591 -0
  133. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +1246 -0
  134. package/docs-site-docusaurus/docs/api/classes/Trie.md +1708 -0
  135. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +199 -0
  136. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +2979 -0
  137. package/docs-site-docusaurus/docs/guide/_category_.json +6 -0
  138. package/docs-site-docusaurus/docs/guide/architecture.md +615 -0
  139. package/docs-site-docusaurus/docs/guide/concepts.md +451 -0
  140. package/docs-site-docusaurus/docs/guide/faq.md +180 -0
  141. package/docs-site-docusaurus/docs/guide/guides.md +597 -0
  142. package/docs-site-docusaurus/docs/guide/installation.md +62 -0
  143. package/docs-site-docusaurus/docs/guide/integrations.md +825 -0
  144. package/docs-site-docusaurus/docs/guide/overview.md +645 -0
  145. package/docs-site-docusaurus/docs/guide/performance.md +835 -0
  146. package/docs-site-docusaurus/docs/guide/quick-start.md +104 -0
  147. package/docs-site-docusaurus/docs/guide/use-cases/_category_.json +6 -0
  148. package/docs-site-docusaurus/docs/guide/use-cases/array-sort-alternative.md +158 -0
  149. package/docs-site-docusaurus/docs/guide/use-cases/heap-vs-sorting.md +92 -0
  150. package/docs-site-docusaurus/docs/guide/use-cases/map-vs-treemap.md +151 -0
  151. package/docs-site-docusaurus/docs/guide/use-cases/priority-queue-typescript.md +113 -0
  152. package/docs-site-docusaurus/docs/guide/use-cases/treemap-javascript.md +151 -0
  153. package/docs-site-docusaurus/docusaurus.config.ts +159 -0
  154. package/docs-site-docusaurus/fix-mdx-generics.mjs +75 -0
  155. package/docs-site-docusaurus/package-lock.json +18667 -0
  156. package/docs-site-docusaurus/package.json +50 -0
  157. package/docs-site-docusaurus/prefix-class-to-methods.mjs +48 -0
  158. package/docs-site-docusaurus/sidebars.ts +23 -0
  159. package/docs-site-docusaurus/sort-protected.mjs +87 -0
  160. package/docs-site-docusaurus/src/css/custom.css +96 -0
  161. package/docs-site-docusaurus/src/pages/index.module.css +13 -0
  162. package/docs-site-docusaurus/src/pages/index.tsx +120 -0
  163. package/docs-site-docusaurus/src/pages/markdown-page.md +7 -0
  164. package/docs-site-docusaurus/src/theme/TOCItems/index.tsx +34 -0
  165. package/docs-site-docusaurus/static/.nojekyll +0 -0
  166. package/docs-site-docusaurus/static/img/docusaurus-social-card.jpg +0 -0
  167. package/docs-site-docusaurus/static/img/docusaurus.png +0 -0
  168. package/docs-site-docusaurus/static/img/favicon.ico +0 -0
  169. package/docs-site-docusaurus/static/img/favicon.png +0 -0
  170. package/docs-site-docusaurus/static/img/logo-180.png +0 -0
  171. package/docs-site-docusaurus/static/img/logo.jpg +0 -0
  172. package/docs-site-docusaurus/static/img/logo.png +0 -0
  173. package/docs-site-docusaurus/static/img/logo.svg +1 -0
  174. package/docs-site-docusaurus/static/img/og-image.png +0 -0
  175. package/docs-site-docusaurus/static/img/undraw_docusaurus_mountain.svg +171 -0
  176. package/docs-site-docusaurus/static/img/undraw_docusaurus_react.svg +170 -0
  177. package/docs-site-docusaurus/static/img/undraw_docusaurus_tree.svg +40 -0
  178. package/docs-site-docusaurus/static/llms.txt +37 -0
  179. package/docs-site-docusaurus/static/robots.txt +4 -0
  180. package/docs-site-docusaurus/typedoc.json +23 -0
  181. package/llms.txt +37 -0
  182. package/package.json +159 -55
  183. package/src/common/error.ts +19 -1
  184. package/src/common/index.ts +1 -1
  185. package/src/data-structures/base/index.ts +1 -0
  186. package/src/data-structures/base/iterable-element-base.ts +3 -2
  187. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  188. package/src/data-structures/base/linear-base.ts +3 -3
  189. package/src/data-structures/binary-tree/avl-tree.ts +287 -0
  190. package/src/data-structures/binary-tree/binary-indexed-tree.ts +327 -5
  191. package/src/data-structures/binary-tree/binary-tree.ts +581 -6
  192. package/src/data-structures/binary-tree/bst.ts +922 -7
  193. package/src/data-structures/binary-tree/red-black-tree.ts +453 -0
  194. package/src/data-structures/binary-tree/segment-tree.ts +139 -2
  195. package/src/data-structures/binary-tree/tree-map.ts +3300 -495
  196. package/src/data-structures/binary-tree/tree-multi-map.ts +3384 -563
  197. package/src/data-structures/binary-tree/tree-multi-set.ts +2757 -493
  198. package/src/data-structures/binary-tree/tree-set.ts +3122 -440
  199. package/src/data-structures/graph/abstract-graph.ts +6 -6
  200. package/src/data-structures/graph/directed-graph.ts +230 -0
  201. package/src/data-structures/graph/undirected-graph.ts +207 -0
  202. package/src/data-structures/hash/hash-map.ts +270 -19
  203. package/src/data-structures/heap/heap.ts +326 -4
  204. package/src/data-structures/heap/max-heap.ts +2 -2
  205. package/src/data-structures/linked-list/doubly-linked-list.ts +394 -3
  206. package/src/data-structures/linked-list/singly-linked-list.ts +348 -3
  207. package/src/data-structures/linked-list/skip-linked-list.ts +421 -7
  208. package/src/data-structures/matrix/matrix.ts +194 -10
  209. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  210. package/src/data-structures/queue/deque.ts +350 -5
  211. package/src/data-structures/queue/queue.ts +276 -0
  212. package/src/data-structures/stack/stack.ts +230 -0
  213. package/src/data-structures/trie/trie.ts +283 -7
  214. package/src/interfaces/graph.ts +1 -1
  215. package/src/types/common.ts +2 -2
  216. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  217. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  218. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  219. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
  220. package/src/types/data-structures/heap/heap.ts +1 -0
  221. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  222. package/src/types/utils/validate-type.ts +4 -4
  223. package/vercel.json +6 -0
  224. package/dist/leetcode/avl-tree-counter.mjs +0 -2957
  225. package/dist/leetcode/avl-tree-multi-map.mjs +0 -2889
  226. package/dist/leetcode/avl-tree.mjs +0 -2720
  227. package/dist/leetcode/binary-tree.mjs +0 -1594
  228. package/dist/leetcode/bst.mjs +0 -2398
  229. package/dist/leetcode/deque.mjs +0 -683
  230. package/dist/leetcode/directed-graph.mjs +0 -1733
  231. package/dist/leetcode/doubly-linked-list.mjs +0 -709
  232. package/dist/leetcode/hash-map.mjs +0 -493
  233. package/dist/leetcode/heap.mjs +0 -542
  234. package/dist/leetcode/max-heap.mjs +0 -375
  235. package/dist/leetcode/max-priority-queue.mjs +0 -383
  236. package/dist/leetcode/min-heap.mjs +0 -363
  237. package/dist/leetcode/min-priority-queue.mjs +0 -371
  238. package/dist/leetcode/priority-queue.mjs +0 -363
  239. package/dist/leetcode/queue.mjs +0 -943
  240. package/dist/leetcode/red-black-tree.mjs +0 -2765
  241. package/dist/leetcode/singly-linked-list.mjs +0 -754
  242. package/dist/leetcode/stack.mjs +0 -217
  243. package/dist/leetcode/tree-counter.mjs +0 -3039
  244. package/dist/leetcode/tree-multi-map.mjs +0 -2913
  245. package/dist/leetcode/trie.mjs +0 -413
  246. package/dist/leetcode/undirected-graph.mjs +0 -1650
@@ -0,0 +1,1708 @@
1
+ [**data-structure-typed**](../README.md)
2
+
3
+ ***
4
+
5
+ [data-structure-typed](../README.md) / Trie
6
+
7
+ # Class: Trie\<R\>
8
+
9
+ Defined in: [data-structures/trie/trie.ts:216](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L216)
10
+
11
+ Prefix tree (Trie) for fast prefix queries and word storage.
12
+
13
+ ## Remarks
14
+
15
+ Time O(1), Space O(1)
16
+
17
+ ## Examples
18
+
19
+ ```ts
20
+ // Trie isPrefix and isAbsolutePrefix checks
21
+ const trie = new Trie(['tree', 'trial', 'trick', 'trip', 'trie']);
22
+
23
+ // Check if string is a prefix of any word
24
+ console.log(trie.hasPrefix('tri')); // true;
25
+ console.log(trie.hasPrefix('tr')); // true;
26
+ console.log(trie.hasPrefix('xyz')); // false;
27
+
28
+ // Check if string is an absolute prefix (not a complete word)
29
+ console.log(trie.hasPurePrefix('tri')); // true;
30
+ console.log(trie.hasPurePrefix('tree')); // false; // 'tree' is a complete word
31
+
32
+ // Verify size
33
+ console.log(trie.size); // 5;
34
+ ```
35
+
36
+ ```ts
37
+ // Trie for autocomplete search index
38
+ // Trie is perfect for autocomplete: O(m + k) where m is prefix length, k is results
39
+ const searchIndex = new Trie(['typescript', 'javascript', 'python', 'java', 'rust', 'ruby', 'golang', 'kotlin']);
40
+
41
+ // User types 'j' - get all suggestions
42
+ const jResults = searchIndex.getWords('j');
43
+ console.log(jResults); // contains 'javascript';
44
+ console.log(jResults); // contains 'java';
45
+ console.log(jResults.length); // 2;
46
+
47
+ // User types 'ja' - get more specific suggestions
48
+ const jaResults = searchIndex.getWords('ja');
49
+ console.log(jaResults); // contains 'javascript';
50
+ console.log(jaResults); // contains 'java';
51
+ console.log(jaResults.length); // 2;
52
+
53
+ // User types 'jav' - even more specific
54
+ const javResults = searchIndex.getWords('jav');
55
+ console.log(javResults); // contains 'javascript';
56
+ console.log(javResults); // contains 'java';
57
+ console.log(javResults.length); // 2;
58
+
59
+ // Check for common prefix
60
+
61
+ console.log(searchIndex.hasCommonPrefix('ja')); // false; // Not all words start with 'ja'
62
+
63
+ // Total words in index
64
+ console.log(searchIndex.size); // 8;
65
+
66
+ // Get height (depth of tree)
67
+ const height = searchIndex.getHeight();
68
+ console.log(typeof height); // 'number';
69
+ ```
70
+
71
+ ```ts
72
+ // Dictionary: Case-insensitive word lookup
73
+ // Create a case-insensitive dictionary
74
+ const dictionary = new Trie<string>([], { caseSensitive: false });
75
+
76
+ // Add words with mixed casing
77
+ dictionary.add('Hello');
78
+ dictionary.add('WORLD');
79
+ dictionary.add('JavaScript');
80
+
81
+ // Test lookups with different casings
82
+ console.log(dictionary.has('hello')); // true;
83
+ console.log(dictionary.has('HELLO')); // true;
84
+ console.log(dictionary.has('Hello')); // true;
85
+ console.log(dictionary.has('javascript')); // true;
86
+ console.log(dictionary.has('JAVASCRIPT')); // true;
87
+ ```
88
+
89
+ ```ts
90
+ // File System Path Operations
91
+ const fileSystem = new Trie<string>([
92
+ '/home/user/documents/file1.txt',
93
+ '/home/user/documents/file2.txt',
94
+ '/home/user/pictures/photo.jpg',
95
+ '/home/user/pictures/vacation/',
96
+ '/home/user/downloads'
97
+ ]);
98
+
99
+ // Find common directory prefix
100
+ console.log(fileSystem.getLongestCommonPrefix()); // '/home/user/';
101
+
102
+ // List all files in a directory
103
+ const documentsFiles = fileSystem.getWords('/home/user/documents/');
104
+ console.log(documentsFiles); // ['/home/user/documents/file1.txt', '/home/user/documents/file2.txt'];
105
+ ```
106
+
107
+ ```ts
108
+ // IP Address Routing Table
109
+ // Add IP address prefixes and their corresponding routes
110
+ const routes = {
111
+ '192.168.1': 'LAN_SUBNET_1',
112
+ '192.168.2': 'LAN_SUBNET_2',
113
+ '10.0.0': 'PRIVATE_NETWORK_1',
114
+ '10.0.1': 'PRIVATE_NETWORK_2'
115
+ };
116
+
117
+ const ipRoutingTable = new Trie<string>(Object.keys(routes));
118
+
119
+ // Check IP address prefix matching
120
+ console.log(ipRoutingTable.hasPrefix('192.168.1')); // true;
121
+ console.log(ipRoutingTable.hasPrefix('192.168.2')); // true;
122
+
123
+ // Validate IP address belongs to subnet
124
+ const ip = '192.168.1.100';
125
+ const subnet = ip.split('.').slice(0, 3).join('.');
126
+ console.log(ipRoutingTable.hasPrefix(subnet)); // true;
127
+ ```
128
+
129
+ ## Extends
130
+
131
+ - [`IterableElementBase`](IterableElementBase.md)\<`string`, `R`\>
132
+
133
+ ## Type Parameters
134
+
135
+ ### R
136
+
137
+ `R` = `any`
138
+
139
+ 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.
140
+ 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'.
141
+ 3. Fast Retrieval: Trie allows retrieval in O(m) time complexity, where m is the length of the string to be searched.
142
+ 4. Space Efficiency: Trie can store a large number of strings very space-efficiently, especially when these strings share common prefixes.
143
+ 5. Autocomplete and Prediction: Trie can be used for implementing autocomplete and word prediction features, as it can quickly find all strings with a common prefix.
144
+ 6. Sorting: Trie can be used to sort a set of strings in alphabetical order.
145
+ 7. String Retrieval: For example, searching for a specific string in a large set of strings.
146
+ 8. Autocomplete: Providing recommended words or phrases as a user types.
147
+ 9. Spell Check: Checking the spelling of words.
148
+ 10. IP Routing: Used in certain types of IP routing algorithms.
149
+ 11. Text Word Frequency Count: Counting and storing the frequency of words in a large amount of text data.
150
+
151
+ ## Constructors
152
+
153
+ ### Constructor
154
+
155
+ ```ts
156
+ new Trie<R>(words?, options?): Trie<R>;
157
+ ```
158
+
159
+ Defined in: [data-structures/trie/trie.ts:225](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L225)
160
+
161
+ Create a Trie and optionally bulk-insert words.
162
+
163
+ #### Parameters
164
+
165
+ ##### words?
166
+
167
+ `Iterable`\<`string`, `any`, `any`\> \| `Iterable`\<`R`, `any`, `any`\>
168
+
169
+ Iterable of strings (or raw records if toElementFn is provided).
170
+
171
+ ##### options?
172
+
173
+ `TrieOptions`\<`R`\>
174
+
175
+ Options such as toElementFn and caseSensitive.
176
+
177
+ #### Returns
178
+
179
+ `Trie`\<`R`\>
180
+
181
+ New Trie instance.
182
+
183
+ #### Remarks
184
+
185
+ Time O(totalChars), Space O(totalChars)
186
+
187
+ #### Overrides
188
+
189
+ [`IterableElementBase`](IterableElementBase.md).[`constructor`](IterableElementBase.md#constructor)
190
+
191
+ ## Properties
192
+
193
+ ### caseSensitive
194
+
195
+ #### Get Signature
196
+
197
+ ```ts
198
+ get caseSensitive(): boolean;
199
+ ```
200
+
201
+ Defined in: [data-structures/trie/trie.ts:256](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L256)
202
+
203
+ Get whether comparisons are case-sensitive.
204
+
205
+ ##### Remarks
206
+
207
+ Time O(1), Space O(1)
208
+
209
+ ##### Returns
210
+
211
+ `boolean`
212
+
213
+ True if case-sensitive.
214
+
215
+ ***
216
+
217
+ ### root
218
+
219
+ #### Get Signature
220
+
221
+ ```ts
222
+ get root(): TrieNode;
223
+ ```
224
+
225
+ Defined in: [data-structures/trie/trie.ts:268](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L268)
226
+
227
+ Get the root node.
228
+
229
+ ##### Remarks
230
+
231
+ Time O(1), Space O(1)
232
+
233
+ ##### Returns
234
+
235
+ [`TrieNode`](TrieNode.md)
236
+
237
+ Root TrieNode.
238
+
239
+ ***
240
+
241
+ ### size
242
+
243
+ #### Get Signature
244
+
245
+ ```ts
246
+ get size(): number;
247
+ ```
248
+
249
+ Defined in: [data-structures/trie/trie.ts:244](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L244)
250
+
251
+ Get the number of stored words.
252
+
253
+ ##### Remarks
254
+
255
+ Time O(1), Space O(1)
256
+
257
+ ##### Returns
258
+
259
+ `number`
260
+
261
+ Word count.
262
+
263
+ ***
264
+
265
+ ### toElementFn
266
+
267
+ #### Get Signature
268
+
269
+ ```ts
270
+ get toElementFn(): ((rawElement) => E) | undefined;
271
+ ```
272
+
273
+ Defined in: [data-structures/base/iterable-element-base.ts:48](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L48)
274
+
275
+ Exposes the current `toElementFn`, if configured.
276
+
277
+ ##### Remarks
278
+
279
+ Time O(1), Space O(1).
280
+
281
+ ##### Returns
282
+
283
+ ((`rawElement`) => `E`) \| `undefined`
284
+
285
+ The converter function or `undefined` when not set.
286
+
287
+ #### Inherited from
288
+
289
+ [`IterableElementBase`](IterableElementBase.md).[`toElementFn`](IterableElementBase.md#toelementfn)
290
+
291
+ ## Methods
292
+
293
+ ### \[iterator\]()
294
+
295
+ ```ts
296
+ iterator: IterableIterator<string>;
297
+ ```
298
+
299
+ Defined in: [data-structures/base/iterable-element-base.ts:61](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L61)
300
+
301
+ Returns an iterator over the structure's elements.
302
+
303
+ #### Parameters
304
+
305
+ ##### args
306
+
307
+ ...`unknown`[]
308
+
309
+ Optional iterator arguments forwarded to the internal iterator.
310
+
311
+ #### Returns
312
+
313
+ `IterableIterator`\<`string`\>
314
+
315
+ An `IterableIterator<E>` that yields the elements in traversal order.
316
+
317
+ #### Remarks
318
+
319
+ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with O(1) extra space.
320
+
321
+ #### Inherited from
322
+
323
+ [`IterableElementBase`](IterableElementBase.md).[`[iterator]`](IterableElementBase.md#iterator)
324
+
325
+ ***
326
+
327
+ ### add()
328
+
329
+ ```ts
330
+ add(word): boolean;
331
+ ```
332
+
333
+ Defined in: [data-structures/trie/trie.ts:339](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L339)
334
+
335
+ Insert one word into the trie.
336
+
337
+ #### Parameters
338
+
339
+ ##### word
340
+
341
+ `string`
342
+
343
+ Word to insert.
344
+
345
+ #### Returns
346
+
347
+ `boolean`
348
+
349
+ True if the word was newly added.
350
+
351
+ *
352
+
353
+ #### Remarks
354
+
355
+ Time O(L), Space O(L)
356
+
357
+ #### Example
358
+
359
+ ```ts
360
+ // basic Trie creation and add words
361
+ // Create a simple Trie with initial words
362
+ const trie = new Trie(['apple', 'app', 'apply']);
363
+
364
+ // Verify size
365
+ console.log(trie.size); // 3;
366
+
367
+ // Check if words exist
368
+ console.log(trie.has('apple')); // true;
369
+ console.log(trie.has('app')); // true;
370
+
371
+ // Add a new word
372
+ trie.add('application');
373
+ console.log(trie.size); // 4;
374
+ ```
375
+
376
+ ***
377
+
378
+ ### addMany()
379
+
380
+ ```ts
381
+ addMany(words): boolean[];
382
+ ```
383
+
384
+ Defined in: [data-structures/trie/trie.ts:405](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L405)
385
+
386
+ Insert many words from an iterable.
387
+
388
+ #### Parameters
389
+
390
+ ##### words
391
+
392
+ `Iterable`\<`string`, `any`, `any`\> \| `Iterable`\<`R`, `any`, `any`\>
393
+
394
+ Iterable of strings (or raw records if toElementFn is provided).
395
+
396
+ #### Returns
397
+
398
+ `boolean`[]
399
+
400
+ Array of per-word 'added' flags.
401
+
402
+ *
403
+
404
+ #### Remarks
405
+
406
+ Time O(ΣL), Space O(ΣL)
407
+
408
+ #### Example
409
+
410
+ ```ts
411
+ // Add multiple words
412
+ const trie = new Trie();
413
+ trie.addMany(['cat', 'car', 'card']);
414
+ console.log(trie.has('cat')); // true;
415
+ console.log(trie.has('car')); // true;
416
+ console.log(trie.size); // 3;
417
+ ```
418
+
419
+ ***
420
+
421
+ ### clear()
422
+
423
+ ```ts
424
+ clear(): void;
425
+ ```
426
+
427
+ Defined in: [data-structures/trie/trie.ts:568](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L568)
428
+
429
+ Remove all words and reset to a fresh root.
430
+
431
+ #### Returns
432
+
433
+ `void`
434
+
435
+ void
436
+
437
+ *
438
+
439
+ #### Remarks
440
+
441
+ Time O(1), Space O(1)
442
+
443
+ #### Example
444
+
445
+ ```ts
446
+ // Remove all words
447
+ const trie = new Trie(['a', 'b', 'c']);
448
+ trie.clear();
449
+ console.log(trie.isEmpty()); // true;
450
+ ```
451
+
452
+ #### Overrides
453
+
454
+ [`IterableElementBase`](IterableElementBase.md).[`clear`](IterableElementBase.md#clear)
455
+
456
+ ***
457
+
458
+ ### clone()
459
+
460
+ ```ts
461
+ clone(): this;
462
+ ```
463
+
464
+ Defined in: [data-structures/trie/trie.ts:985](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L985)
465
+
466
+ Deep clone this trie by iterating and inserting all words.
467
+
468
+ #### Returns
469
+
470
+ `this`
471
+
472
+ A new trie with the same words and options.
473
+
474
+ *
475
+
476
+ #### Remarks
477
+
478
+ Time O(ΣL), Space O(ΣL)
479
+
480
+ #### Example
481
+
482
+ ```ts
483
+ // Create independent copy
484
+ const trie = new Trie(['hello', 'world']);
485
+ const copy = trie.clone();
486
+ copy.delete('hello');
487
+ console.log(trie.has('hello')); // true;
488
+ ```
489
+
490
+ #### Overrides
491
+
492
+ [`IterableElementBase`](IterableElementBase.md).[`clone`](IterableElementBase.md#clone)
493
+
494
+ ***
495
+
496
+ ### delete()
497
+
498
+ ```ts
499
+ delete(word): boolean;
500
+ ```
501
+
502
+ Defined in: [data-structures/trie/trie.ts:632](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L632)
503
+
504
+ Delete one word if present.
505
+
506
+ #### Parameters
507
+
508
+ ##### word
509
+
510
+ `string`
511
+
512
+ Word to delete.
513
+
514
+ #### Returns
515
+
516
+ `boolean`
517
+
518
+ True if a word was removed.
519
+
520
+ *
521
+
522
+ #### Remarks
523
+
524
+ Time O(L), Space O(1)
525
+
526
+ #### Example
527
+
528
+ ```ts
529
+ // Trie delete and iteration
530
+ const trie = new Trie(['car', 'card', 'care', 'careful', 'can', 'cat']);
531
+
532
+ // Delete a word
533
+ trie.delete('card');
534
+ console.log(trie.has('card')); // false;
535
+
536
+ // Word with same prefix still exists
537
+ console.log(trie.has('care')); // true;
538
+
539
+ // Size decreased
540
+ console.log(trie.size); // 5;
541
+
542
+ // Iterate through all words
543
+ const allWords = [...trie];
544
+ console.log(allWords.length); // 5;
545
+ ```
546
+
547
+ ***
548
+
549
+ ### every()
550
+
551
+ ```ts
552
+ every(predicate, thisArg?): boolean;
553
+ ```
554
+
555
+ Defined in: [data-structures/base/iterable-element-base.ts:87](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L87)
556
+
557
+ Tests whether all elements satisfy the predicate.
558
+
559
+ #### Parameters
560
+
561
+ ##### predicate
562
+
563
+ `ElementCallback`\<`string`, `R`, `boolean`\>
564
+
565
+ Function invoked for each element with signature `(value, index, self)`.
566
+
567
+ ##### thisArg?
568
+
569
+ `unknown`
570
+
571
+ Optional `this` binding for the predicate.
572
+
573
+ #### Returns
574
+
575
+ `boolean`
576
+
577
+ `true` if every element passes; otherwise `false`.
578
+
579
+ #### Remarks
580
+
581
+ Time O(n) in the worst case; may exit early when the first failure is found. Space O(1).
582
+
583
+ #### Inherited from
584
+
585
+ [`IterableElementBase`](IterableElementBase.md).[`every`](IterableElementBase.md#every)
586
+
587
+ ***
588
+
589
+ ### filter()
590
+
591
+ ```ts
592
+ filter(predicate, thisArg?): this;
593
+ ```
594
+
595
+ Defined in: [data-structures/trie/trie.ts:1036](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L1036)
596
+
597
+ Filter words into a new trie of the same class.
598
+
599
+ #### Parameters
600
+
601
+ ##### predicate
602
+
603
+ `ElementCallback`\<`string`, `R`, `boolean`\>
604
+
605
+ Predicate (word, index, trie) → boolean to keep word.
606
+
607
+ ##### thisArg?
608
+
609
+ `unknown`
610
+
611
+ Value for `this` inside the predicate.
612
+
613
+ #### Returns
614
+
615
+ `this`
616
+
617
+ A new trie containing words that satisfy the predicate.
618
+
619
+ *
620
+
621
+ #### Remarks
622
+
623
+ Time O(ΣL), Space O(ΣL)
624
+
625
+ #### Example
626
+
627
+ ```ts
628
+ // Filter words
629
+ const trie = new Trie(['cat', 'car', 'dog', 'card']);
630
+ const result = trie.filter(w => w.startsWith('ca'));
631
+ console.log(result.size); // 3;
632
+ ```
633
+
634
+ #### Overrides
635
+
636
+ [`IterableElementBase`](IterableElementBase.md).[`filter`](IterableElementBase.md#filter)
637
+
638
+ ***
639
+
640
+ ### find()
641
+
642
+ #### Call Signature
643
+
644
+ ```ts
645
+ find<S>(predicate, thisArg?): S | undefined;
646
+ ```
647
+
648
+ Defined in: [data-structures/base/iterable-element-base.ts:163](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L163)
649
+
650
+ Finds the first element that satisfies the predicate and returns it.
651
+
652
+ Finds the first element of type `S` (a subtype of `E`) that satisfies the predicate and returns it.
653
+
654
+ ##### Type Parameters
655
+
656
+ ###### S
657
+
658
+ `S` *extends* `string`
659
+
660
+ ##### Parameters
661
+
662
+ ###### predicate
663
+
664
+ `ElementCallback`\<`string`, `R`, `S`\>
665
+
666
+ Type-guard predicate: `(value, index, self) => value is S`.
667
+
668
+ ###### thisArg?
669
+
670
+ `unknown`
671
+
672
+ Optional `this` binding for the predicate.
673
+
674
+ ##### Returns
675
+
676
+ `S` \| `undefined`
677
+
678
+ The matched element typed as `S`, or `undefined` if not found.
679
+
680
+ ##### Remarks
681
+
682
+ Time O(n) in the worst case; may exit early on the first match. Space O(1).
683
+
684
+ ##### Inherited from
685
+
686
+ [`IterableElementBase`](IterableElementBase.md).[`find`](IterableElementBase.md#find)
687
+
688
+ #### Call Signature
689
+
690
+ ```ts
691
+ find(predicate, thisArg?): string | undefined;
692
+ ```
693
+
694
+ Defined in: [data-structures/base/iterable-element-base.ts:164](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L164)
695
+
696
+ Finds the first element that satisfies the predicate and returns it.
697
+
698
+ Finds the first element of type `S` (a subtype of `E`) that satisfies the predicate and returns it.
699
+
700
+ ##### Parameters
701
+
702
+ ###### predicate
703
+
704
+ `ElementCallback`\<`string`, `R`, `unknown`\>
705
+
706
+ Type-guard predicate: `(value, index, self) => value is S`.
707
+
708
+ ###### thisArg?
709
+
710
+ `unknown`
711
+
712
+ Optional `this` binding for the predicate.
713
+
714
+ ##### Returns
715
+
716
+ `string` \| `undefined`
717
+
718
+ The matched element typed as `S`, or `undefined` if not found.
719
+
720
+ ##### Remarks
721
+
722
+ Time O(n) in the worst case; may exit early on the first match. Space O(1).
723
+
724
+ ##### Inherited from
725
+
726
+ [`IterableElementBase`](IterableElementBase.md).[`find`](IterableElementBase.md#find)
727
+
728
+ ***
729
+
730
+ ### forEach()
731
+
732
+ ```ts
733
+ forEach(callbackfn, thisArg?): void;
734
+ ```
735
+
736
+ Defined in: [data-structures/base/iterable-element-base.ts:133](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L133)
737
+
738
+ Invokes a callback for each element in iteration order.
739
+
740
+ #### Parameters
741
+
742
+ ##### callbackfn
743
+
744
+ `ElementCallback`\<`string`, `R`, `void`\>
745
+
746
+ Function invoked per element with signature `(value, index, self)`.
747
+
748
+ ##### thisArg?
749
+
750
+ `unknown`
751
+
752
+ Optional `this` binding for the callback.
753
+
754
+ #### Returns
755
+
756
+ `void`
757
+
758
+ `void`.
759
+
760
+ #### Remarks
761
+
762
+ Time O(n), Space O(1).
763
+
764
+ #### Inherited from
765
+
766
+ [`IterableElementBase`](IterableElementBase.md).[`forEach`](IterableElementBase.md#foreach)
767
+
768
+ ***
769
+
770
+ ### getHeight()
771
+
772
+ ```ts
773
+ getHeight(): number;
774
+ ```
775
+
776
+ Defined in: [data-structures/trie/trie.ts:674](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L674)
777
+
778
+ Compute the height (max depth) of the trie.
779
+
780
+ #### Returns
781
+
782
+ `number`
783
+
784
+ Maximum depth from root to a leaf.
785
+
786
+ #### Remarks
787
+
788
+ Time O(N), Space O(H)
789
+
790
+ ***
791
+
792
+ ### getLongestCommonPrefix()
793
+
794
+ ```ts
795
+ getLongestCommonPrefix(): string;
796
+ ```
797
+
798
+ Defined in: [data-structures/trie/trie.ts:839](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L839)
799
+
800
+ Return the longest common prefix among all words.
801
+
802
+ #### Returns
803
+
804
+ `string`
805
+
806
+ The longest common prefix string.
807
+
808
+ *
809
+
810
+ #### Remarks
811
+
812
+ Time O(H), Space O(1)
813
+
814
+ #### Example
815
+
816
+ ```ts
817
+ // Find shared prefix
818
+ const trie = new Trie(['flower', 'flow', 'flight']);
819
+
820
+ console.log(trie.getLongestCommonPrefix()); // 'fl';
821
+ ```
822
+
823
+ ***
824
+
825
+ ### getWords()
826
+
827
+ ```ts
828
+ getWords(
829
+ prefix?,
830
+ max?,
831
+ isAllWhenEmptyPrefix?): string[];
832
+ ```
833
+
834
+ Defined in: [data-structures/trie/trie.ts:906](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L906)
835
+
836
+ Collect words under a prefix up to a maximum count.
837
+
838
+ #### Parameters
839
+
840
+ ##### prefix?
841
+
842
+ `string` = `''`
843
+
844
+ Prefix to match; default empty string for root.
845
+
846
+ ##### max?
847
+
848
+ `number` = `Number.MAX_SAFE_INTEGER`
849
+
850
+ Maximum number of words to return; default is Number.MAX_SAFE_INTEGER.
851
+
852
+ ##### isAllWhenEmptyPrefix?
853
+
854
+ `boolean` = `false`
855
+
856
+ When true, collect from root even if prefix is empty.
857
+
858
+ #### Returns
859
+
860
+ `string`[]
861
+
862
+ Array of collected words (at most max).
863
+
864
+ *
865
+
866
+ #### Remarks
867
+
868
+ Time O(K·L), Space O(K·L)
869
+
870
+ #### Example
871
+
872
+ ```ts
873
+ // Trie getWords and prefix search
874
+ const trie = new Trie(['apple', 'app', 'apply', 'application', 'apricot']);
875
+
876
+ // Get all words with prefix 'app'
877
+ const appWords = trie.getWords('app');
878
+ console.log(appWords); // contains 'app';
879
+ console.log(appWords); // contains 'apple';
880
+ console.log(appWords); // contains 'apply';
881
+ console.log(appWords); // contains 'application';
882
+ expect(appWords).not.toContain('apricot');
883
+ ```
884
+
885
+ ***
886
+
887
+ ### has()
888
+
889
+ ```ts
890
+ has(word): boolean;
891
+ ```
892
+
893
+ Defined in: [data-structures/trie/trie.ts:466](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L466)
894
+
895
+ Check whether a word exists.
896
+
897
+ #### Parameters
898
+
899
+ ##### word
900
+
901
+ `string`
902
+
903
+ Word to search for.
904
+
905
+ #### Returns
906
+
907
+ `boolean`
908
+
909
+ True if present.
910
+
911
+ *
912
+
913
+ #### Remarks
914
+
915
+ Time O(L), Space O(1)
916
+
917
+ #### Example
918
+
919
+ ```ts
920
+ // Check if a word exists
921
+ const dict = new Trie(['apple', 'app', 'application']);
922
+
923
+ console.log(dict.has('app')); // true;
924
+ console.log(dict.has('apple')); // true;
925
+ console.log(dict.has('ap')); // false;
926
+ ```
927
+
928
+ #### Overrides
929
+
930
+ [`IterableElementBase`](IterableElementBase.md).[`has`](IterableElementBase.md#has)
931
+
932
+ ***
933
+
934
+ ### hasCommonPrefix()
935
+
936
+ ```ts
937
+ hasCommonPrefix(input): boolean;
938
+ ```
939
+
940
+ Defined in: [data-structures/trie/trie.ts:779](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L779)
941
+
942
+ Check whether the trie’s longest common prefix equals input.
943
+
944
+ #### Parameters
945
+
946
+ ##### input
947
+
948
+ `string`
949
+
950
+ Candidate longest common prefix.
951
+
952
+ #### Returns
953
+
954
+ `boolean`
955
+
956
+ True if input equals the common prefix.
957
+
958
+ #### Remarks
959
+
960
+ Time O(min(H,L)), Space O(1)
961
+
962
+ ***
963
+
964
+ ### hasPrefix()
965
+
966
+ ```ts
967
+ hasPrefix(input): boolean;
968
+ ```
969
+
970
+ Defined in: [data-structures/trie/trie.ts:761](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L761)
971
+
972
+ Check whether any word starts with input.
973
+
974
+ #### Parameters
975
+
976
+ ##### input
977
+
978
+ `string`
979
+
980
+ String to test as prefix.
981
+
982
+ #### Returns
983
+
984
+ `boolean`
985
+
986
+ True if input matches a path from root.
987
+
988
+ *
989
+
990
+ #### Remarks
991
+
992
+ Time O(L), Space O(1)
993
+
994
+ #### Example
995
+
996
+ ```ts
997
+ // Check if a prefix exists
998
+ const trie = new Trie(['hello', 'help', 'world']);
999
+
1000
+ console.log(trie.hasPrefix('hel')); // true;
1001
+ console.log(trie.hasPrefix('wor')); // true;
1002
+ console.log(trie.hasPrefix('xyz')); // false;
1003
+ ```
1004
+
1005
+ ***
1006
+
1007
+ ### hasPurePrefix()
1008
+
1009
+ ```ts
1010
+ hasPurePrefix(input): boolean;
1011
+ ```
1012
+
1013
+ Defined in: [data-structures/trie/trie.ts:701](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L701)
1014
+
1015
+ Check whether input is a proper prefix of at least one word.
1016
+
1017
+ #### Parameters
1018
+
1019
+ ##### input
1020
+
1021
+ `string`
1022
+
1023
+ String to test as prefix.
1024
+
1025
+ #### Returns
1026
+
1027
+ `boolean`
1028
+
1029
+ True if input is a prefix but not a full word.
1030
+
1031
+ #### Remarks
1032
+
1033
+ Time O(L), Space O(1)
1034
+
1035
+ ***
1036
+
1037
+ ### isEmpty()
1038
+
1039
+ ```ts
1040
+ isEmpty(): boolean;
1041
+ ```
1042
+
1043
+ Defined in: [data-structures/trie/trie.ts:521](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L521)
1044
+
1045
+ Check whether the trie is empty.
1046
+
1047
+ #### Returns
1048
+
1049
+ `boolean`
1050
+
1051
+ True if size is 0.
1052
+
1053
+ *
1054
+
1055
+ #### Remarks
1056
+
1057
+ Time O(1), Space O(1)
1058
+
1059
+ #### Example
1060
+
1061
+ ```ts
1062
+ // Check if empty
1063
+ const trie = new Trie();
1064
+ console.log(trie.isEmpty()); // true;
1065
+ trie.add('word');
1066
+ console.log(trie.isEmpty()); // false;
1067
+ ```
1068
+
1069
+ #### Overrides
1070
+
1071
+ [`IterableElementBase`](IterableElementBase.md).[`isEmpty`](IterableElementBase.md#isempty)
1072
+
1073
+ ***
1074
+
1075
+ ### map()
1076
+
1077
+ #### Call Signature
1078
+
1079
+ ```ts
1080
+ map<RM>(
1081
+ callback,
1082
+ options?,
1083
+ thisArg?): Trie<RM>;
1084
+ ```
1085
+
1086
+ Defined in: [data-structures/trie/trie.ts:1088](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L1088)
1087
+
1088
+ Transform words
1089
+
1090
+ *
1091
+
1092
+ ##### Type Parameters
1093
+
1094
+ ###### RM
1095
+
1096
+ `RM`
1097
+
1098
+ ##### Parameters
1099
+
1100
+ ###### callback
1101
+
1102
+ `ElementCallback`\<`string`, `R`, `string`\>
1103
+
1104
+ ###### options?
1105
+
1106
+ `TrieOptions`\<`RM`\>
1107
+
1108
+ ###### thisArg?
1109
+
1110
+ `unknown`
1111
+
1112
+ ##### Returns
1113
+
1114
+ `Trie`\<`RM`\>
1115
+
1116
+ ##### Example
1117
+
1118
+ ```ts
1119
+ // Transform words
1120
+ const trie = new Trie(['hello', 'world']);
1121
+ const upper = trie.map(w => w.toUpperCase());
1122
+ console.log(upper.has('HELLO')); // true;
1123
+ ```
1124
+
1125
+ ##### Overrides
1126
+
1127
+ [`IterableElementBase`](IterableElementBase.md).[`map`](IterableElementBase.md#map)
1128
+
1129
+ #### Call Signature
1130
+
1131
+ ```ts
1132
+ map<EM, RM>(
1133
+ callback,
1134
+ options?,
1135
+ thisArg?): IterableElementBase<EM, RM>;
1136
+ ```
1137
+
1138
+ Defined in: [data-structures/trie/trie.ts:1101](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L1101)
1139
+
1140
+ Map words into a new trie (possibly different record type).
1141
+
1142
+ ##### Type Parameters
1143
+
1144
+ ###### EM
1145
+
1146
+ `EM`
1147
+
1148
+ ###### RM
1149
+
1150
+ `RM`
1151
+
1152
+ ##### Parameters
1153
+
1154
+ ###### callback
1155
+
1156
+ `ElementCallback`\<`string`, `R`, `EM`\>
1157
+
1158
+ Mapping function (word, index, trie) → newWord (string).
1159
+
1160
+ ###### options?
1161
+
1162
+ `TrieOptions`\<`RM`\>
1163
+
1164
+ Options for the output trie (e.g., toElementFn, caseSensitive).
1165
+
1166
+ ###### thisArg?
1167
+
1168
+ `unknown`
1169
+
1170
+ Value for `this` inside the callback.
1171
+
1172
+ ##### Returns
1173
+
1174
+ [`IterableElementBase`](IterableElementBase.md)\<`EM`, `RM`\>
1175
+
1176
+ A new Trie constructed from mapped words.
1177
+
1178
+ ##### Remarks
1179
+
1180
+ Time O(ΣL), Space O(ΣL)
1181
+
1182
+ ##### Overrides
1183
+
1184
+ ```ts
1185
+ IterableElementBase.map
1186
+ ```
1187
+
1188
+ ***
1189
+
1190
+ ### mapSame()
1191
+
1192
+ ```ts
1193
+ mapSame(callback, thisArg?): this;
1194
+ ```
1195
+
1196
+ Defined in: [data-structures/trie/trie.ts:1128](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L1128)
1197
+
1198
+ Map words into a new trie of the same element type.
1199
+
1200
+ #### Parameters
1201
+
1202
+ ##### callback
1203
+
1204
+ `ElementCallback`\<`string`, `R`, `string`\>
1205
+
1206
+ Mapping function (word, index, trie) → string.
1207
+
1208
+ ##### thisArg?
1209
+
1210
+ `unknown`
1211
+
1212
+ Value for `this` inside the callback.
1213
+
1214
+ #### Returns
1215
+
1216
+ `this`
1217
+
1218
+ A new trie with mapped words.
1219
+
1220
+ #### Remarks
1221
+
1222
+ Time O(ΣL), Space O(ΣL)
1223
+
1224
+ #### Overrides
1225
+
1226
+ [`IterableElementBase`](IterableElementBase.md).[`mapSame`](IterableElementBase.md#mapsame)
1227
+
1228
+ ***
1229
+
1230
+ ### print()
1231
+
1232
+ ```ts
1233
+ print(): void;
1234
+ ```
1235
+
1236
+ Defined in: [data-structures/base/iterable-element-base.ts:269](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L269)
1237
+
1238
+ Prints `toVisual()` to the console. Intended for quick debugging.
1239
+
1240
+ #### Returns
1241
+
1242
+ `void`
1243
+
1244
+ `void`.
1245
+
1246
+ #### Remarks
1247
+
1248
+ Time O(n) due to materialization, Space O(n) for the intermediate representation.
1249
+
1250
+ #### Inherited from
1251
+
1252
+ [`IterableElementBase`](IterableElementBase.md).[`print`](IterableElementBase.md#print)
1253
+
1254
+ ***
1255
+
1256
+ ### reduce()
1257
+
1258
+ Reduces all elements to a single accumulated value.
1259
+
1260
+ #### Param
1261
+
1262
+ Reducer of signature `(acc, value, index, self) => nextAcc`. The first element is used as the initial accumulator.
1263
+
1264
+ #### Param
1265
+
1266
+ Reducer of signature `(acc, value, index, self) => nextAcc`.
1267
+
1268
+ #### Param
1269
+
1270
+ The initial accumulator value of type `E`.
1271
+
1272
+ #### Template
1273
+
1274
+ The accumulator type when it differs from `E`.
1275
+
1276
+ #### Param
1277
+
1278
+ Reducer of signature `(acc: U, value, index, self) => U`.
1279
+
1280
+ #### Param
1281
+
1282
+ The initial accumulator value of type `U`.
1283
+
1284
+ #### Remarks
1285
+
1286
+ Time O(n), Space O(1). Throws if called on an empty structure without `initialValue`.
1287
+
1288
+ #### Call Signature
1289
+
1290
+ ```ts
1291
+ reduce(callbackfn): string;
1292
+ ```
1293
+
1294
+ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L194)
1295
+
1296
+ ##### Parameters
1297
+
1298
+ ###### callbackfn
1299
+
1300
+ `ReduceElementCallback`\<`string`, `R`\>
1301
+
1302
+ ##### Returns
1303
+
1304
+ `string`
1305
+
1306
+ ##### Inherited from
1307
+
1308
+ [`IterableElementBase`](IterableElementBase.md).[`reduce`](IterableElementBase.md#reduce)
1309
+
1310
+ #### Call Signature
1311
+
1312
+ ```ts
1313
+ reduce(callbackfn, initialValue): string;
1314
+ ```
1315
+
1316
+ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L195)
1317
+
1318
+ ##### Parameters
1319
+
1320
+ ###### callbackfn
1321
+
1322
+ `ReduceElementCallback`\<`string`, `R`\>
1323
+
1324
+ ###### initialValue
1325
+
1326
+ `string`
1327
+
1328
+ ##### Returns
1329
+
1330
+ `string`
1331
+
1332
+ ##### Inherited from
1333
+
1334
+ [`IterableElementBase`](IterableElementBase.md).[`reduce`](IterableElementBase.md#reduce)
1335
+
1336
+ #### Call Signature
1337
+
1338
+ ```ts
1339
+ reduce<U>(callbackfn, initialValue): U;
1340
+ ```
1341
+
1342
+ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L196)
1343
+
1344
+ ##### Type Parameters
1345
+
1346
+ ###### U
1347
+
1348
+ `U`
1349
+
1350
+ ##### Parameters
1351
+
1352
+ ###### callbackfn
1353
+
1354
+ `ReduceElementCallback`\<`string`, `R`, `U`\>
1355
+
1356
+ ###### initialValue
1357
+
1358
+ `U`
1359
+
1360
+ ##### Returns
1361
+
1362
+ `U`
1363
+
1364
+ ##### Inherited from
1365
+
1366
+ [`IterableElementBase`](IterableElementBase.md).[`reduce`](IterableElementBase.md#reduce)
1367
+
1368
+ ***
1369
+
1370
+ ### some()
1371
+
1372
+ ```ts
1373
+ some(predicate, thisArg?): boolean;
1374
+ ```
1375
+
1376
+ Defined in: [data-structures/base/iterable-element-base.ts:110](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L110)
1377
+
1378
+ Tests whether at least one element satisfies the predicate.
1379
+
1380
+ #### Parameters
1381
+
1382
+ ##### predicate
1383
+
1384
+ `ElementCallback`\<`string`, `R`, `boolean`\>
1385
+
1386
+ Function invoked for each element with signature `(value, index, self)`.
1387
+
1388
+ ##### thisArg?
1389
+
1390
+ `unknown`
1391
+
1392
+ Optional `this` binding for the predicate.
1393
+
1394
+ #### Returns
1395
+
1396
+ `boolean`
1397
+
1398
+ `true` if any element passes; otherwise `false`.
1399
+
1400
+ #### Remarks
1401
+
1402
+ Time O(n) in the worst case; may exit early on first success. Space O(1).
1403
+
1404
+ #### Inherited from
1405
+
1406
+ [`IterableElementBase`](IterableElementBase.md).[`some`](IterableElementBase.md#some)
1407
+
1408
+ ***
1409
+
1410
+ ### toArray()
1411
+
1412
+ ```ts
1413
+ toArray(): string[];
1414
+ ```
1415
+
1416
+ Defined in: [data-structures/base/iterable-element-base.ts:246](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L246)
1417
+
1418
+ Materializes the elements into a new array.
1419
+
1420
+ #### Returns
1421
+
1422
+ `string`[]
1423
+
1424
+ A shallow array copy of the iteration order.
1425
+
1426
+ #### Remarks
1427
+
1428
+ Time O(n), Space O(n).
1429
+
1430
+ #### Inherited from
1431
+
1432
+ [`IterableElementBase`](IterableElementBase.md).[`toArray`](IterableElementBase.md#toarray)
1433
+
1434
+ ***
1435
+
1436
+ ### toVisual()
1437
+
1438
+ ```ts
1439
+ toVisual(): string[];
1440
+ ```
1441
+
1442
+ Defined in: [data-structures/base/iterable-element-base.ts:258](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L258)
1443
+
1444
+ Returns a representation of the structure suitable for quick visualization.
1445
+ Defaults to an array of elements; subclasses may override to provide richer visuals.
1446
+
1447
+ #### Returns
1448
+
1449
+ `string`[]
1450
+
1451
+ A visual representation (array by default).
1452
+
1453
+ #### Remarks
1454
+
1455
+ Time O(n), Space O(n).
1456
+
1457
+ #### Inherited from
1458
+
1459
+ [`IterableElementBase`](IterableElementBase.md).[`toVisual`](IterableElementBase.md#tovisual)
1460
+
1461
+ ***
1462
+
1463
+ ### values()
1464
+
1465
+ ```ts
1466
+ values(): IterableIterator<string>;
1467
+ ```
1468
+
1469
+ Defined in: [data-structures/base/iterable-element-base.ts:72](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L72)
1470
+
1471
+ Returns an iterator over the values (alias of the default iterator).
1472
+
1473
+ #### Returns
1474
+
1475
+ `IterableIterator`\<`string`\>
1476
+
1477
+ An `IterableIterator<E>` over all elements.
1478
+
1479
+ #### Remarks
1480
+
1481
+ Creating the iterator is O(1); full iteration is Time O(n), Space O(1).
1482
+
1483
+ #### Inherited from
1484
+
1485
+ [`IterableElementBase`](IterableElementBase.md).[`values`](IterableElementBase.md#values)
1486
+
1487
+
1488
+ ---
1489
+
1490
+ ## Protected Members
1491
+
1492
+ ### \_toElementFn?
1493
+
1494
+ ```ts
1495
+ protected optional _toElementFn?: (rawElement) => string;
1496
+ ```
1497
+
1498
+ Defined in: [data-structures/base/iterable-element-base.ts:39](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L39)
1499
+
1500
+ The converter used to transform a raw element (`R`) into a public element (`E`).
1501
+
1502
+ #### Parameters
1503
+
1504
+ ##### rawElement
1505
+
1506
+ `R`
1507
+
1508
+ #### Returns
1509
+
1510
+ `string`
1511
+
1512
+ #### Remarks
1513
+
1514
+ Time O(1), Space O(1).
1515
+
1516
+ #### Inherited from
1517
+
1518
+ [`IterableElementBase`](IterableElementBase.md).[`_toElementFn`](IterableElementBase.md#_toelementfn)
1519
+
1520
+ ## Accessors
1521
+
1522
+ ### \_total
1523
+
1524
+ #### Get Signature
1525
+
1526
+ ```ts
1527
+ get protected _total(): number;
1528
+ ```
1529
+
1530
+ Defined in: [data-structures/trie/trie.ts:278](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L278)
1531
+
1532
+ (Protected) Get total count for base class iteration.
1533
+
1534
+ ##### Remarks
1535
+
1536
+ Time O(1), Space O(1)
1537
+
1538
+ ##### Returns
1539
+
1540
+ `number`
1541
+
1542
+ Total number of elements.
1543
+
1544
+ ***
1545
+
1546
+ ### \_caseProcess()
1547
+
1548
+ ```ts
1549
+ protected _caseProcess(str): string;
1550
+ ```
1551
+
1552
+ Defined in: [data-structures/trie/trie.ts:1212](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L1212)
1553
+
1554
+ (Protected) Normalize a string according to case sensitivity.
1555
+
1556
+ #### Parameters
1557
+
1558
+ ##### str
1559
+
1560
+ `string`
1561
+
1562
+ Input string to normalize.
1563
+
1564
+ #### Returns
1565
+
1566
+ `string`
1567
+
1568
+ Normalized string based on caseSensitive.
1569
+
1570
+ #### Remarks
1571
+
1572
+ Time O(L), Space O(L)
1573
+
1574
+ ***
1575
+
1576
+ ### \_createInstance()
1577
+
1578
+ ```ts
1579
+ protected _createInstance(options?): this;
1580
+ ```
1581
+
1582
+ Defined in: [data-structures/trie/trie.ts:1145](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L1145)
1583
+
1584
+ (Protected) Create an empty instance of the same concrete class.
1585
+
1586
+ #### Parameters
1587
+
1588
+ ##### options?
1589
+
1590
+ `TrieOptions`\<`R`\>
1591
+
1592
+ Options forwarded to the constructor.
1593
+
1594
+ #### Returns
1595
+
1596
+ `this`
1597
+
1598
+ An empty like-kind trie instance.
1599
+
1600
+ #### Remarks
1601
+
1602
+ Time O(1), Space O(1)
1603
+
1604
+ ***
1605
+
1606
+ ### \_createLike()
1607
+
1608
+ ```ts
1609
+ protected _createLike<RM>(elements?, options?): Trie<RM>;
1610
+ ```
1611
+
1612
+ Defined in: [data-structures/trie/trie.ts:1166](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L1166)
1613
+
1614
+ (Protected) Create a like-kind trie and seed it from an iterable.
1615
+
1616
+ #### Type Parameters
1617
+
1618
+ ##### RM
1619
+
1620
+ `RM`
1621
+
1622
+ #### Parameters
1623
+
1624
+ ##### elements?
1625
+
1626
+ `Iterable`\<`string`, `any`, `any`\> \| `Iterable`\<`RM`, `any`, `any`\>
1627
+
1628
+ Iterable used to seed the new trie.
1629
+
1630
+ ##### options?
1631
+
1632
+ `TrieOptions`\<`RM`\>
1633
+
1634
+ Options forwarded to the constructor.
1635
+
1636
+ #### Returns
1637
+
1638
+ `Trie`\<`RM`\>
1639
+
1640
+ A like-kind Trie instance.
1641
+
1642
+ #### Remarks
1643
+
1644
+ Time O(ΣL), Space O(ΣL)
1645
+
1646
+ ***
1647
+
1648
+ ### \_getIterator()
1649
+
1650
+ ```ts
1651
+ protected _getIterator(): IterableIterator<string>;
1652
+ ```
1653
+
1654
+ Defined in: [data-structures/trie/trie.ts:1192](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L1192)
1655
+
1656
+ (Protected) Iterate all words in lexicographic order of edges.
1657
+
1658
+ #### Returns
1659
+
1660
+ `IterableIterator`\<`string`\>
1661
+
1662
+ Iterator of words.
1663
+
1664
+ #### Remarks
1665
+
1666
+ Time O(ΣL), Space O(H)
1667
+
1668
+ #### Overrides
1669
+
1670
+ [`IterableElementBase`](IterableElementBase.md).[`_getIterator`](IterableElementBase.md#_getiterator)
1671
+
1672
+ ***
1673
+
1674
+ ### \_spawnLike()
1675
+
1676
+ ```ts
1677
+ protected _spawnLike<RM>(options?): Trie<RM>;
1678
+ ```
1679
+
1680
+ Defined in: [data-structures/trie/trie.ts:1182](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/trie/trie.ts#L1182)
1681
+
1682
+ (Protected) Spawn an empty like-kind trie instance.
1683
+
1684
+ #### Type Parameters
1685
+
1686
+ ##### RM
1687
+
1688
+ `RM`
1689
+
1690
+ #### Parameters
1691
+
1692
+ ##### options?
1693
+
1694
+ `TrieOptions`\<`RM`\>
1695
+
1696
+ Options forwarded to the constructor.
1697
+
1698
+ #### Returns
1699
+
1700
+ `Trie`\<`RM`\>
1701
+
1702
+ An empty like-kind Trie instance.
1703
+
1704
+ #### Remarks
1705
+
1706
+ Time O(1), Space O(1)
1707
+
1708
+ ***