data-structure-typed 1.50.2 → 1.50.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +17 -15
  3. package/README_zh-CN.md +1 -1
  4. package/SPECIFICATION.md +56 -0
  5. package/SPONSOR-zh-CN.md +90 -0
  6. package/SPONSOR.md +54 -0
  7. package/benchmark/report.html +13 -13
  8. package/benchmark/report.json +149 -155
  9. package/dist/cjs/data-structures/base/iterable-base.d.ts +6 -0
  10. package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +29 -1
  12. package/dist/cjs/data-structures/binary-tree/avl-tree.js +33 -1
  13. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  15. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  16. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +1 -1
  18. package/dist/cjs/data-structures/binary-tree/binary-tree.js +1 -1
  19. package/dist/cjs/data-structures/binary-tree/bst.d.ts +46 -13
  20. package/dist/cjs/data-structures/binary-tree/bst.js +46 -13
  21. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  22. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +54 -2
  23. package/dist/cjs/data-structures/binary-tree/rb-tree.js +73 -15
  24. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  25. package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
  26. package/dist/cjs/data-structures/binary-tree/segment-tree.js +127 -10
  27. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -1
  28. package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +35 -2
  29. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +38 -0
  30. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  31. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +0 -78
  32. package/dist/cjs/data-structures/graph/abstract-graph.js +0 -189
  33. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  34. package/dist/cjs/data-structures/graph/directed-graph.d.ts +59 -0
  35. package/dist/cjs/data-structures/graph/directed-graph.js +105 -0
  36. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  37. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +60 -7
  38. package/dist/cjs/data-structures/graph/undirected-graph.js +126 -18
  39. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  40. package/dist/cjs/data-structures/hash/hash-map.d.ts +143 -23
  41. package/dist/cjs/data-structures/hash/hash-map.js +196 -62
  42. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  43. package/dist/cjs/data-structures/heap/heap.d.ts +29 -19
  44. package/dist/cjs/data-structures/heap/heap.js +29 -20
  45. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  46. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +71 -25
  47. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +83 -25
  48. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  49. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +26 -3
  50. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +34 -3
  51. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  52. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  53. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +2 -2
  54. package/dist/cjs/data-structures/matrix/matrix.d.ts +1 -1
  55. package/dist/cjs/data-structures/matrix/matrix.js +1 -1
  56. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  57. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +10 -0
  58. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  59. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  60. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +11 -0
  61. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  62. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
  63. package/dist/cjs/data-structures/priority-queue/priority-queue.js +8 -0
  64. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  65. package/dist/cjs/data-structures/queue/deque.d.ts +95 -21
  66. package/dist/cjs/data-structures/queue/deque.js +100 -16
  67. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  68. package/dist/cjs/data-structures/queue/queue.d.ts +65 -45
  69. package/dist/cjs/data-structures/queue/queue.js +65 -45
  70. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  71. package/dist/cjs/data-structures/stack/stack.d.ts +36 -22
  72. package/dist/cjs/data-structures/stack/stack.js +36 -22
  73. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  74. package/dist/cjs/data-structures/tree/tree.d.ts +57 -3
  75. package/dist/cjs/data-structures/tree/tree.js +77 -11
  76. package/dist/cjs/data-structures/tree/tree.js.map +1 -1
  77. package/dist/cjs/data-structures/trie/trie.d.ts +100 -36
  78. package/dist/cjs/data-structures/trie/trie.js +115 -36
  79. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  80. package/dist/mjs/data-structures/base/iterable-base.d.ts +6 -0
  81. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +29 -1
  82. package/dist/mjs/data-structures/binary-tree/avl-tree.js +34 -2
  83. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  84. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  85. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +1 -1
  86. package/dist/mjs/data-structures/binary-tree/binary-tree.js +1 -1
  87. package/dist/mjs/data-structures/binary-tree/bst.d.ts +46 -13
  88. package/dist/mjs/data-structures/binary-tree/bst.js +46 -13
  89. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +54 -2
  90. package/dist/mjs/data-structures/binary-tree/rb-tree.js +74 -16
  91. package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
  92. package/dist/mjs/data-structures/binary-tree/segment-tree.js +127 -10
  93. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +35 -2
  94. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +38 -1
  95. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +0 -78
  96. package/dist/mjs/data-structures/graph/abstract-graph.js +0 -188
  97. package/dist/mjs/data-structures/graph/directed-graph.d.ts +59 -0
  98. package/dist/mjs/data-structures/graph/directed-graph.js +105 -0
  99. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +60 -7
  100. package/dist/mjs/data-structures/graph/undirected-graph.js +127 -19
  101. package/dist/mjs/data-structures/hash/hash-map.d.ts +143 -23
  102. package/dist/mjs/data-structures/hash/hash-map.js +204 -70
  103. package/dist/mjs/data-structures/heap/heap.d.ts +29 -19
  104. package/dist/mjs/data-structures/heap/heap.js +29 -20
  105. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +71 -25
  106. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +86 -28
  107. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +26 -3
  108. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +36 -5
  109. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  110. package/dist/mjs/data-structures/linked-list/skip-linked-list.js +2 -2
  111. package/dist/mjs/data-structures/matrix/matrix.d.ts +1 -1
  112. package/dist/mjs/data-structures/matrix/matrix.js +1 -1
  113. package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  114. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +10 -0
  115. package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  116. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +11 -0
  117. package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
  118. package/dist/mjs/data-structures/priority-queue/priority-queue.js +8 -0
  119. package/dist/mjs/data-structures/queue/deque.d.ts +95 -21
  120. package/dist/mjs/data-structures/queue/deque.js +105 -21
  121. package/dist/mjs/data-structures/queue/queue.d.ts +65 -45
  122. package/dist/mjs/data-structures/queue/queue.js +65 -45
  123. package/dist/mjs/data-structures/stack/stack.d.ts +36 -22
  124. package/dist/mjs/data-structures/stack/stack.js +36 -22
  125. package/dist/mjs/data-structures/tree/tree.d.ts +57 -3
  126. package/dist/mjs/data-structures/tree/tree.js +80 -14
  127. package/dist/mjs/data-structures/trie/trie.d.ts +100 -36
  128. package/dist/mjs/data-structures/trie/trie.js +118 -39
  129. package/dist/umd/data-structure-typed.js +1445 -595
  130. package/dist/umd/data-structure-typed.min.js +2 -2
  131. package/dist/umd/data-structure-typed.min.js.map +1 -1
  132. package/package.json +59 -58
  133. package/src/data-structures/base/iterable-base.ts +12 -0
  134. package/src/data-structures/binary-tree/avl-tree.ts +37 -3
  135. package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
  136. package/src/data-structures/binary-tree/binary-tree.ts +1 -1
  137. package/src/data-structures/binary-tree/bst.ts +46 -13
  138. package/src/data-structures/binary-tree/rb-tree.ts +79 -18
  139. package/src/data-structures/binary-tree/segment-tree.ts +145 -11
  140. package/src/data-structures/binary-tree/tree-multimap.ts +42 -3
  141. package/src/data-structures/graph/abstract-graph.ts +0 -211
  142. package/src/data-structures/graph/directed-graph.ts +122 -0
  143. package/src/data-structures/graph/undirected-graph.ts +143 -19
  144. package/src/data-structures/hash/hash-map.ts +228 -76
  145. package/src/data-structures/heap/heap.ts +31 -20
  146. package/src/data-structures/linked-list/doubly-linked-list.ts +96 -29
  147. package/src/data-structures/linked-list/singly-linked-list.ts +42 -6
  148. package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
  149. package/src/data-structures/matrix/matrix.ts +1 -1
  150. package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
  151. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
  152. package/src/data-structures/priority-queue/priority-queue.ts +8 -0
  153. package/src/data-structures/queue/deque.ts +118 -22
  154. package/src/data-structures/queue/queue.ts +68 -45
  155. package/src/data-structures/stack/stack.ts +39 -23
  156. package/src/data-structures/tree/tree.ts +89 -15
  157. package/src/data-structures/trie/trie.ts +131 -40
  158. package/test/performance/data-structures/graph/directed-graph.test.ts +1 -1
  159. package/test/unit/data-structures/graph/abstract-graph.test.ts +3 -0
  160. package/test/unit/data-structures/graph/directed-graph.test.ts +189 -253
  161. package/test/unit/data-structures/graph/undirected-graph.test.ts +263 -18
  162. package/test/unit/data-structures/queue/queue.test.ts +2 -0
