data-structure-typed 1.50.1 → 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 (196) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/README.md +30 -28
  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 -161
  9. package/dist/cjs/data-structures/base/iterable-base.d.ts +120 -9
  10. package/dist/cjs/data-structures/base/iterable-base.js +143 -7
  11. package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
  12. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +72 -47
  13. package/dist/cjs/data-structures/binary-tree/avl-tree.js +101 -72
  14. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  15. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  16. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  17. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  18. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +244 -199
  19. package/dist/cjs/data-structures/binary-tree/binary-tree.js +484 -376
  20. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  21. package/dist/cjs/data-structures/binary-tree/bst.d.ts +92 -79
  22. package/dist/cjs/data-structures/binary-tree/bst.js +68 -76
  23. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  24. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +127 -57
  25. package/dist/cjs/data-structures/binary-tree/rb-tree.js +152 -99
  26. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  27. package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
  28. package/dist/cjs/data-structures/binary-tree/segment-tree.js +127 -10
  29. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -1
  30. package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +72 -58
  31. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +102 -85
  32. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  33. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +1 -78
  34. package/dist/cjs/data-structures/graph/abstract-graph.js +3 -189
  35. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  36. package/dist/cjs/data-structures/graph/directed-graph.d.ts +73 -0
  37. package/dist/cjs/data-structures/graph/directed-graph.js +131 -0
  38. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  39. package/dist/cjs/data-structures/graph/map-graph.d.ts +8 -0
  40. package/dist/cjs/data-structures/graph/map-graph.js +14 -0
  41. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  42. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +76 -7
  43. package/dist/cjs/data-structures/graph/undirected-graph.js +151 -18
  44. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  45. package/dist/cjs/data-structures/hash/hash-map.d.ts +254 -28
  46. package/dist/cjs/data-structures/hash/hash-map.js +347 -78
  47. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  48. package/dist/cjs/data-structures/heap/heap.d.ts +95 -25
  49. package/dist/cjs/data-structures/heap/heap.js +95 -26
  50. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  51. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +126 -63
  52. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +141 -77
  53. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  54. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +154 -106
  55. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +164 -115
  56. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  57. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +63 -36
  58. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +63 -36
  59. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
  60. package/dist/cjs/data-structures/matrix/matrix.d.ts +35 -4
  61. package/dist/cjs/data-structures/matrix/matrix.js +50 -11
  62. package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
  63. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  64. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +10 -0
  65. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  66. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  67. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +11 -0
  68. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  69. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
  70. package/dist/cjs/data-structures/priority-queue/priority-queue.js +8 -0
  71. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  72. package/dist/cjs/data-structures/queue/deque.d.ts +139 -35
  73. package/dist/cjs/data-structures/queue/deque.js +200 -62
  74. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  75. package/dist/cjs/data-structures/queue/queue.d.ts +103 -49
  76. package/dist/cjs/data-structures/queue/queue.js +111 -49
  77. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  78. package/dist/cjs/data-structures/stack/stack.d.ts +51 -21
  79. package/dist/cjs/data-structures/stack/stack.js +58 -22
  80. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  81. package/dist/cjs/data-structures/tree/tree.d.ts +57 -3
  82. package/dist/cjs/data-structures/tree/tree.js +77 -11
  83. package/dist/cjs/data-structures/tree/tree.js.map +1 -1
  84. package/dist/cjs/data-structures/trie/trie.d.ts +135 -34
  85. package/dist/cjs/data-structures/trie/trie.js +153 -33
  86. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  87. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  88. package/dist/cjs/types/data-structures/hash/hash-map.d.ts +4 -3
  89. package/dist/cjs/types/utils/utils.d.ts +1 -0
  90. package/dist/mjs/data-structures/base/iterable-base.d.ts +120 -9
  91. package/dist/mjs/data-structures/base/iterable-base.js +143 -7
  92. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +72 -47
  93. package/dist/mjs/data-structures/binary-tree/avl-tree.js +102 -73
  94. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  95. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  96. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +244 -199
  97. package/dist/mjs/data-structures/binary-tree/binary-tree.js +483 -375
  98. package/dist/mjs/data-structures/binary-tree/bst.d.ts +92 -79
  99. package/dist/mjs/data-structures/binary-tree/bst.js +68 -76
  100. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +127 -57
  101. package/dist/mjs/data-structures/binary-tree/rb-tree.js +153 -100
  102. package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
  103. package/dist/mjs/data-structures/binary-tree/segment-tree.js +127 -10
  104. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +72 -58
  105. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +102 -86
  106. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +1 -78
  107. package/dist/mjs/data-structures/graph/abstract-graph.js +3 -188
  108. package/dist/mjs/data-structures/graph/directed-graph.d.ts +73 -0
  109. package/dist/mjs/data-structures/graph/directed-graph.js +131 -0
  110. package/dist/mjs/data-structures/graph/map-graph.d.ts +8 -0
  111. package/dist/mjs/data-structures/graph/map-graph.js +14 -0
  112. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +76 -7
  113. package/dist/mjs/data-structures/graph/undirected-graph.js +152 -19
  114. package/dist/mjs/data-structures/hash/hash-map.d.ts +254 -28
  115. package/dist/mjs/data-structures/hash/hash-map.js +353 -84
  116. package/dist/mjs/data-structures/heap/heap.d.ts +95 -25
  117. package/dist/mjs/data-structures/heap/heap.js +95 -26
  118. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +126 -63
  119. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +144 -80
  120. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +154 -106
  121. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +166 -117
  122. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +63 -36
  123. package/dist/mjs/data-structures/linked-list/skip-linked-list.js +63 -36
  124. package/dist/mjs/data-structures/matrix/matrix.d.ts +35 -4
  125. package/dist/mjs/data-structures/matrix/matrix.js +50 -11
  126. package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  127. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +10 -0
  128. package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  129. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +11 -0
  130. package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
  131. package/dist/mjs/data-structures/priority-queue/priority-queue.js +8 -0
  132. package/dist/mjs/data-structures/queue/deque.d.ts +139 -35
  133. package/dist/mjs/data-structures/queue/deque.js +205 -67
  134. package/dist/mjs/data-structures/queue/queue.d.ts +103 -49
  135. package/dist/mjs/data-structures/queue/queue.js +111 -49
  136. package/dist/mjs/data-structures/stack/stack.d.ts +51 -21
  137. package/dist/mjs/data-structures/stack/stack.js +58 -22
  138. package/dist/mjs/data-structures/tree/tree.d.ts +57 -3
  139. package/dist/mjs/data-structures/tree/tree.js +80 -14
  140. package/dist/mjs/data-structures/trie/trie.d.ts +135 -34
  141. package/dist/mjs/data-structures/trie/trie.js +156 -36
  142. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  143. package/dist/mjs/types/data-structures/hash/hash-map.d.ts +4 -3
  144. package/dist/mjs/types/utils/utils.d.ts +1 -0
  145. package/dist/umd/data-structure-typed.js +3121 -1583
  146. package/dist/umd/data-structure-typed.min.js +3 -3
  147. package/dist/umd/data-structure-typed.min.js.map +1 -1
  148. package/package.json +61 -55
  149. package/src/data-structures/base/iterable-base.ts +184 -19
  150. package/src/data-structures/binary-tree/avl-tree.ts +134 -100
  151. package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
  152. package/src/data-structures/binary-tree/binary-tree.ts +674 -671
  153. package/src/data-structures/binary-tree/bst.ts +127 -136
  154. package/src/data-structures/binary-tree/rb-tree.ts +199 -166
  155. package/src/data-structures/binary-tree/segment-tree.ts +145 -11
  156. package/src/data-structures/binary-tree/tree-multimap.ts +138 -115
  157. package/src/data-structures/graph/abstract-graph.ts +4 -211
  158. package/src/data-structures/graph/directed-graph.ts +152 -0
  159. package/src/data-structures/graph/map-graph.ts +15 -0
  160. package/src/data-structures/graph/undirected-graph.ts +171 -19
  161. package/src/data-structures/hash/hash-map.ts +389 -96
  162. package/src/data-structures/heap/heap.ts +97 -26
  163. package/src/data-structures/linked-list/doubly-linked-list.ts +156 -83
  164. package/src/data-structures/linked-list/singly-linked-list.ts +174 -120
  165. package/src/data-structures/linked-list/skip-linked-list.ts +63 -37
  166. package/src/data-structures/matrix/matrix.ts +52 -12
  167. package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
  168. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
  169. package/src/data-structures/priority-queue/priority-queue.ts +8 -0
  170. package/src/data-structures/queue/deque.ts +225 -70
  171. package/src/data-structures/queue/queue.ts +118 -49
  172. package/src/data-structures/stack/stack.ts +63 -23
  173. package/src/data-structures/tree/tree.ts +89 -15
  174. package/src/data-structures/trie/trie.ts +173 -38
  175. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  176. package/src/types/data-structures/hash/hash-map.ts +4 -3
  177. package/src/types/utils/utils.ts +2 -0
  178. package/test/performance/data-structures/graph/directed-graph.test.ts +4 -4
  179. package/test/performance/data-structures/queue/deque.test.ts +26 -25
  180. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +37 -0
  181. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +46 -17
  182. package/test/unit/data-structures/binary-tree/bst.test.ts +65 -1
  183. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +38 -1
  184. package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +37 -32
  185. package/test/unit/data-structures/graph/abstract-graph.test.ts +11 -0
  186. package/test/unit/data-structures/graph/directed-graph.test.ts +190 -5
  187. package/test/unit/data-structures/graph/undirected-graph.test.ts +263 -18
  188. package/test/unit/data-structures/hash/hash-map.test.ts +376 -353
  189. package/test/unit/data-structures/heap/heap.test.ts +18 -1
  190. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +24 -5
  191. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +20 -2
  192. package/test/unit/data-structures/linked-list/skip-list.test.ts +1 -1
  193. package/test/unit/data-structures/queue/deque.test.ts +65 -5
  194. package/test/unit/data-structures/queue/queue.test.ts +24 -5
  195. package/test/unit/data-structures/stack/stack.test.ts +17 -0
  196. package/test/unit/data-structures/trie/trie.test.ts +17 -0
