data-structure-typed 1.35.1 → 1.36.1

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 (214) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/dist/data-structures/binary-tree/aa-tree.d.ts +2 -0
  3. package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +21 -0
  4. package/dist/data-structures/binary-tree/abstract-binary-tree.js +13 -864
  5. package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -1
  6. package/dist/data-structures/binary-tree/avl-tree.d.ts +94 -0
  7. package/dist/data-structures/binary-tree/avl-tree.js +90 -3
  8. package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
  9. package/dist/data-structures/binary-tree/b-tree.d.ts +2 -0
  10. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +46 -0
  11. package/dist/data-structures/binary-tree/binary-indexed-tree.js +36 -0
  12. package/dist/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  13. package/dist/data-structures/binary-tree/binary-tree.d.ts +536 -0
  14. package/dist/data-structures/binary-tree/binary-tree.js +1194 -2
  15. package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
  16. package/dist/data-structures/binary-tree/bst.d.ts +133 -0
  17. package/dist/data-structures/binary-tree/bst.js +114 -0
  18. package/dist/data-structures/binary-tree/bst.js.map +1 -1
  19. package/dist/data-structures/binary-tree/index.d.ts +12 -0
  20. package/dist/data-structures/binary-tree/rb-tree.d.ts +13 -0
  21. package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
  22. package/dist/data-structures/binary-tree/segment-tree.d.ts +83 -0
  23. package/dist/data-structures/binary-tree/segment-tree.js +45 -0
  24. package/dist/data-structures/binary-tree/segment-tree.js.map +1 -1
  25. package/dist/data-structures/binary-tree/splay-tree.d.ts +2 -0
  26. package/dist/data-structures/binary-tree/tree-multiset.d.ts +209 -0
  27. package/dist/data-structures/binary-tree/tree-multiset.js +178 -0
  28. package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -1
  29. package/dist/data-structures/binary-tree/two-three-tree.d.ts +2 -0
  30. package/dist/data-structures/graph/abstract-graph.d.ts +332 -0
  31. package/dist/data-structures/graph/abstract-graph.js +270 -7
  32. package/dist/data-structures/graph/abstract-graph.js.map +1 -1
  33. package/dist/data-structures/graph/directed-graph.d.ts +200 -0
  34. package/dist/data-structures/graph/directed-graph.js +167 -0
  35. package/dist/data-structures/graph/directed-graph.js.map +1 -1
  36. package/dist/data-structures/graph/index.d.ts +4 -0
  37. package/dist/data-structures/graph/map-graph.d.ts +79 -0
  38. package/dist/data-structures/graph/map-graph.js +54 -0
  39. package/dist/data-structures/graph/map-graph.js.map +1 -1
  40. package/dist/data-structures/graph/undirected-graph.d.ts +127 -0
  41. package/dist/data-structures/graph/undirected-graph.js +105 -0
  42. package/dist/data-structures/graph/undirected-graph.js.map +1 -1
  43. package/dist/data-structures/hash/coordinate-map.d.ts +45 -0
  44. package/dist/data-structures/hash/coordinate-map.js +35 -0
  45. package/dist/data-structures/hash/coordinate-map.js.map +1 -1
  46. package/dist/data-structures/hash/coordinate-set.d.ts +37 -0
  47. package/dist/data-structures/hash/coordinate-set.js +28 -0
  48. package/dist/data-structures/hash/coordinate-set.js.map +1 -1
  49. package/dist/data-structures/hash/hash-map.d.ts +56 -0
  50. package/dist/data-structures/hash/hash-map.js +29 -1
  51. package/dist/data-structures/hash/hash-map.js.map +1 -1
  52. package/dist/data-structures/hash/hash-table.d.ts +106 -0
  53. package/dist/data-structures/hash/hash-table.js +88 -6
  54. package/dist/data-structures/hash/hash-table.js.map +1 -1
  55. package/dist/data-structures/hash/index.d.ts +7 -0
  56. package/dist/data-structures/hash/pair.d.ts +2 -0
  57. package/dist/data-structures/hash/tree-map.d.ts +2 -0
  58. package/dist/data-structures/hash/tree-set.d.ts +2 -0
  59. package/dist/data-structures/heap/heap.d.ts +99 -0
  60. package/dist/data-structures/heap/heap.js +200 -78
  61. package/dist/data-structures/heap/heap.js.map +1 -1
  62. package/dist/data-structures/heap/index.d.ts +3 -0
  63. package/dist/data-structures/heap/max-heap.d.ts +12 -0
  64. package/dist/data-structures/heap/max-heap.js +16 -6
  65. package/dist/data-structures/heap/max-heap.js.map +1 -1
  66. package/dist/data-structures/heap/min-heap.d.ts +12 -0
  67. package/dist/data-structures/heap/min-heap.js +16 -6
  68. package/dist/data-structures/heap/min-heap.js.map +1 -1
  69. package/dist/data-structures/index.d.ts +11 -0
  70. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +234 -0
  71. package/dist/data-structures/linked-list/doubly-linked-list.js +202 -0
  72. package/dist/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  73. package/dist/data-structures/linked-list/index.d.ts +3 -0
  74. package/dist/data-structures/linked-list/singly-linked-list.d.ts +157 -0
  75. package/dist/data-structures/linked-list/singly-linked-list.js +135 -0
  76. package/dist/data-structures/linked-list/singly-linked-list.js.map +1 -1
  77. package/dist/data-structures/linked-list/skip-linked-list.d.ts +61 -0
  78. package/dist/data-structures/linked-list/skip-linked-list.js +36 -0
  79. package/dist/data-structures/linked-list/skip-linked-list.js.map +1 -1
  80. package/dist/data-structures/matrix/index.d.ts +4 -0
  81. package/dist/data-structures/matrix/matrix.d.ts +21 -0
  82. package/dist/data-structures/matrix/matrix.js +15 -0
  83. package/dist/data-structures/matrix/matrix.js.map +1 -1
  84. package/dist/data-structures/matrix/matrix2d.d.ts +108 -0
  85. package/dist/data-structures/matrix/matrix2d.js +91 -2
  86. package/dist/data-structures/matrix/matrix2d.js.map +1 -1
  87. package/dist/data-structures/matrix/navigator.d.ts +52 -0
  88. package/dist/data-structures/matrix/navigator.js +28 -0
  89. package/dist/data-structures/matrix/navigator.js.map +1 -1
  90. package/dist/data-structures/matrix/vector2d.d.ts +201 -0
  91. package/dist/data-structures/matrix/vector2d.js +188 -1
  92. package/dist/data-structures/matrix/vector2d.js.map +1 -1
  93. package/dist/data-structures/priority-queue/index.d.ts +3 -0
  94. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -0
  95. package/dist/data-structures/priority-queue/max-priority-queue.js +16 -17
  96. package/dist/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  97. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +12 -0
  98. package/dist/data-structures/priority-queue/min-priority-queue.js +16 -17
  99. package/dist/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  100. package/dist/data-structures/priority-queue/priority-queue.d.ts +12 -0
  101. package/dist/data-structures/priority-queue/priority-queue.js +11 -174
  102. package/dist/data-structures/priority-queue/priority-queue.js.map +1 -1
  103. package/dist/data-structures/queue/deque.d.ts +165 -0
  104. package/dist/data-structures/queue/deque.js +124 -0
  105. package/dist/data-structures/queue/deque.js.map +1 -1
  106. package/dist/data-structures/queue/index.d.ts +2 -0
  107. package/dist/data-structures/queue/queue.d.ts +107 -0
  108. package/dist/data-structures/queue/queue.js +80 -0
  109. package/dist/data-structures/queue/queue.js.map +1 -1
  110. package/dist/data-structures/stack/index.d.ts +1 -0
  111. package/dist/data-structures/stack/stack.d.ts +63 -0
  112. package/dist/data-structures/stack/stack.js +50 -0
  113. package/dist/data-structures/stack/stack.js.map +1 -1
  114. package/dist/data-structures/tree/index.d.ts +1 -0
  115. package/dist/data-structures/tree/tree.d.ts +14 -0
  116. package/dist/data-structures/tree/tree.js +1 -0
  117. package/dist/data-structures/tree/tree.js.map +1 -1
  118. package/dist/data-structures/trie/index.d.ts +1 -0
  119. package/dist/data-structures/trie/trie.d.ts +61 -0
  120. package/dist/data-structures/trie/trie.js +36 -0
  121. package/dist/data-structures/trie/trie.js.map +1 -1
  122. package/dist/index.d.ts +4 -0
  123. package/dist/interfaces/abstract-binary-tree.d.ts +7 -0
  124. package/dist/interfaces/abstract-graph.d.ts +5 -0
  125. package/dist/interfaces/avl-tree.d.ts +7 -0
  126. package/dist/interfaces/binary-tree.d.ts +6 -0
  127. package/dist/interfaces/bst.d.ts +6 -0
  128. package/dist/interfaces/directed-graph.d.ts +3 -0
  129. package/dist/interfaces/doubly-linked-list.d.ts +1 -0
  130. package/dist/interfaces/heap.d.ts +1 -0
  131. package/dist/interfaces/index.d.ts +15 -0
  132. package/dist/interfaces/navigator.d.ts +1 -0
  133. package/dist/interfaces/priority-queue.d.ts +1 -0
  134. package/dist/interfaces/rb-tree.d.ts +6 -0
  135. package/dist/interfaces/segment-tree.d.ts +1 -0
  136. package/dist/interfaces/singly-linked-list.d.ts +1 -0
  137. package/dist/interfaces/tree-multiset.d.ts +6 -0
  138. package/dist/interfaces/undirected-graph.d.ts +3 -0
  139. package/dist/types/data-structures/abstract-binary-tree.d.ts +32 -0
  140. package/dist/types/data-structures/abstract-binary-tree.js +6 -0
  141. package/dist/types/data-structures/abstract-binary-tree.js.map +1 -1
  142. package/dist/types/data-structures/abstract-graph.d.ts +11 -0
  143. package/dist/types/data-structures/avl-tree.d.ts +4 -0
  144. package/dist/types/data-structures/binary-tree.d.ts +6 -0
  145. package/dist/types/data-structures/bst.d.ts +13 -0
  146. package/dist/types/data-structures/directed-graph.d.ts +6 -0
  147. package/dist/types/data-structures/doubly-linked-list.d.ts +1 -0
  148. package/dist/types/data-structures/hash.d.ts +1 -0
  149. package/dist/types/data-structures/heap.d.ts +1 -0
  150. package/dist/types/data-structures/index.d.ts +16 -0
  151. package/dist/types/data-structures/map-graph.d.ts +1 -0
  152. package/dist/types/data-structures/navigator.d.ts +14 -0
  153. package/dist/types/data-structures/priority-queue.d.ts +7 -0
  154. package/dist/types/data-structures/rb-tree.d.ts +8 -0
  155. package/dist/types/data-structures/segment-tree.d.ts +1 -0
  156. package/dist/types/data-structures/singly-linked-list.d.ts +1 -0
  157. package/dist/types/data-structures/tree-multiset.d.ts +4 -0
  158. package/dist/types/helpers.d.ts +1 -0
  159. package/dist/types/index.d.ts +3 -0
  160. package/dist/types/utils/index.d.ts +2 -0
  161. package/dist/types/utils/utils.d.ts +7 -0
  162. package/dist/types/utils/validate-type.d.ts +19 -0
  163. package/dist/utils/index.d.ts +1 -0
  164. package/dist/utils/utils.d.ts +19 -0
  165. package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +3 -509
  166. package/lib/data-structures/binary-tree/abstract-binary-tree.js +1 -1175
  167. package/lib/data-structures/binary-tree/avl-tree.d.ts +1 -1
  168. package/lib/data-structures/binary-tree/binary-tree.d.ts +506 -1
  169. package/lib/data-structures/binary-tree/binary-tree.js +1173 -2
  170. package/lib/data-structures/binary-tree/bst.d.ts +1 -1
  171. package/lib/data-structures/binary-tree/rb-tree.d.ts +1 -1
  172. package/lib/data-structures/binary-tree/tree-multiset.d.ts +1 -1
  173. package/lib/data-structures/graph/abstract-graph.js +3 -5
  174. package/lib/data-structures/heap/heap.d.ts +84 -68
  175. package/lib/data-structures/heap/heap.js +168 -107
  176. package/lib/data-structures/heap/max-heap.d.ts +6 -17
  177. package/lib/data-structures/heap/max-heap.js +11 -17
  178. package/lib/data-structures/heap/min-heap.d.ts +6 -18
  179. package/lib/data-structures/heap/min-heap.js +11 -18
  180. package/lib/data-structures/priority-queue/max-priority-queue.d.ts +4 -7
  181. package/lib/data-structures/priority-queue/max-priority-queue.js +11 -30
  182. package/lib/data-structures/priority-queue/min-priority-queue.d.ts +4 -7
  183. package/lib/data-structures/priority-queue/min-priority-queue.js +11 -31
  184. package/lib/data-structures/priority-queue/priority-queue.d.ts +6 -174
  185. package/lib/data-structures/priority-queue/priority-queue.js +11 -315
  186. package/lib/types/data-structures/abstract-binary-tree.d.ts +1 -3
  187. package/lib/types/data-structures/binary-tree.d.ts +4 -2
  188. package/lib/types/data-structures/heap.d.ts +1 -3
  189. package/package.json +10 -6
  190. package/src/data-structures/binary-tree/abstract-binary-tree.ts +4 -1527
  191. package/src/data-structures/binary-tree/avl-tree.ts +3 -3
  192. package/src/data-structures/binary-tree/binary-tree.ts +1524 -5
  193. package/src/data-structures/binary-tree/bst.ts +3 -3
  194. package/src/data-structures/binary-tree/rb-tree.ts +3 -3
  195. package/src/data-structures/binary-tree/tree-multiset.ts +3 -3
  196. package/src/data-structures/graph/abstract-graph.ts +3 -5
  197. package/src/data-structures/heap/heap.ts +167 -143
  198. package/src/data-structures/heap/max-heap.ts +15 -22
  199. package/src/data-structures/heap/min-heap.ts +15 -23
  200. package/src/data-structures/priority-queue/max-priority-queue.ts +13 -46
  201. package/src/data-structures/priority-queue/min-priority-queue.ts +13 -47
  202. package/src/data-structures/priority-queue/priority-queue.ts +7 -350
  203. package/src/types/data-structures/abstract-binary-tree.ts +1 -1
  204. package/src/types/data-structures/binary-tree.ts +2 -2
  205. package/src/types/data-structures/heap.ts +1 -5
  206. package/test/unit/data-structures/heap/heap.test.ts +26 -18
  207. package/test/unit/data-structures/heap/max-heap.test.ts +50 -42
  208. package/test/unit/data-structures/heap/min-heap.test.ts +38 -68
  209. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +9 -10
  210. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -1
  211. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +14 -30
  212. package/umd/bundle.min.js +1 -1
  213. package/umd/bundle.min.js.LICENSE.txt +15 -0
  214. package/umd/bundle.min.js.map +1 -1