@@ -8,9 +8,57 @@ const base_1 = require("../base");
8
8
  */
9
9
  class TrieNode {
10
10
  constructor(key) {
11
- this.key = key;
12
- this.isEnd = false;
13
- this.children = new Map();
11
+ this._key = key;
12
+ this._isEnd = false;
13
+ this._children = new Map();
14
+ }
15
+ /**
16
+ * The function returns the value of the protected variable _key.
17
+ * @returns The value of the `_key` property, which is a string.
18
+ */
19
+ get key() {
20
+ return this._key;
21
+ }
22
+ /**
23
+ * The above function sets the value of a protected variable called "key".
24
+ * @param {string} value - The value parameter is a string that represents the value to be assigned
25
+ * to the key.
26
+ */
27
+ set key(value) {
28
+ this._key = value;
29
+ }
30
+ /**
31
+ * The function returns the children of a TrieNode as a Map.
32
+ * @returns The `children` property of the TrieNode object, which is a Map containing string keys and
33
+ * TrieNode values.
34
+ */
35
+ get children() {
36
+ return this._children;
37
+ }
38
+ /**
39
+ * The function sets the value of the `_children` property of a TrieNode object.
40
+ * @param value - The value parameter is a Map object that represents the children of a TrieNode. The
41
+ * keys of the map are strings, which represent the characters that are associated with each child
42
+ * TrieNode. The values of the map are TrieNode objects, which represent the child nodes of the
43
+ * current TrieNode.
44
+ */
45
+ set children(value) {
46
+ this._children = value;
47
+ }
48
+ /**
49
+ * The function returns a boolean value indicating whether a certain condition is met.
50
+ * @returns The method is returning a boolean value, specifically the value of the variable `_isEnd`.
51
+ */
52
+ get isEnd() {
53
+ return this._isEnd;
54
+ }
55
+ /**
56
+ * The function sets the value of the "_isEnd" property.
57
+ * @param {boolean} value - The value parameter is a boolean value that indicates whether the current
58
+ * state is the end state or not.
59
+ */
60
+ set isEnd(value) {
61
+ this._isEnd = value;
14
62
  }
15
63
  }