@@ -9,17 +9,118 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.SegmentTree = exports.SegmentTreeNode = void 0;
11
11
  class SegmentTreeNode {
12
+ /**
13
+ * The constructor initializes the properties of a SegmentTreeNode object.
14
+ * @param {number} start - The `start` parameter represents the starting index of the segment covered
15
+ * by this node in a segment tree.
16
+ * @param {number} end - The `end` parameter represents the end index of the segment covered by this
17
+ * node in a segment tree.
18
+ * @param {number} sum - The `sum` parameter represents the sum of the values in the range covered by
19
+ * the segment tree node.
20
+ * @param {SegmentTreeNodeVal | undefined} [value] - The `value` parameter is an optional parameter
21
+ * of type `SegmentTreeNodeVal`. It represents the value associated with the segment tree node.
22
+ */
12
23
  constructor(start, end, sum, value) {
13
- this.start = 0;
14
- this.end = 0;
15
- this.value = undefined;
16
- this.sum = 0;
17
- this.left = undefined;
18
- this.right = undefined;
19
- this.start = start;
20
- this.end = end;
21
- this.sum = sum;
22
- this.value = value || undefined;
24
+ this._start = 0;
25
+ this._end = 0;
26
+ this._value = undefined;
27
+ this._sum = 0;
28
+ this._left = undefined;
29
+ this._right = undefined;
30
+ this._start = start;
31
+ this._end = end;
32
+ this._sum = sum;
33
+ this._value = value || undefined;
34
+ }
35
+ /**
36
+ * The function returns the value of the protected variable _start.
37
+ * @returns The start value, which is of type number.
38
+ */
39
+ get start() {
40
+ return this._start;
41
+ }
42
+ /**
43
+ * The above function sets the value of the "start" property.
44
+ * @param {number} value - The value parameter is of type number.
45
+ */
46
+ set start(value) {
47
+ this._start = value;
48
+ }
49
+ /**
50
+ * The function returns the value of the protected variable `_end`.
51
+ * @returns The value of the protected property `_end`.
52
+ */
53
+ get end() {
54
+ return this._end;
55
+ }
56
+ /**
57
+ * The above function sets the value of the "end" property.
58
+ * @param {number} value - The value parameter is a number that represents the new value for the end
59
+ * property.
60
+ */
61
+ set end(value) {
62
+ this._end = value;
63
+ }
64
+ /**
65
+ * The function returns the value of a segment tree node.
66
+ * @returns The value being returned is either a `SegmentTreeNodeVal` object or `undefined`.
67
+ */
68
+ get value() {
69
+ return this._value;
70
+ }
71
+ /**
72
+ * The function sets the value of a segment tree node.
73
+ * @param {SegmentTreeNodeVal | undefined} value - The `value` parameter is of type
74
+ * `SegmentTreeNodeVal` or `undefined`.
75
+ */
76
+ set value(value) {
77
+ this._value = value;
78
+ }
79
+ /**
80
+ * The function returns the value of the sum property.
81
+ * @returns The method is returning the value of the variable `_sum`.
82
+ */
83
+ get sum() {
84
+ return this._sum;
85
+ }
86
+ /**
87
+ * The above function sets the value of the sum property.
88
+ * @param {number} value - The parameter "value" is of type "number".
89
+ */
90
+ set sum(value) {
91
+ this._sum = value;
92
+ }
93
+ /**
94
+ * The function returns the left child of a segment tree node.
95
+ * @returns The `left` property of the `SegmentTreeNode` object is being returned. It is of type
96
+ * `SegmentTreeNode` or `undefined`.
97
+ */
98
+ get left() {
99
+ return this._left;
100
+ }
101
+ /**
102
+ * The function sets the value of the left property of a SegmentTreeNode object.
103
+ * @param {SegmentTreeNode | undefined} value - The value parameter is of type SegmentTreeNode or
104
+ * undefined.
105
+ */
106
+ set left(value) {
107
+ this._left = value;
108
+ }
109
+ /**
110
+ * The function returns the right child of a segment tree node.
111
+ * @returns The `getRight()` method is returning a value of type `SegmentTreeNode` or `undefined`.
112
+ */
113
+ get right() {
114
+ return this._right;
115
+ }
116
+ /**
117
+ * The function sets the right child of a segment tree node.
118
+ * @param {SegmentTreeNode | undefined} value - The `value` parameter is of type `SegmentTreeNode |
119
+ * undefined`. This means that it can accept either a `SegmentTreeNode` object or `undefined` as its
120
+ * value.
121
+ */
122
+ set right(value) {
123
+ this._right = value;
23
124
  }
24
125
  }