@@ -1,4 +1,11 @@
1
1
  "use strict";
2
+ /**
3
+ * data-structure-typed
4
+ *
5
+ * @author Tyler Zeng
6
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
7
+ * @license MIT License
8
+ */
2
9
  Object.defineProperty(exports, "__esModule", { value: true });
3
10
  exports.SegmentTree = exports.SegmentTreeNode = void 0;
4
11
  class SegmentTreeNode {
@@ -53,6 +60,15 @@ class SegmentTreeNode {
53
60
  }
54
61
  exports.SegmentTreeNode = SegmentTreeNode;
55
62
  class SegmentTree {
63
+ /**
64
+ * The constructor initializes the values, start, end, and root properties of an object.
65
+ * @param {number[]} values - An array of numbers that will be used to build a binary search tree.
66
+ * @param {number} [start] - The `start` parameter is the index of the first element in the `values` array that should
67
+ * be included in the range. If no value is provided for `start`, it defaults to 0, which means the range starts from
68
+ * the beginning of the array.
69
+ * @param {number} [end] - The "end" parameter is the index of the last element in the "values" array that should be
70
+ * included in the range. If not provided, it defaults to the index of the last element in the "values" array.
71
+ */
56
72
  constructor(values, start, end) {
57
73
  this._values = [];
58
74
  this._start = 0;
@@ -81,6 +97,15 @@ class SegmentTree {
81
97
  get root() {
82
98
  return this._root;
83
99
  }
100
+ /**
101
+ * The build function creates a segment tree by recursively dividing the given range into smaller segments and assigning
102
+ * the sum of values to each segment.
103
+ * @param {number} start - The `start` parameter represents the starting index of the segment or range for which we are
104
+ * building the segment tree.
105
+ * @param {number} end - The "end" parameter represents the ending index of the segment or range for which we want to
106
+ * build a segment tree.
107
+ * @returns a SegmentTreeNode object.
108
+ */
84
109
  build(start, end) {
85
110
  if (start > end) {
86
111
  return new SegmentTreeNode(start, end, 0);
@@ -95,6 +120,17 @@ class SegmentTree {
95
120
  cur.right = right;
96
121
  return cur;
97
122
  }
123
+ /**
124
+ * The function updates the value of a node in a segment tree and recalculates the sum of its children if they exist.
125
+ * @param {number} index - The index parameter represents the index of the node in the segment tree that needs to be
126
+ * updated.
127
+ * @param {number} sum - The `sum` parameter represents the new value that should be assigned to the `sum` property of
128
+ * the `SegmentTreeNode` at the specified `index`.
129
+ * @param {SegmentTreeNodeVal} [val] - The `val` parameter is an optional value that can be assigned to the `val`
130
+ * property of the `SegmentTreeNode` object. It is not currently used in the code, but you can uncomment the line `//
131
+ * cur.val = val;` and pass a value for `val` in the
132
+ * @returns The function does not return anything.
133
+ */
98
134
  updateNode(index, sum, val) {
99
135
  const root = this.root || null;
100
136
  if (!root) {
@@ -124,6 +160,13 @@ class SegmentTree {
124
160
  };
125
161
  dfs(root, index, sum, val);
126
162
  }
163
+ /**
164
+ * The function `querySumByRange` calculates the sum of values within a given range in a segment tree.
165
+ * @param {number} indexA - The starting index of the range for which you want to calculate the sum.
166
+ * @param {number} indexB - The parameter `indexB` represents the ending index of the range for which you want to
167
+ * calculate the sum.
168
+ * @returns The function `querySumByRange` returns a number.
169
+ */
127
170
  querySumByRange(indexA, indexB) {
128
171
  const root = this.root || null;
129
172
  if (!root) {
@@ -134,6 +177,7 @@ class SegmentTree {
134
177
  }
135
178
  const dfs = (cur, i, j) => {
136
179
  if (i <= cur.start && j >= cur.end) {
180
+ // The range [i, j] completely covers the current node's range [cur.start, cur.end]
137
181
  return cur.sum;
138
182
  }
139
183
  const mid = cur.start + Math.floor((cur.end - cur.start) / 2);
@@ -154,6 +198,7 @@ class SegmentTree {
154
198
  }
155
199
  }
156
200
  else {
201
+ // Query both left and right subtrees
157
202
  let leftSum = 0;
158
203
  let rightSum = 0;
159
204
  if (cur.left) {
@@ -1 +1 @@
1
- {"version":3,"file":"segment-tree.js","sourceRoot":"","sources":["../../../src/data-structures/binary-tree/segment-tree.ts"],"names":[],"mappings":";;;AAUA,MAAa,eAAe;IAC1B,YAAY,KAAa,EAAE,GAAW,EAAE,GAAW,EAAE,GAA+B;QAO5E,WAAM,GAAG,CAAC,CAAC;QASX,SAAI,GAAG,CAAC,CAAC;QAUT,SAAI,GAA8B,IAAI,CAAC;QAUvC,SAAI,GAAG,CAAC,CAAC;QAUT,UAAK,GAA2B,IAAI,CAAC;QAUrC,WAAM,GAA2B,IAAI,CAAC;QAvD5C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC;IAC1B,CAAC;IAGD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,KAAK,CAAC,CAAS;QACjB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;IAID,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,IAAI,GAAG,CAAC,CAAS;QACf,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;IAChB,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C;aAC3B;QACH,CAAC,CAAC;QACF,OAAO,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;IAES,UAAU,CAAC,KAAe;QAClC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;IAES,SAAS,CAAC,KAAa;QAC/B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAES,OAAO,CAAC,KAAa;QAC7B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACpB,CAAC;IAES,QAAQ,CAAC,CAAyB;QAC1C,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;CACF;AAlLD,kCAkLC"}
1
+ {"version":3,"file":"segment-tree.js","sourceRoot":"","sources":["../../../src/data-structures/binary-tree/segment-tree.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAIH,MAAa,eAAe;IAC1B,YAAY,KAAa,EAAE,GAAW,EAAE,GAAW,EAAE,GAA+B;QAO5E,WAAM,GAAG,CAAC,CAAC;QASX,SAAI,GAAG,CAAC,CAAC;QAUT,SAAI,GAA8B,IAAI,CAAC;QAUvC,SAAI,GAAG,CAAC,CAAC;QAUT,UAAK,GAA2B,IAAI,CAAC;QAUrC,WAAM,GAA2B,IAAI,CAAC;QAvD5C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC;IAC1B,CAAC;IAGD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,KAAK,CAAC,CAAS;QACjB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;IAID,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,IAAI,GAAG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GAAG,CAAC,KAAK,EAAE;oBACb,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;iBACvC;gBACD,OAAO,OAAO,GAAG,QAAQ,CAAC;aAC3B;QACH,CAAC,CAAC;QACF,OAAO,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;IAES,UAAU,CAAC,KAAe;QAClC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;IAES,SAAS,CAAC,KAAa;QAC/B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAES,OAAO,CAAC,KAAa;QAC7B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACpB,CAAC;IAES,QAAQ,CAAC,CAAyB;QAC1C,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;CACF;AAlLD,kCAkLC"}
@@ -0,0 +1,2 @@
1
+ export declare class SplayTree {
2
+ }
@@ -0,0 +1,209 @@
1
+ /**
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
7
+ */
8
+ import type { BinaryTreeNodeKey, TreeMultisetNodeNested, TreeMultisetOptions } from '../../types';
9
+ import { BinaryTreeDeletedResult, DFSOrderPattern } from '../../types';
10
+ import { ITreeMultiset, ITreeMultisetNode } from '../../interfaces';
11
+ import { AVLTree, AVLTreeNode } from './avl-tree';
12
+ export declare class TreeMultisetNode<V = any, FAMILY extends TreeMultisetNode<V, FAMILY> = TreeMultisetNodeNested<V>> extends AVLTreeNode<V, FAMILY> implements ITreeMultisetNode<V, FAMILY> {
13
+ /**
14
+ * The constructor function initializes a BinaryTreeNode object with a key, value, and count.
15
+ * @param {BinaryTreeNodeKey} key - The `key` parameter is of type `BinaryTreeNodeKey` and represents the unique identifier
16
+ * of the binary tree node.
17
+ * @param {V} [val] - The `val` parameter is an optional parameter of type `V`. It represents the value of the binary
18
+ * tree node. If no value is provided, it will be `undefined`.
19
+ * @param {number} [count=1] - The `count` parameter is a number that represents the number of times a particular value
20
+ * occurs in a binary tree node. It has a default value of 1, which means that if no value is provided for the `count`
21
+ * parameter when creating a new instance of the `BinaryTreeNode` class.
22
+ */
23
+ constructor(key: BinaryTreeNodeKey, val?: V, count?: number);
24
+ count: number;
25
+ }
26
+ /**
27
+ * The only distinction between a TreeMultiset and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
28
+ */
29
+ export declare class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultisetNode> extends AVLTree<N> implements ITreeMultiset<N> {
30
+ /**
31
+ * The constructor function for a TreeMultiset class in TypeScript, which extends another class and sets an option to
32
+ * merge duplicated values.
33
+ * @param {TreeMultisetOptions} [options] - An optional object that contains additional configuration options for the
34
+ * TreeMultiset.
35
+ */
36
+ constructor(options?: TreeMultisetOptions);
37
+ private _count;
38
+ get count(): number;
39
+ /**
40
+ * The function creates a new BSTNode with the given key, value, and count.
41
+ * @param {BinaryTreeNodeKey} key - The key parameter is the unique identifier for the binary tree node. It is used to
42
+ * distinguish one node from another in the tree.
43
+ * @param {N} val - The `val` parameter represents the value that will be stored in the binary search tree node.
44
+ * @param {number} [count] - The "count" parameter is an optional parameter of type number. It represents the number of
45
+ * occurrences of the value in the binary search tree node. If not provided, the count will default to 1.
46
+ * @returns A new instance of the BSTNode class with the specified key, value, and count (if provided).
47
+ */
48
+ createNode(key: BinaryTreeNodeKey, val?: N['val'], count?: number): N;
49
+ /**
50
+ * The function swaps the location of two nodes in a tree data structure.
51
+ * @param {N} srcNode - The source node that we want to swap with the destination node.
52
+ * @param {N} destNode - The `destNode` parameter represents the destination node where the values from `srcNode` will
53
+ * be swapped with.
54
+ * @returns the `destNode` after swapping its values with the `srcNode`.
55
+ */
56
+ swapLocation(srcNode: N, destNode: N): N;
57
+ /**
58
+ * The `add` function adds a new node to a binary search tree, maintaining the tree's properties and balancing if
59
+ * necessary.
60
+ * @param {BinaryTreeNodeKey | N} keyOrNode - The `keyOrNode` parameter can be either a `BinaryTreeNodeKey` or a `N` (which
61
+ * represents a `BinaryTreeNode`).
62
+ * @param [val] - The `val` parameter represents the value to be added to the binary tree node.
63
+ * @param {number} [count] - The `count` parameter is an optional parameter that specifies the number of times the
64
+ * value should be added to the binary tree. If the `count` parameter is not provided, it defaults to 1.
65
+ * @returns The method `add` returns either the inserted node (`N`), `null`, or `undefined`.
66
+ */
67
+ add(keyOrNode: BinaryTreeNodeKey | N | null, val?: N['val'], count?: number): N | null | undefined;
68
+ /**
69
+ * The function adds a new node to a binary tree if there is an available slot on the left or right side of the parent
70
+ * node.
71
+ * @param {N | null} newNode - The `newNode` parameter represents the node that needs to be added to the tree. It can
72
+ * be either a node object (`N`) or `null`.
73
+ * @param {N} parent - The `parent` parameter represents the parent node to which the new node will be added as a
74
+ * child.
75
+ * @returns The method returns either the `parent.left`, `parent.right`, or `undefined`.
76
+ */
77
+ _addTo(newNode: N | null, parent: N): N | null | undefined;
78
+ /**
79
+ * The `addMany` function takes an array of node IDs or nodes and adds them to the tree multiset, returning an array of
80
+ * the inserted nodes.
81
+ * @param {(BinaryTreeNodeKey | null)[] | (N | null)[]} keysOrNodes - An array of BinaryTreeNodeKey or BinaryTreeNode
82
+ * objects, or null values.
83
+ * @param {N['val'][]} [data] - The `data` parameter is an optional array of values (`N['val'][]`) that corresponds to
84
+ * the nodes being added. It is used when adding nodes using the `keyOrNode` and `data` arguments in the `this.add()`
85
+ * method. If provided, the `data` array should
86
+ * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
87
+ */
88
+ addMany(keysOrNodes: (BinaryTreeNodeKey | null)[] | (N | null)[], data?: N['val'][]): (N | null | undefined)[];
89
+ /**
90
+ * The `perfectlyBalance` function takes a binary tree, performs a depth-first search to sort the nodes, and then
91
+ * constructs a balanced binary search tree using either a recursive or iterative approach.
92
+ * @returns The function `perfectlyBalance()` returns a boolean value.
93
+ */
94
+ perfectlyBalance(): boolean;
95
+ /**
96
+ * The `remove` function removes a node from a binary search tree and returns the deleted node along with the parent
97
+ * node that needs to be balanced.
98
+ * @param {N | BinaryTreeNodeKey | null} nodeOrKey - The `nodeOrKey` parameter can be one of the following:
99
+ * @param {boolean} [ignoreCount] - The `ignoreCount` parameter is an optional boolean parameter that determines
100
+ * whether to ignore the count of the node being removed. If `ignoreCount` is set to `true`, the count of the node will
101
+ * not be taken into account when removing it. If `ignoreCount` is set to `false
102
+ * @returns The function `remove` returns an array of `BinaryTreeDeletedResult<N>` objects.
103
+ */
104
+ remove(nodeOrKey: N | BinaryTreeNodeKey, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
105
+ /**
106
+ * The function `getSubTreeCount` calculates the number of nodes and the sum of their counts in a subtree, using either
107
+ * recursive or iterative traversal.
108
+ * @param {N | null | undefined} subTreeRoot - The `subTreeRoot` parameter represents the root node of a subtree in a
109
+ * binary tree.
110
+ * @returns The function `getSubTreeCount` returns an array `[number, number]`.
111
+ */
112
+ getSubTreeCount(subTreeRoot: N | null | undefined): [number, number];
113
+ /**
114
+ * The function `subTreeSumCount` calculates the sum of the `count` property of each node in a subtree, either
115
+ * recursively or iteratively.
116
+ * @param {N | BinaryTreeNodeKey | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a subtree
117
+ * in a binary tree. It can be either a `BinaryTreeNodeKey` (a unique identifier for a node in the binary tree) or
118
+ * `null` if the subtree is empty.
119
+ * @returns the sum of the count values of all nodes in the subtree rooted at `subTreeRoot`.
120
+ */
121
+ subTreeSumCount(subTreeRoot: N | BinaryTreeNodeKey | null): number;
122
+ /**
123
+ * The function `subTreeAddCount` recursively or iteratively traverses a binary tree and adds a given delta value to
124
+ * the `count` property of each node.
125
+ * @param {N | BinaryTreeNodeKey | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a subtree
126
+ * in a binary tree. It can be either a `BinaryTreeNodeKey` (a unique identifier for a node in the binary tree), a
127
+ * `BinaryTreeNode` object, or `null` if the subtree is empty.
128
+ * @param {number} delta - The delta parameter is a number that represents the amount by which the count of each node
129
+ * in the subtree should be increased or decreased.
130
+ * @returns a boolean value.
131
+ */
132
+ subTreeAddCount(subTreeRoot: N | BinaryTreeNodeKey | null, delta: number): boolean;
133
+ /**
134
+ * The function `getNodesByCount` returns an array of nodes that have a specific count property, either recursively or
135
+ * using a queue.
136
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or a
137
+ * `N`. It represents the property of the nodes that you want to search for.
138
+ * @param {boolean} [onlyOne] - The `onlyOne` parameter is an optional boolean parameter that determines whether to
139
+ * return only one node that matches the `nodeProperty` or all nodes that match the `nodeProperty`. If `onlyOne` is set
140
+ * to `true`, the function will return only one node. If `onlyOne`
141
+ * @returns an array of nodes that match the given nodeProperty.
142
+ */
143
+ getNodesByCount(nodeProperty: BinaryTreeNodeKey | N, onlyOne?: boolean): N[];
144
+ /**
145
+ * The BFSCount function returns an array of counts from a breadth-first search of nodes.
146
+ * @returns The BFSCount() function returns an array of numbers, specifically the count property of each node in the
147
+ * bfs traversal.
148
+ */
149
+ BFSCount(): number[];
150
+ /**
151
+ * The function "listLevelsCount" takes a node and returns an array of arrays, where each inner array contains the
152
+ * count property of each node at that level.
153
+ * @param {N | null} node - The parameter `node` is of type `N | null`. This means that it can either be an instance of
154
+ * the class `N` or `null`.
155
+ * @returns a 2D array of numbers. Each inner array represents a level in the binary tree, and each number in the inner
156
+ * array represents the count property of a node in that level.
157
+ */
158
+ listLevelsCount(node: N | null): number[][];
159
+ /**
160
+ * The `morrisCount` function returns an array of counts for each node in a binary tree, based on a specified traversal
161
+ * pattern.
162
+ * @param {'in' | 'pre' | 'post'} [pattern] - The `pattern` parameter is an optional parameter that specifies the
163
+ * traversal pattern for the Morris traversal algorithm. It can have one of three values: 'in', 'pre', or 'post'.
164
+ * @returns The function `morrisCount` returns an array of numbers.
165
+ */
166
+ morrisCount(pattern?: DFSOrderPattern): number[];
167
+ /**
168
+ * The function dfsCountIterative performs an iterative depth-first search and returns an array of node counts based on
169
+ * the specified traversal pattern.
170
+ * @param {'in' | 'pre' | 'post'} [pattern] - The pattern parameter is a string that specifies the traversal order for
171
+ * the Depth-First Search (dfs) algorithm. It can have three possible values: 'in', 'pre', or 'post'.
172
+ * @returns The dfsCountIterative function returns an array of numbers, which represents the count property of each node
173
+ * in the dfs traversal.
174
+ */
175
+ dfsCountIterative(pattern?: DFSOrderPattern): number[];
176
+ /**
177
+ * The dfsCount function returns an array of counts for each node in a depth-first search traversal.
178
+ * @param {DFSOrderPattern} [pattern] - The pattern parameter is an optional parameter that specifies the order in which
179
+ * the Depth-First Search (dfs) algorithm should traverse the nodes. It can have one of the following values:
180
+ * @returns The dfsCount function returns an array of numbers, specifically the count property of each node in the dfs
181
+ * traversal.
182
+ */
183
+ dfsCount(pattern?: DFSOrderPattern): number[];
184
+ /**
185
+ * The `lesserSumCount` function calculates the sum of the counts of all nodes in a binary tree that have a lesser
186
+ * value than a given node.
187
+ * @param {N | BinaryTreeNodeKey | null} beginNode - The `beginNode` parameter can be one of the following:
188
+ * @returns the sum of the counts of nodes in the binary tree that have a lesser value than the given beginNode.
189
+ */
190
+ lesserSumCount(beginNode: N | BinaryTreeNodeKey | null): number;
191
+ /**
192
+ * The function `allGreaterNodesAddCount` updates the count property of all nodes in a binary tree that have an ID
193
+ * greater than a given ID by a specified delta value.
194
+ * @param {N | BinaryTreeNodeKey | null} node - The `node` parameter can be one of the following:
195
+ * @param {number} delta - The `delta` parameter is a number that represents the amount by which the `count` property
196
+ * of each node should be increased.
197
+ * @returns a boolean value.
198
+ */
199
+ allGreaterNodesAddCount(node: N | BinaryTreeNodeKey | null, delta: number): boolean;
200
+ /**
201
+ * The clear() function clears the data and sets the count to 0.
202
+ */
203
+ clear(): void;
204
+ /**
205
+ * The function "_setCount" is used to set the value of the "_count" property.
206
+ * @param {number} v - number
207
+ */
208
+ protected _setCount(v: number): void;
209
+ }