16
64
  exports.TrieNode = TrieNode;
@@ -57,9 +105,8 @@ class Trie extends base_1.IterableElementBase {
57
105
  return this._size;
58
106
  }
59
107
  /**
60
- * The caseSensitive function is a getter that returns the value of the private _caseSensitive property.
61
- *
62
- * @return The value of the _casesensitive private variable
108
+ * The caseSensitive function is a getter that returns the value of the protected _caseSensitive property.
109
+ * @return The value of the _caseSensitive protected variable
63
110
  */
64
111
  get caseSensitive() {
65
112
  return this._caseSensitive;
@@ -72,12 +119,12 @@ class Trie extends base_1.IterableElementBase {
72
119
  return this._root;
73
120
  }
74
121
  /**
75
- * Time Complexity: O(M), where M is the length of the word being added.
76
- * Space Complexity: O(M) - Each character in the word adds a TrieNode.
122
+ * Time Complexity: O(l), where l is the length of the word being added.
123
+ * Space Complexity: O(l) - Each character in the word adds a TrieNode.
77
124
  */
78
125
  /**
79
- * Time Complexity: O(M), where M is the length of the word being added.
80
- * Space Complexity: O(M) - Each character in the word adds a TrieNode.
126
+ * Time Complexity: O(l), where l is the length of the word being added.
127
+ * Space Complexity: O(l) - Each character in the word adds a TrieNode.
81
128
  *
82
129
  * Add a word to the Trie structure.
83
130
  * @param {string} word - The word to add.
@@ -103,11 +150,11 @@ class Trie extends base_1.IterableElementBase {
103
150
  return isNewWord;
104
151
  }
105
152
  /**
106
- * Time Complexity: O(M), where M is the length of the input word.
153
+ * Time Complexity: O(l), where l is the length of the input word.
107
154
  * Space Complexity: O(1) - Constant space.
108
155
  */
109
156
  /**
110
- * Time Complexity: O(M), where M is the length of the input word.
157
+ * Time Complexity: O(l), where l is the length of the input word.
111
158
  * Space Complexity: O(1) - Constant space.
112
159
  *
113
160
  * Check if the Trie contains a given word.
@@ -126,6 +173,13 @@ class Trie extends base_1.IterableElementBase {
126
173
  return cur.isEnd;
127
174
  }
128
175
  /**
176
+ * Time Complexity: O(1)
177
+ * Space Complexity: O(1)
178
+ */
179
+ /**
180
+ * Time Complexity: O(1)
181
+ * Space Complexity: O(1)
182
+ *
129
183
  * The isEmpty function checks if the size of the queue is 0.
130
184
  * @return True if the size of the queue is 0
131
185
  */
@@ -133,12 +187,26 @@ class Trie extends base_1.IterableElementBase {
133
187
  return this.size === 0;
134
188
  }
135
189
  /**
136
- * Time Complexity: O(M), where M is the length of the word being deleted.
137
- * Space Complexity: O(M) - Due to the recursive DFS approach.
190
+ * Time Complexity: O(1)
191
+ * Space Complexity: O(1)
192
+ */
193
+ /**
194
+ * Time Complexity: O(1)
195
+ * Space Complexity: O(1)
196
+ *
197
+ * The clear function resets the size of the Trie to 0 and creates a new root TrieNode.
198
+ */
199
+ clear() {
200
+ this._size = 0;
201
+ this._root = new TrieNode('');
202
+ }
203
+ /**
204
+ * Time Complexity: O(l), where l is the length of the word being deleted.
205
+ * Space Complexity: O(n) - Due to the recursive DFS approach.
138
206
  */
139
207
  /**
140
- * Time Complexity: O(M), where M is the length of the word being deleted.
141
- * Space Complexity: O(M) - Due to the recursive DFS approach.
208
+ * Time Complexity: O(l), where l is the length of the word being deleted.
209
+ * Space Complexity: O(n) - Due to the recursive DFS approach.
142
210
  *
143
211
  * Remove a word from the Trie structure.
144
212
  * @param{string} word - The word to delete.
@@ -180,11 +248,11 @@ class Trie extends base_1.IterableElementBase {
180
248
  return isDeleted;
181
249
  }
182
250
  /**
183
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
251
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
184
252
  * Space Complexity: O(1) - Constant space.
185
253
  */
186
254
  /**
187
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
255
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
188
256
  * Space Complexity: O(1) - Constant space.
189
257
  *
190
258
  */
@@ -208,11 +276,11 @@ class Trie extends base_1.IterableElementBase {
208
276
  return maxDepth;
209
277
  }
210
278
  /**
211
- * Time Complexity: O(M), where M is the length of the input prefix.
279
+ * Time Complexity: O(l), where l is the length of the input prefix.
212
280
  * Space Complexity: O(1) - Constant space.
213
281
  */
214
282
  /**
215
- * Time Complexity: O(M), where M is the length of the input prefix.
283
+ * Time Complexity: O(l), where l is the length of the input prefix.
216
284
  * Space Complexity: O(1) - Constant space.
217
285
  *
218
286
  * Check if a given input string has an absolute prefix in the Trie, meaning it's not a complete word.
@@ -231,11 +299,11 @@ class Trie extends base_1.IterableElementBase {
231
299
  return !cur.isEnd;
232
300
  }
233
301
  /**
234
- * Time Complexity: O(M), where M is the length of the input prefix.
302
+ * Time Complexity: O(l), where l is the length of the input prefix.
235
303
  * Space Complexity: O(1) - Constant space.
236
304
  */
237
305
  /**
238
- * Time Complexity: O(M), where M is the length of the input prefix.
306
+ * Time Complexity: O(l), where l is the length of the input prefix.
239
307
  * Space Complexity: O(1) - Constant space.
240
308
  *
241
309
  * 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.
@@ -254,12 +322,12 @@ class Trie extends base_1.IterableElementBase {
254
322
  return true;
255
323
  }
256
324
  /**
257
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
258
- * Space Complexity: O(M), where M is the length of the input prefix.
325
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
326
+ * Space Complexity: O(l), where l is the length of the input prefix.
259
327
  */
260
328
  /**
261
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
262
- * Space Complexity: O(M), where M is the length of the input prefix.
329
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
330
+ * Space Complexity: O(l), where l is the length of the input prefix.
263
331
  *
264
332
  * Check if the input string is a common prefix in the Trie, meaning it's a prefix shared by all words in the Trie.
265
333
  * @param {string} input - The input string representing the common prefix to check for.
@@ -283,12 +351,12 @@ class Trie extends base_1.IterableElementBase {
283
351
  return commonPre === input;
284
352
  }
285
353
  /**
286
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
287
- * Space Complexity: O(M), where M is the length of the longest common prefix.
354
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
355
+ * Space Complexity: O(l), where l is the length of the longest common prefix.
288
356
  */
289
357
  /**
290
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
291
- * Space Complexity: O(M), where M is the length of the longest common prefix.
358
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
359
+ * Space Complexity: O(l), where l is the length of the longest common prefix.
292
360
  *
293
361
  * Get the longest common prefix among all the words stored in the Trie.
294
362
  * @returns {string} The longest common prefix found in the Trie.
@@ -308,12 +376,12 @@ class Trie extends base_1.IterableElementBase {
308
376
  return commonPre;
309
377
  }
310
378
  /**
311
- * Time Complexity: O(K * L), where K is the number of words retrieved, and L is the average length of the words.
312
- * Space Complexity: O(K * L) - The space required for the output array.
379
+ * Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
380
+ * Space Complexity: O(w * l) - The space required for the output array.
313
381
  */
314
382
  /**
315
- * Time Complexity: O(K * L), where K is the number of words retrieved, and L is the average length of the words.
316
- * Space Complexity: O(K * L) - The space required for the output array.
383
+ * Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
384
+ * Space Complexity: O(w * l) - The space required for the output array.
317
385
  *
318
386
  * The `getAll` function returns an array of all words in a Trie data structure that start with a given prefix.
319
387
  * @param {string} prefix - The `prefix` parameter is a string that represents the prefix that we want to search for in the
@@ -422,6 +490,17 @@ class Trie extends base_1.IterableElementBase {
422
490
  }
423
491
  return newTrie;
424
492
  }
493
+ /**
494
+ * Time Complexity: O(n)
495
+ * Space Complexity: O(n)
496
+ */
497
+ /**
498
+ * Time Complexity: O(n)
499
+ * Space Complexity: O(n)
500
+ *
501
+ * The function `_getIterator` returns an iterable iterator that performs a depth-first search on a
502
+ * trie data structure and yields all the paths to the end nodes.
503
+ */
425
504
  *_getIterator() {
426
505
  function* _dfs(node, path) {
427
506
  if (node.isEnd) {
@@ -434,11 +513,11 @@ class Trie extends base_1.IterableElementBase {
434
513
  yield* _dfs(this.root, '');
435
514
  }
436
515
  /**
437
- * Time Complexity: O(M), where M is the length of the input string.
516
+ * Time Complexity: O(l), where l is the length of the input string.
438
517
  * Space Complexity: O(1) - Constant space.
439
518
  */
440
519
  /**
441
- * Time Complexity: O(M), where M is the length of the input string.
520
+ * Time Complexity: O(l), where l is the length of the input string.
442
521
  * Space Complexity: O(1) - Constant space.
443
522
  *
444
523
  * @param str
@@ -1 +1 @@
1
- {"version":3,"file":"trie.js","sourceRoot":"","sources":["../../../../src/data-structures/trie/trie.ts"],"names":[],"mappings":";;;AAQA,kCAA8C;AAE9C;;;GAGG;AACH,MAAa,QAAQ;IAKnB,YAAY,GAAW;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC9C,CAAC;CACF;AAVD,4BAUC;AAED;;;;;;;;;;;;GAYG;AACH,MAAa,IAAK,SAAQ,0BAAiC;IACzD;;;;;OAKG;IACH,YAAY,QAA0B,EAAE,EAAE,OAAqB;QAC7D,KAAK,EAAE,CAAC;QAUA,UAAK,GAAW,CAAC,CAAC;QAUlB,mBAAc,GAAY,IAAI,CAAC;QAW/B,UAAK,GAAa,IAAI,QAAQ,CAAC,EAAE,CAAC,CAAC;QA9B3C,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;YAClC,IAAI,aAAa,KAAK,SAAS;gBAAE,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACvE,CAAC;QACD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C,GAAW;QAChC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,+CAA+C;QAC1E,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAneD,oBAmeC"}
@@ -198,7 +198,10 @@ export declare abstract class IterableEntryBase<K = any, V = any> {
198
198
  */
199
199
  print(): void;
200
200
  abstract isEmpty(): boolean;
201
+ abstract clear(): void;
201
202
  abstract clone(): any;
203
+ abstract map(...args: any[]): any;
204
+ abstract filter(...args: any[]): any;
202
205
  protected abstract _getIterator(...args: any[]): IterableIterator<[K, V]>;
203
206
  }
204
207
  export declare abstract class IterableElementBase<E = any, C = any> {
@@ -343,6 +346,9 @@ export declare abstract class IterableElementBase<E = any, C = any> {
343
346
  */
344
347
  print(): void;
345
348
  abstract isEmpty(): boolean;
349
+ abstract clear(): void;
346
350
  abstract clone(): C;
351
+ abstract map(...args: any[]): any;
352
+ abstract filter(...args: any[]): any;
347
353
  protected abstract _getIterator(...args: any[]): IterableIterator<E>;
348
354
  }
@@ -9,8 +9,27 @@ import { BST, BSTNode } from './bst';
9
9
  import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEntry } from '../../types';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
12
- height: number;
12
+ /**
13
+ * The constructor function initializes a new instance of a class with a key and an optional value,
14
+ * and sets the height property to 0.
15
+ * @param {K} key - The "key" parameter is of type K, which represents the type of the key for the
16
+ * constructor. It is used to initialize the key property of the object being created.
17
+ * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
18
+ * value associated with the key in the constructor.
19
+ */
13
20
  constructor(key: K, value?: V);
21
+ protected _height: number;
22
+ /**
23
+ * The function returns the value of the height property.
24
+ * @returns The height of the object.
25
+ */
26
+ get height(): number;
27
+ /**
28
+ * The above function sets the value of the height property.
29
+ * @param {number} value - The value parameter is a number that represents the new height value to be
30
+ * set.
31
+ */
32
+ set height(value: number);
14
33
  }
15
34
  /**
16
35
  * 1. Height-Balanced: Each node's left and right subtrees differ in height by no more than one.
@@ -195,5 +214,14 @@ export declare class AVLTree<K = any, V = any, NODE extends AVLTreeNode<K, V, NO
195
214
  * AVL tree that needs to be balanced.
196
215
  */
197
216
  protected _balancePath(node: KeyOrNodeOrEntry<K, V, NODE>): void;
217
+ /**
218
+ * The function replaces an old node with a new node while preserving the height of the old node.
219
+ * @param {NODE} oldNode - The `oldNode` parameter is the node that you want to replace with the
220
+ * `newNode`.
221
+ * @param {NODE} newNode - The `newNode` parameter is the new node that will replace the `oldNode` in
222
+ * the data structure.
223
+ * @returns the result of calling the `_replaceNode` method on the superclass, passing in the
224
+ * `oldNode` and `newNode` as arguments.
225
+ */
198
226
  protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
199
227
  }
@@ -7,10 +7,33 @@
7
7
  */
8
8
  import { BST, BSTNode } from './bst';
9
9
  export class AVLTreeNode extends BSTNode {
10
- height;
10
+ /**
11
+ * The constructor function initializes a new instance of a class with a key and an optional value,
12
+ * and sets the height property to 0.
13
+ * @param {K} key - The "key" parameter is of type K, which represents the type of the key for the
14
+ * constructor. It is used to initialize the key property of the object being created.
15
+ * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
16
+ * value associated with the key in the constructor.
17
+ */
11
18
  constructor(key, value) {
12
19
  super(key, value);
13
- this.height = 0;
20
+ this._height = 0;
21
+ }
22
+ _height;
23
+ /**
24
+ * The function returns the value of the height property.
25
+ * @returns The height of the object.
26
+ */
27
+ get height() {
28
+ return this._height;
29
+ }
30
+ /**
31
+ * The above function sets the value of the height property.
32
+ * @param {number} value - The value parameter is a number that represents the new height value to be
33
+ * set.
34
+ */
35
+ set height(value) {
36
+ this._height = value;
14
37
  }
15
38
  }
16
39
  /**
@@ -451,6 +474,15 @@ export class AVLTree extends BST {
451
474
  // TODO So far, no sure if this is necessary that Recursive Repair: Once rotation operations are executed, it may cause imbalance issues at higher levels of the tree. Therefore, you need to recursively check and repair imbalance problems upwards until you reach the root node.
452
475
  }
453
476
  }
477
+ /**
478
+ * The function replaces an old node with a new node while preserving the height of the old node.
479
+ * @param {NODE} oldNode - The `oldNode` parameter is the node that you want to replace with the
480
+ * `newNode`.
481
+ * @param {NODE} newNode - The `newNode` parameter is the new node that will replace the `oldNode` in
482
+ * the data structure.
483
+ * @returns the result of calling the `_replaceNode` method on the superclass, passing in the
484
+ * `oldNode` and `newNode` as arguments.
485
+ */
454
486
  _replaceNode(oldNode, newNode) {
455
487
  newNode.height = oldNode.height;
456
488
  return super._replaceNode(oldNode, newNode);
@@ -12,12 +12,34 @@ export declare class BinaryIndexedTree {
12
12
  max: number;
13
13
  });
14
14
  protected _freqMap: Record<number, number>;
15
+ /**
16
+ * The function returns the frequency map of numbers.
17
+ * @returns The `_freqMap` property, which is a record with number keys and number values, is being
18
+ * returned.
19
+ */
15
20
  get freqMap(): Record<number, number>;
16
21
  protected _msb: number;
22
+ /**
23
+ * The function returns the value of the _msb property.
24
+ * @returns The `_msb` property of the object.
25
+ */
17
26
  get msb(): number;
18
27
  protected _negativeCount: number;
28
+ /**
29
+ * The function returns the value of the _negativeCount property.
30
+ * @returns The method is returning the value of the variable `_negativeCount`, which is of type
31
+ * `number`.
32
+ */
19
33
  get negativeCount(): number;
34
+ /**
35
+ * The above function returns the value of the protected variable `_freq`.
36
+ * @returns The frequency value stored in the protected variable `_freq`.
37
+ */
20
38
  get freq(): number;
39
+ /**
40
+ * The above function returns the maximum value.
41
+ * @returns The maximum value stored in the variable `_max`.
42
+ */
21
43
  get max(): number;
22
44
  /**
23
45
  * The function "readSingle" reads a single number from a specified index.
@@ -23,20 +23,42 @@ export class BinaryIndexedTree {
23
23
  this._negativeCount = frequency < 0 ? max : 0;
24
24
  }
25
25
  _freqMap;
26
+ /**
27
+ * The function returns the frequency map of numbers.
28
+ * @returns The `_freqMap` property, which is a record with number keys and number values, is being
29
+ * returned.
30
+ */
26
31
  get freqMap() {
27
32
  return this._freqMap;
28
33
  }
29
34
  _msb;
35
+ /**
36
+ * The function returns the value of the _msb property.
37
+ * @returns The `_msb` property of the object.
38
+ */
30
39
  get msb() {
31
40
  return this._msb;
32
41
  }
33
42
  _negativeCount;
43
+ /**
44
+ * The function returns the value of the _negativeCount property.
45
+ * @returns The method is returning the value of the variable `_negativeCount`, which is of type
46
+ * `number`.
47
+ */
34
48
  get negativeCount() {
35
49
  return this._negativeCount;
36
50
  }
51
+ /**
52
+ * The above function returns the value of the protected variable `_freq`.
53
+ * @returns The frequency value stored in the protected variable `_freq`.
54
+ */
37
55
  get freq() {
38
56
  return this._freq;
39
57
  }
58
+ /**
59
+ * The above function returns the maximum value.
60
+ * @returns The maximum value stored in the variable `_max`.
61
+ */
40
62
  get max() {
41
63
  return this._max;
42
64
  }
@@ -21,7 +21,7 @@ export declare class BinaryTreeNode<K = any, V = any, NODE extends BinaryTreeNod
21
21
  /**
22
22
  * The constructor function initializes an object with a key and an optional value.
23
23
  * @param {K} key - The "key" parameter is of type K, which represents the type of the key for the
24
- * constructor. It is used to set the value of the "key" property of the object being created.
24
+ * constructor. It is used to set the key property of the object being created.
25
25
  * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
26
26
  * value associated with the key in the constructor.
27
27
  */
@@ -21,7 +21,7 @@ export class BinaryTreeNode {
21
21
  /**
22
22
  * The constructor function initializes an object with a key and an optional value.
23
23
  * @param {K} key - The "key" parameter is of type K, which represents the type of the key for the
24
- * constructor. It is used to set the value of the "key" property of the object being created.
24
+ * constructor. It is used to set the key property of the object being created.
25
25
  * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
26
26
  * value associated with the key in the constructor.
27
27
  */
@@ -13,10 +13,29 @@ export declare class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE>
13
13
  parent?: NODE;
14
14
  constructor(key: K, value?: V);
15
15
  protected _left?: NODE;
16
+ /**
17
+ * The function returns the value of the `_left` property.
18
+ * @returns The `_left` property of the current object is being returned.
19
+ */
16
20
  get left(): NODE | undefined;
21
+ /**
22
+ * The function sets the left child of a node and updates the parent reference of the child.
23
+ * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be an
24
+ * instance of the `NODE` class or `undefined`.
25
+ */
17
26
  set left(v: NODE | undefined);
18
27
  protected _right?: NODE;
28
+ /**
29
+ * The function returns the right node of a binary tree or undefined if there is no right node.
30
+ * @returns The method is returning the value of the `_right` property, which is of type `NODE` or
31
+ * `undefined`.
32
+ */
19
33
  get right(): NODE | undefined;
34
+ /**
35
+ * The function sets the right child of a node and updates the parent reference of the child.
36
+ * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be a
37
+ * `NODE` object or `undefined`.
38
+ */
20
39
  set right(v: NODE | undefined);
21
40
  }
22
41
  /**
@@ -30,33 +49,42 @@ export declare class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE>
30
49
  */
31
50
  export declare class BST<K = any, V = any, NODE extends BSTNode<K, V, NODE> = BSTNode<K, V, BSTNodeNested<K, V>>, TREE extends BST<K, V, NODE, TREE> = BST<K, V, NODE, BSTNested<K, V, NODE>>> extends BinaryTree<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> {
32
51
  /**
33
- * This is the constructor function for a binary search tree class in TypeScript, which initializes
34
- * the tree with optional keysOrNodesOrEntries and options.
35
- * @param [keysOrNodesOrEntries] - An optional iterable of KeyOrNodeOrEntry objects that will be added to the
36
- * binary search tree.
52
+ * This is the constructor function for a TypeScript class that initializes a binary search tree with
53
+ * optional keys or nodes or entries and options.
54
+ * @param keysOrNodesOrEntries - An iterable object that contains keys, nodes, or entries. It is used
55
+ * to initialize the binary search tree with the provided keys, nodes, or entries.
37
56
  * @param [options] - The `options` parameter is an optional object that can contain additional
38
57
  * configuration options for the binary search tree. It can have the following properties:
39
58
  */
40
59
  constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: BSTOptions<K>);
41
60
  protected _root?: NODE;
61
+ /**
62
+ * The function returns the root node of a tree structure.
63
+ * @returns The `_root` property of the object, which is of type `NODE` or `undefined`.
64
+ */
42
65
  get root(): NODE | undefined;
43
66
  protected _variant: BSTVariant;
67
+ /**
68
+ * The function returns the value of the _variant property.
69
+ * @returns The value of the `_variant` property.
70
+ */
44
71
  get variant(): BSTVariant;
45
72
  /**
46
- * The function creates a new binary search tree node with the given key and value.
47
- * @param {K} key - The key parameter is the key value that will be associated with
48
- * the new node. It is used to determine the position of the node in the binary search tree.
49
- * @param [value] - The parameter `value` is an optional value that can be assigned to the node. It
50
- * represents the value associated with the node in a binary search tree.
51
- * @returns a new instance of the BSTNode class with the specified key and value.
73
+ * The function creates a new BSTNode with the given key and value and returns it.
74
+ * @param {K} key - The key parameter is of type K, which represents the type of the key for the node
75
+ * being created.
76
+ * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
77
+ * value associated with the key in the node being created.
78
+ * @returns The method is returning a new instance of the BSTNode class, casted as the NODE type.
52
79
  */
53
80
  createNode(key: K, value?: V): NODE;
54
81
  /**
55
82
  * The function creates a new binary search tree with the specified options.
56
83
  * @param [options] - The `options` parameter is an optional object that allows you to customize the
57
- * behavior of the `createTree` method. It accepts a partial `BSTOptions` object, which is a type
58
- * that defines various options for creating a binary search tree.
59
- * @returns a new instance of the BST class with the specified options.
84
+ * behavior of the `createTree` method. It is of type `Partial<BSTOptions<K>>`, which means it is a
85
+ * partial object of type `BSTOptions<K>`.
86
+ * @returns a new instance of the BST class, with the provided options merged with the default
87
+ * options. The returned value is casted as TREE.
60
88
  */
61
89
  createTree(options?: Partial<BSTOptions<K>>): TREE;
62
90
  /**
@@ -333,6 +361,11 @@ export declare class BST<K = any, V = any, NODE extends BSTNode<K, V, NODE> = BS
333
361
  * @returns a boolean value.
334
362
  */
335
363
  isAVLBalanced(iterationType?: IterationType): boolean;
364
+ /**
365
+ * The function sets the root property of an object and updates the parent property of the new root.
366
+ * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. This means that it
367
+ * can either be an object of type `NODE` or it can be `undefined`.
368
+ */
336
369
  protected _setRoot(v: NODE | undefined): void;
337
370
  /**
338
371
  * The function compares two values using a comparator function and returns whether the first value