25
126
  exports.SegmentTreeNode = SegmentTreeNode;
@@ -49,15 +150,31 @@ class SegmentTree {
49
150
  this._values = [];
50
151
  }
51
152
  }
153
+ /**
154
+ * The function returns an array of numbers.
155
+ * @returns An array of numbers is being returned.
156
+ */
52
157
  get values() {
53
158
  return this._values;
54
159
  }
160
+ /**
161
+ * The function returns the value of the protected variable _start.
162
+ * @returns The start value, which is of type number.
163
+ */
55
164
  get start() {
56
165
  return this._start;
57
166
  }
167
+ /**
168
+ * The function returns the value of the protected variable `_end`.
169
+ * @returns The value of the protected property `_end`.
170
+ */
58
171
  get end() {
59
172
  return this._end;
60
173
  }
174
+ /**
175
+ * The function returns the root node of a segment tree.
176
+ * @returns The `root` property of the class `SegmentTreeNode` or `undefined` if it is not defined.
177
+ */
61
178
  get root() {
62
179
  return this._root;
63
180
  }
@@ -1 +1 @@
1
- {"version":3,"file":"segment-tree.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/segment-tree.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAIH,MAAa,eAAe;IAQ1B,YAAY,KAAa,EAAE,GAAW,EAAE,GAAW,EAAE,KAAsC;QAP3F,UAA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,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;gBACxC,CAAC;gBACD,OAAO,OAAO,GAAG,QAAQ,CAAC;YAC5B,CAAC;QACH,CAAC,CAAC;QACF,OAAO,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;CACF;AAnKD,kCAmKC"}
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;;;;;;;;;;OAUG;IACH,YAAY,KAAa,EAAE,GAAW,EAAE,GAAW,EAAE,KAAsC;QAOjF,WAAM,GAAG,CAAC,CAAC;QAkBX,SAAI,GAAG,CAAC,CAAC;QAmBT,WAAM,GAAmC,SAAS,CAAC;QAmBnD,SAAI,GAAG,CAAC,CAAC;QAkBT,UAAK,GAAgC,SAAS,CAAC;QAoB/C,WAAM,GAAgC,SAAS,CAAC;QApGxD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,MAAM,GAAG,KAAK,IAAI,SAAS,CAAC;IACnC,CAAC;IAID;;;OAGG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,IAAI,KAAK,CAAC,KAAa;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAID;;;OAGG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,IAAI,GAAG,CAAC,KAAa;QACnB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACpB,CAAC;IAID;;;OAGG;IACH,IAAI,KAAK;QACP,OAA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oBACN,OAAO,GAAG,CAAC;gBACb,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,qCAAqC;gBACrC,IAAI,OAAO,GAAG,CAAC,CAAC;gBAChB,IAAI,QAAQ,GAAG,CAAC,CAAC;gBACjB,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;oBACb,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;gBAClC,CAAC;gBACD,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;oBACd,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;gBACxC,CAAC;gBACD,OAAO,OAAO,GAAG,QAAQ,CAAC;YAC5B,CAAC;QACH,CAAC,CAAC;QACF,OAAO,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;CACF;AAnLD,kCAmLC"}
@@ -9,8 +9,7 @@ import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEnt
9
9
  import { IterationType } from '../../types';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  import { AVLTree, AVLTreeNode } from './avl-tree';
12
- export declare class TreeMultimapNode<K = any, V = any, N extends TreeMultimapNode<K, V, N> = TreeMultimapNodeNested<K, V>> extends AVLTreeNode<K, V, N> {
13
- count: number;
12
+ export declare class TreeMultimapNode<K = any, V = any, NODE extends TreeMultimapNode<K, V, NODE> = TreeMultimapNodeNested<K, V>> extends AVLTreeNode<K, V, NODE> {
14
13
  /**
15
14
  * The constructor function initializes a BinaryTreeNode object with a key, value, and count.
16
15
  * @param {K} key - The `key` parameter is of type `K` and represents the unique identifier
@@ -22,48 +21,73 @@ export declare class TreeMultimapNode<K = any, V = any, N extends TreeMultimapNo
22
21
  * parameter when creating a new instance of the `BinaryTreeNode` class.
23
22
  */
24
23
  constructor(key: K, value?: V, count?: number);
24
+ protected _count: number;
25
+ /**
26
+ * The function returns the value of the protected variable _count.
27
+ * @returns The count property of the object, which is of type number.
28
+ */
29
+ get count(): number;
30
+ /**
31
+ * The above function sets the value of the count property.
32
+ * @param {number} value - The value parameter is of type number, which means it can accept any
33
+ * numeric value.
34
+ */
35
+ set count(value: number);
25
36
  }
26
37
  /**
27
38
  * The only distinction between a TreeMultimap and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
28
39
  */
29
- export declare class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K, V, N> = TreeMultimapNode<K, V, TreeMultimapNodeNested<K, V>>, TREE extends TreeMultimap<K, V, N, TREE> = TreeMultimap<K, V, N, TreeMultimapNested<K, V, N>>> extends AVLTree<K, V, N, TREE> implements IBinaryTree<K, V, N, TREE> {
30
- constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, N>>, options?: TreeMultimapOptions<K>);
31
- private _count;
40
+ export declare class TreeMultimap<K = any, V = any, NODE extends TreeMultimapNode<K, V, NODE> = TreeMultimapNode<K, V, TreeMultimapNodeNested<K, V>>, TREE extends TreeMultimap<K, V, NODE, TREE> = TreeMultimap<K, V, NODE, TreeMultimapNested<K, V, NODE>>> extends AVLTree<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> {
41
+ constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: TreeMultimapOptions<K>);
42
+ protected _count: number;
43
+ /**
44
+ * The function calculates the sum of the count property of all nodes in a tree using depth-first
45
+ * search.
46
+ * @returns the sum of the count property of all nodes in the tree.
47
+ */
32
48
  get count(): number;
33
49
  /**
34
50
  * The function creates a new BSTNode with the given key, value, and count.
35
51
  * @param {K} key - The key parameter is the unique identifier for the binary tree node. It is used to
36
52
  * distinguish one node from another in the tree.
37
- * @param {N} value - The `value` parameter represents the value that will be stored in the binary search tree node.
53
+ * @param {NODE} value - The `value` parameter represents the value that will be stored in the binary search tree node.
38
54
  * @param {number} [count] - The "count" parameter is an optional parameter of type number. It represents the number of
39
55
  * occurrences of the value in the binary search tree node. If not provided, the count will default to 1.
40
56
  * @returns A new instance of the BSTNode class with the specified key, value, and count (if provided).
41
57
  */
42
- createNode(key: K, value?: V, count?: number): N;
58
+ createNode(key: K, value?: V, count?: number): NODE;
59
+ /**
60
+ * The function creates a new TreeMultimap object with the specified options and returns it.
61
+ * @param [options] - The `options` parameter is an optional object that contains additional
62
+ * configuration options for creating the `TreeMultimap` object. It can include properties such as
63
+ * `iterationType` and `variant`, which are used to specify the type of iteration and the variant of
64
+ * the tree, respectively. These properties can be
65
+ * @returns a new instance of the `TreeMultimap` class, with the provided options merged with the
66
+ * default options. The returned value is casted as `TREE`.
67
+ */
43
68
  createTree(options?: TreeMultimapOptions<K>): TREE;
44
69
  /**
45
- * The function `exemplarToNode` converts an keyOrNodeOrEntry object into a node object.
46
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, N>`, which means it
70
+ * The function `keyValueOrEntryToNode` converts an keyOrNodeOrEntry object into a node object.
71
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, NODE>`, which means it
47
72
  * can be one of the following:
48
73
  * @param {V} [value] - The `value` parameter is an optional argument that represents the value
49
74
  * associated with the node. It is of type `V`, which can be any data type. If no value is provided,
50
75
  * it defaults to `undefined`.
51
76
  * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
52
77
  * times the value should be added to the node. If not provided, it defaults to 1.
53
- * @returns a node of type `N` or `undefined`.
78
+ * @returns a node of type `NODE` or `undefined`.
54
79
  */
55
- exemplarToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>, value?: V, count?: number): N | undefined;
80
+ keyValueOrEntryToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined;
56
81
  /**
57
82
  * The function checks if an keyOrNodeOrEntry is an instance of the TreeMultimapNode class.
58
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, N>`.
83
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, NODE>`.
59
84
  * @returns a boolean value indicating whether the keyOrNodeOrEntry is an instance of the TreeMultimapNode
60
85
  * class.
61
86
  */
62
- isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>): keyOrNodeOrEntry is N;
87
+ isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntry is NODE;
63
88
  /**
64
89
  * Time Complexity: O(log n)
65
90
  * Space Complexity: O(1)
66
- * logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity. constant space, as it doesn't use additional data structures that scale with input size.
67
91
  */
68
92
  /**
69
93
  * Time Complexity: O(log n)
@@ -81,47 +105,13 @@ export declare class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K
81
105
  * @returns The method is returning either the newly inserted node or `undefined` if the insertion
82
106
  * was not successful.
83
107
  */
84
- add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>, value?: V, count?: number): boolean;
85
- /**
86
- * Time Complexity: O(k log n)
87
- * Space Complexity: O(1)
88
- * logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity. constant space, as it doesn't use additional data structures that scale with input size.
89
- */
90
- /**
91
- * Time Complexity: O(k log n)
92
- * Space Complexity: O(1)
93
- *
94
- * The function overrides the addMany method to add multiple keys, nodes, or entries to a data
95
- * structure.
96
- * @param keysOrNodesOrEntries - The parameter `keysOrNodesOrEntries` is an iterable that can contain
97
- * either keys, nodes, or entries.
98
- * @returns The method is returning an array of type `N | undefined`.
99
- */
100
- addMany(keysOrNodesOrEntries: Iterable<KeyOrNodeOrEntry<K, V, N>>): boolean[];
101
- /**
102
- * Time Complexity: O(n log n)
103
- * Space Complexity: O(n)
104
- * logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node. linear space, as it creates an array to store the sorted nodes.
105
- */
106
- /**
107
- * Time Complexity: O(n log n)
108
- * Space Complexity: O(n)
109
- *
110
- * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
111
- * tree using either a recursive or iterative approach.
112
- * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
113
- * type of iteration to use when building the balanced binary search tree. It can have two possible
114
- * values:
115
- * @returns a boolean value.
116
- */
117
- perfectlyBalance(iterationType?: IterationType): boolean;
108
+ add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
118
109
  /**
119
- * Time Complexity: O(k log n)
110
+ * Time Complexity: O(log n)
120
111
  * Space Complexity: O(1)
121
- * logarithmic time for each insertion, where "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted. This is because the method iterates through the keys and calls the add method for each. constant space, as it doesn't use additional data structures that scale with input size.
122
112
  */
123
113
  /**
124
- * Time Complexity: O(k log n)
114
+ * Time Complexity: O(log n)
125
115
  * Space Complexity: O(1)
126
116
  *
127
117
  * The `delete` function in TypeScript is used to remove a node from a binary tree, taking into
@@ -137,9 +127,9 @@ export declare class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K
137
127
  * being deleted. If set to true, the count of the node will not be considered and the node will be
138
128
  * deleted regardless of its count. If set to false (default), the count of the node will be
139
129
  * decremented by 1 and
140
- * @returns an array of `BinaryTreeDeleteResult<N>`.
130
+ * @returns an array of `BinaryTreeDeleteResult<NODE>`.
141
131
  */
142
- delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BinaryTreeDeleteResult<N>[];
132
+ delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BinaryTreeDeleteResult<NODE>[];
143
133
  /**
144
134
  * Time Complexity: O(1)
145
135
  * Space Complexity: O(1)
@@ -151,6 +141,22 @@ export declare class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K
151
141
  * The clear() function clears the contents of a data structure and sets the count to zero.
152
142
  */
153
143
  clear(): void;
144
+ /**
145
+ * Time Complexity: O(n log n)
146
+ * Space Complexity: O(log n)
147
+ */
148
+ /**
149
+ * Time Complexity: O(n log n)
150
+ * Space Complexity: O(log n)
151
+ *
152
+ * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
153
+ * tree using either a recursive or iterative approach.
154
+ * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
155
+ * type of iteration to use when building the balanced binary search tree. It can have two possible
156
+ * values:
157
+ * @returns a boolean value.
158
+ */
159
+ perfectlyBalance(iterationType?: IterationType): boolean;
154
160
  /**
155
161
  * Time complexity: O(n)
156
162
  * Space complexity: O(n)
@@ -165,13 +171,21 @@ export declare class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K
165
171
  clone(): TREE;
166
172
  /**
167
173
  * The `_swapProperties` function swaps the key, value, count, and height properties between two nodes.
168
- * @param {K | N | undefined} srcNode - The `srcNode` parameter represents the source node from
169
- * which the values will be swapped. It can be of type `K`, `N`, or `undefined`.
170
- * @param {K | N | undefined} destNode - The `destNode` parameter represents the destination
174
+ * @param {K | NODE | undefined} srcNode - The `srcNode` parameter represents the source node from
175
+ * which the values will be swapped. It can be of type `K`, `NODE`, or `undefined`.
176
+ * @param {K | NODE | undefined} destNode - The `destNode` parameter represents the destination
171
177
  * node where the values from the source node will be swapped to.
172
178
  * @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
173
179
  * if either `srcNode` or `destNode` is undefined.
174
180
  */
175
- protected _swapProperties(srcNode: BSTNKeyOrNode<K, N>, destNode: BSTNKeyOrNode<K, N>): N | undefined;
176
- protected _replaceNode(oldNode: N, newNode: N): N;
181
+ protected _swapProperties(srcNode: BSTNKeyOrNode<K, NODE>, destNode: BSTNKeyOrNode<K, NODE>): NODE | undefined;
182
+ /**
183
+ * The function replaces an old node with a new node and updates the count property of the new node.
184
+ * @param {NODE} oldNode - The `oldNode` parameter is of type `NODE` and represents the node that
185
+ * needs to be replaced in a data structure.
186
+ * @param {NODE} newNode - The `newNode` parameter is an object of type `NODE`.
187
+ * @returns The method is returning the result of calling the `_replaceNode` method from the
188
+ * superclass, after updating the `count` property of the `newNode` object.
189
+ */
190
+ protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
177
191
  }