data-structure-typed 0.8.18 → 1.3.0

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 (272) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +690 -2
  3. package/dist/bundle.js +2 -0
  4. package/dist/bundle.js.LICENSE.txt +13 -0
  5. package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +364 -0
  6. package/dist/data-structures/binary-tree/abstract-binary-tree.js +1308 -0
  7. package/dist/data-structures/binary-tree/avl-tree.d.ts +85 -18
  8. package/dist/data-structures/binary-tree/avl-tree.js +110 -37
  9. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +40 -2
  10. package/dist/data-structures/binary-tree/binary-indexed-tree.js +44 -2
  11. package/dist/data-structures/binary-tree/binary-tree.d.ts +29 -138
  12. package/dist/data-structures/binary-tree/binary-tree.js +27 -979
  13. package/dist/data-structures/binary-tree/bst.d.ts +118 -28
  14. package/dist/data-structures/binary-tree/bst.js +162 -124
  15. package/dist/data-structures/binary-tree/index.d.ts +1 -0
  16. package/dist/data-structures/binary-tree/index.js +1 -0
  17. package/dist/data-structures/binary-tree/rb-tree.d.ts +18 -1
  18. package/dist/data-structures/binary-tree/rb-tree.js +40 -2
  19. package/dist/data-structures/binary-tree/segment-tree.d.ts +63 -13
  20. package/dist/data-structures/binary-tree/segment-tree.js +80 -17
  21. package/dist/data-structures/binary-tree/tree-multiset.d.ts +213 -10
  22. package/dist/data-structures/binary-tree/tree-multiset.js +682 -9
  23. package/dist/data-structures/graph/abstract-graph.d.ts +270 -64
  24. package/dist/data-structures/graph/abstract-graph.js +365 -92
  25. package/dist/data-structures/graph/directed-graph.d.ts +175 -26
  26. package/dist/data-structures/graph/directed-graph.js +249 -95
  27. package/dist/data-structures/graph/index.d.ts +1 -0
  28. package/dist/data-structures/graph/index.js +1 -0
  29. package/dist/data-structures/graph/map-graph.d.ts +79 -0
  30. package/dist/data-structures/graph/map-graph.js +111 -0
  31. package/dist/data-structures/graph/undirected-graph.d.ts +111 -8
  32. package/dist/data-structures/graph/undirected-graph.js +154 -44
  33. package/dist/data-structures/hash/coordinate-map.d.ts +39 -2
  34. package/dist/data-structures/hash/coordinate-map.js +44 -3
  35. package/dist/data-structures/hash/coordinate-set.d.ts +32 -2
  36. package/dist/data-structures/hash/coordinate-set.js +34 -0
  37. package/dist/data-structures/hash/hash-table.d.ts +2 -1
  38. package/dist/data-structures/hash/hash-table.js +4 -0
  39. package/dist/data-structures/hash/index.d.ts +5 -0
  40. package/dist/data-structures/hash/index.js +5 -0
  41. package/dist/data-structures/hash/pair.d.ts +2 -1
  42. package/dist/data-structures/hash/pair.js +4 -0
  43. package/dist/data-structures/hash/tree-map.d.ts +2 -1
  44. package/dist/data-structures/hash/tree-map.js +4 -0
  45. package/dist/data-structures/hash/tree-set.d.ts +2 -1
  46. package/dist/data-structures/hash/tree-set.js +4 -0
  47. package/dist/data-structures/heap/heap.d.ts +62 -51
  48. package/dist/data-structures/heap/heap.js +106 -63
  49. package/dist/data-structures/heap/max-heap.d.ts +13 -4
  50. package/dist/data-structures/heap/max-heap.js +10 -2
  51. package/dist/data-structures/heap/min-heap.d.ts +14 -4
  52. package/dist/data-structures/heap/min-heap.js +11 -2
  53. package/dist/data-structures/index.d.ts +1 -0
  54. package/dist/data-structures/index.js +1 -0
  55. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +193 -57
  56. package/dist/data-structures/linked-list/doubly-linked-list.js +461 -194
  57. package/dist/data-structures/linked-list/index.d.ts +1 -0
  58. package/dist/data-structures/linked-list/index.js +1 -0
  59. package/dist/data-structures/linked-list/singly-linked-list.d.ts +117 -319
  60. package/dist/data-structures/linked-list/singly-linked-list.js +338 -557
  61. package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -1
  62. package/dist/data-structures/linked-list/skip-linked-list.js +4 -0
  63. package/dist/data-structures/matrix/matrix.d.ts +12 -0
  64. package/dist/data-structures/matrix/matrix.js +14 -0
  65. package/dist/data-structures/matrix/matrix2d.d.ts +87 -4
  66. package/dist/data-structures/matrix/matrix2d.js +91 -8
  67. package/dist/data-structures/matrix/navigator.d.ts +37 -16
  68. package/dist/data-structures/matrix/navigator.js +28 -0
  69. package/dist/data-structures/matrix/vector2d.d.ts +156 -29
  70. package/dist/data-structures/matrix/vector2d.js +184 -55
  71. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -1
  72. package/dist/data-structures/priority-queue/max-priority-queue.js +28 -4
  73. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +12 -1
  74. package/dist/data-structures/priority-queue/min-priority-queue.js +29 -4
  75. package/dist/data-structures/priority-queue/priority-queue.d.ts +166 -22
  76. package/dist/data-structures/priority-queue/priority-queue.js +219 -75
  77. package/dist/data-structures/queue/deque.d.ts +141 -13
  78. package/dist/data-structures/queue/deque.js +151 -7
  79. package/dist/data-structures/queue/queue.d.ts +68 -42
  80. package/dist/data-structures/queue/queue.js +95 -51
  81. package/dist/data-structures/stack/stack.d.ts +30 -36
  82. package/dist/data-structures/stack/stack.js +31 -37
  83. package/dist/data-structures/tree/index.d.ts +1 -0
  84. package/dist/data-structures/tree/index.js +17 -0
  85. package/dist/data-structures/tree/tree.d.ts +14 -0
  86. package/dist/{types/utils.js → data-structures/tree/tree.js} +26 -19
  87. package/dist/data-structures/trie/trie.d.ts +39 -6
  88. package/dist/data-structures/trie/trie.js +81 -12
  89. package/dist/index.d.ts +3 -0
  90. package/dist/index.js +3 -0
  91. package/dist/interfaces/abstract-binary-tree.d.ts +90 -0
  92. package/dist/interfaces/abstract-binary-tree.js +2 -0
  93. package/dist/interfaces/abstract-graph.d.ts +17 -0
  94. package/dist/interfaces/abstract-graph.js +2 -0
  95. package/dist/interfaces/avl-tree.d.ts +9 -0
  96. package/dist/interfaces/avl-tree.js +2 -0
  97. package/dist/interfaces/binary-tree.d.ts +6 -0
  98. package/dist/interfaces/binary-tree.js +2 -0
  99. package/dist/interfaces/bst.d.ts +17 -0
  100. package/dist/interfaces/bst.js +2 -0
  101. package/dist/interfaces/directed-graph.d.ts +12 -0
  102. package/dist/interfaces/directed-graph.js +2 -0
  103. package/dist/interfaces/doubly-linked-list.js +2 -0
  104. package/dist/interfaces/heap.js +2 -0
  105. package/dist/interfaces/index.d.ts +15 -0
  106. package/dist/interfaces/index.js +31 -0
  107. package/dist/interfaces/navigator.js +2 -0
  108. package/dist/interfaces/priority-queue.js +2 -0
  109. package/dist/interfaces/rb-tree.d.ts +8 -0
  110. package/dist/interfaces/rb-tree.js +2 -0
  111. package/dist/interfaces/segment-tree.js +2 -0
  112. package/dist/interfaces/singly-linked-list.js +2 -0
  113. package/dist/interfaces/tree-multiset.d.ts +7 -0
  114. package/dist/interfaces/tree-multiset.js +2 -0
  115. package/dist/interfaces/undirected-graph.d.ts +5 -0
  116. package/dist/interfaces/undirected-graph.js +2 -0
  117. package/dist/types/data-structures/abstract-binary-tree.d.ts +34 -0
  118. package/dist/types/data-structures/abstract-binary-tree.js +25 -0
  119. package/dist/types/data-structures/abstract-graph.d.ts +11 -0
  120. package/dist/types/data-structures/abstract-graph.js +2 -0
  121. package/dist/types/data-structures/avl-tree.d.ts +4 -0
  122. package/dist/types/data-structures/avl-tree.js +2 -0
  123. package/dist/types/data-structures/binary-tree.d.ts +4 -0
  124. package/dist/types/data-structures/binary-tree.js +2 -0
  125. package/dist/types/data-structures/bst.d.ts +13 -0
  126. package/dist/types/data-structures/bst.js +9 -0
  127. package/dist/types/data-structures/directed-graph.d.ts +6 -0
  128. package/dist/types/data-structures/directed-graph.js +9 -0
  129. package/dist/types/data-structures/doubly-linked-list.js +2 -0
  130. package/dist/types/data-structures/heap.d.ts +3 -0
  131. package/dist/types/data-structures/heap.js +2 -0
  132. package/dist/types/data-structures/index.d.ts +13 -7
  133. package/dist/types/data-structures/index.js +31 -0
  134. package/dist/types/data-structures/map-graph.d.ts +1 -0
  135. package/dist/types/data-structures/map-graph.js +2 -0
  136. package/dist/types/data-structures/navigator.d.ts +14 -0
  137. package/dist/types/data-structures/navigator.js +2 -0
  138. package/dist/types/data-structures/priority-queue.d.ts +7 -0
  139. package/dist/types/data-structures/priority-queue.js +2 -0
  140. package/dist/types/data-structures/rb-tree.d.ts +8 -0
  141. package/dist/types/data-structures/rb-tree.js +8 -0
  142. package/dist/types/data-structures/segment-tree.d.ts +1 -0
  143. package/dist/types/data-structures/segment-tree.js +2 -0
  144. package/dist/types/data-structures/singly-linked-list.js +2 -0
  145. package/dist/types/data-structures/tree-multiset.d.ts +4 -0
  146. package/dist/types/data-structures/tree-multiset.js +2 -0
  147. package/dist/types/helpers.d.ts +1 -0
  148. package/dist/types/helpers.js +2 -0
  149. package/dist/types/index.d.ts +2 -0
  150. package/dist/types/index.js +2 -0
  151. package/dist/types/utils/index.d.ts +2 -0
  152. package/dist/types/utils/index.js +18 -0
  153. package/dist/types/utils/utils.d.ts +7 -0
  154. package/dist/types/utils/utils.js +2 -0
  155. package/dist/types/utils/validate-type.d.ts +19 -0
  156. package/dist/types/utils/validate-type.js +2 -0
  157. package/dist/utils/index.js +17 -0
  158. package/dist/utils/utils.d.ts +19 -0
  159. package/dist/{data-structures/trampoline.js → utils/utils.js} +26 -12
  160. package/package.json +106 -55
  161. package/.idea/data-structure-typed.iml +0 -12
  162. package/.idea/modules.xml +0 -8
  163. package/.idea/vcs.xml +0 -6
  164. package/dist/data-structures/trampoline.d.ts +0 -25
  165. package/dist/types/data-structures/binary-tree/aa-tree.d.ts +0 -2
  166. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -21
  167. package/dist/types/data-structures/binary-tree/b-tree.d.ts +0 -2
  168. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -8
  169. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -140
  170. package/dist/types/data-structures/binary-tree/bst.d.ts +0 -32
  171. package/dist/types/data-structures/binary-tree/index.d.ts +0 -4
  172. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +0 -2
  173. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +0 -33
  174. package/dist/types/data-structures/binary-tree/splay-tree.d.ts +0 -2
  175. package/dist/types/data-structures/binary-tree/tree-multiset.d.ts +0 -11
  176. package/dist/types/data-structures/binary-tree/two-three-tree.d.ts +0 -2
  177. package/dist/types/data-structures/graph/abstract-graph.d.ts +0 -126
  178. package/dist/types/data-structures/graph/directed-graph.d.ts +0 -51
  179. package/dist/types/data-structures/graph/index.d.ts +0 -3
  180. package/dist/types/data-structures/graph/undirected-graph.d.ts +0 -24
  181. package/dist/types/data-structures/hash/coordinate-map.d.ts +0 -8
  182. package/dist/types/data-structures/hash/coordinate-set.d.ts +0 -7
  183. package/dist/types/data-structures/hash/index.d.ts +0 -1
  184. package/dist/types/data-structures/heap/heap.d.ts +0 -72
  185. package/dist/types/data-structures/heap/index.d.ts +0 -3
  186. package/dist/types/data-structures/heap/max-heap.d.ts +0 -14
  187. package/dist/types/data-structures/heap/min-heap.d.ts +0 -14
  188. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -59
  189. package/dist/types/data-structures/linked-list/index.d.ts +0 -2
  190. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +0 -358
  191. package/dist/types/data-structures/matrix/index.d.ts +0 -3
  192. package/dist/types/data-structures/matrix/matrix.d.ts +0 -9
  193. package/dist/types/data-structures/matrix/matrix2d.d.ts +0 -25
  194. package/dist/types/data-structures/matrix/navigator.d.ts +0 -31
  195. package/dist/types/data-structures/matrix/vector2d.d.ts +0 -74
  196. package/dist/types/data-structures/priority-queue/index.d.ts +0 -3
  197. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -4
  198. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -4
  199. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +0 -36
  200. package/dist/types/data-structures/queue/deque.d.ts +0 -37
  201. package/dist/types/data-structures/queue/index.d.ts +0 -1
  202. package/dist/types/data-structures/queue/queue.d.ts +0 -76
  203. package/dist/types/data-structures/stack/index.d.ts +0 -1
  204. package/dist/types/data-structures/stack/stack.d.ts +0 -69
  205. package/dist/types/data-structures/trampoline.d.ts +0 -25
  206. package/dist/types/data-structures/trie/index.d.ts +0 -1
  207. package/dist/types/data-structures/trie/trie.d.ts +0 -28
  208. package/dist/types/types/utils.d.ts +0 -46
  209. package/dist/types/utils.d.ts +0 -46
  210. package/dist/utils.d.ts +0 -122
  211. package/dist/utils.js +0 -569
  212. package/src/data-structures/binary-tree/aa-tree.ts +0 -3
  213. package/src/data-structures/binary-tree/avl-tree.ts +0 -232
  214. package/src/data-structures/binary-tree/b-tree.ts +0 -3
  215. package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -33
  216. package/src/data-structures/binary-tree/binary-tree.ts +0 -1088
  217. package/src/data-structures/binary-tree/bst.ts +0 -404
  218. package/src/data-structures/binary-tree/index.ts +0 -11
  219. package/src/data-structures/binary-tree/rb-tree.ts +0 -3
  220. package/src/data-structures/binary-tree/segment-tree.ts +0 -164
  221. package/src/data-structures/binary-tree/splay-tree.ts +0 -3
  222. package/src/data-structures/binary-tree/tree-multiset.ts +0 -21
  223. package/src/data-structures/binary-tree/two-three-tree.ts +0 -3
  224. package/src/data-structures/graph/abstract-graph.ts +0 -789
  225. package/src/data-structures/graph/directed-graph.ts +0 -322
  226. package/src/data-structures/graph/index.ts +0 -3
  227. package/src/data-structures/graph/undirected-graph.ts +0 -154
  228. package/src/data-structures/hash/coordinate-map.ts +0 -24
  229. package/src/data-structures/hash/coordinate-set.ts +0 -20
  230. package/src/data-structures/hash/hash-table.ts +0 -1
  231. package/src/data-structures/hash/index.ts +0 -1
  232. package/src/data-structures/heap/heap.ts +0 -136
  233. package/src/data-structures/heap/index.ts +0 -3
  234. package/src/data-structures/heap/max-heap.ts +0 -22
  235. package/src/data-structures/heap/min-heap.ts +0 -24
  236. package/src/data-structures/index.ts +0 -11
  237. package/src/data-structures/linked-list/doubly-linked-list.ts +0 -258
  238. package/src/data-structures/linked-list/index.ts +0 -2
  239. package/src/data-structures/linked-list/singly-linked-list.ts +0 -750
  240. package/src/data-structures/linked-list/skip-linked-list.ts +0 -1
  241. package/src/data-structures/matrix/index.ts +0 -4
  242. package/src/data-structures/matrix/matrix.ts +0 -13
  243. package/src/data-structures/matrix/matrix2d.ts +0 -125
  244. package/src/data-structures/matrix/navigator.ts +0 -99
  245. package/src/data-structures/matrix/vector2d.ts +0 -189
  246. package/src/data-structures/priority-queue/index.ts +0 -3
  247. package/src/data-structures/priority-queue/max-priority-queue.ts +0 -12
  248. package/src/data-structures/priority-queue/min-priority-queue.ts +0 -12
  249. package/src/data-structures/priority-queue/priority-queue.ts +0 -208
  250. package/src/data-structures/queue/deque.ts +0 -139
  251. package/src/data-structures/queue/index.ts +0 -2
  252. package/src/data-structures/queue/queue.ts +0 -123
  253. package/src/data-structures/stack/index.ts +0 -1
  254. package/src/data-structures/stack/stack.ts +0 -104
  255. package/src/data-structures/trampoline.ts +0 -91
  256. package/src/data-structures/trie/index.ts +0 -1
  257. package/src/data-structures/trie/trie.ts +0 -153
  258. package/src/index.ts +0 -1
  259. package/src/types/index.ts +0 -1
  260. package/src/types/patches/index.d.ts +0 -0
  261. package/src/types/utils.ts +0 -158
  262. package/src/utils.ts +0 -605
  263. package/tsconfig.json +0 -53
  264. /package/dist/{types/data-structures/hash/hash-table.d.ts → interfaces/doubly-linked-list.d.ts} +0 -0
  265. /package/dist/{types/data-structures/hash/pair.d.ts → interfaces/heap.d.ts} +0 -0
  266. /package/dist/{types/data-structures/hash/tree-map.d.ts → interfaces/navigator.d.ts} +0 -0
  267. /package/dist/{types/data-structures/hash/tree-set.d.ts → interfaces/priority-queue.d.ts} +0 -0
  268. /package/dist/{types/data-structures/linked-list/skip-linked-list.d.ts → interfaces/segment-tree.d.ts} +0 -0
  269. /package/{src/data-structures/hash/pair.ts → dist/interfaces/singly-linked-list.d.ts} +0 -0
  270. /package/{src/data-structures/hash/tree-map.ts → dist/types/data-structures/doubly-linked-list.d.ts} +0 -0
  271. /package/{src/data-structures/hash/tree-set.ts → dist/types/data-structures/singly-linked-list.d.ts} +0 -0
  272. /package/dist/{types/types → utils}/index.d.ts +0 -0
@@ -1,16 +1,689 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TreeMultiSet = void 0;
4
- const bst_1 = require("./bst");
5
- class TreeMultiSet extends bst_1.BST {
3
+ exports.TreeMultiset = exports.TreeMultisetNode = void 0;
4
+ const types_1 = require("../../types");
5
+ const avl_tree_1 = require("./avl-tree");
6
+ class TreeMultisetNode extends avl_tree_1.AVLTreeNode {
7
+ /**
8
+ * The constructor function initializes a BinaryTreeNode object with an id, value, and count.
9
+ * @param {BinaryTreeNodeId} id - The `id` parameter is of type `BinaryTreeNodeId` and represents the unique identifier
10
+ * of the binary tree node.
11
+ * @param {T} [val] - The `val` parameter is an optional parameter of type `T`. It represents the value of the binary
12
+ * tree node. If no value is provided, it will be `undefined`.
13
+ * @param {number} [count=1] - The `count` parameter is a number that represents the number of times a particular value
14
+ * occurs in a binary tree node. It has a default value of 1, which means that if no value is provided for the `count`
15
+ * parameter when creating a new instance of the `BinaryTreeNode` class,
16
+ */
17
+ constructor(id, val, count = 1) {
18
+ super(id, val);
19
+ this._count = count;
20
+ }
21
+ get count() {
22
+ return this._count;
23
+ }
24
+ set count(v) {
25
+ this._count = v;
26
+ }
27
+ }
28
+ exports.TreeMultisetNode = TreeMultisetNode;
29
+ /**
30
+ * 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.
31
+ */
32
+ class TreeMultiset extends avl_tree_1.AVLTree {
33
+ /**
34
+ * The constructor function for a TreeMultiset class in TypeScript, which extends another class and sets an option to
35
+ * merge duplicated values.
36
+ * @param {TreeMultisetOptions} [options] - An optional object that contains additional configuration options for the
37
+ * TreeMultiset.
38
+ */
39
+ constructor(options) {
40
+ super(Object.assign({}, options));
41
+ this._count = 0;
42
+ }
43
+ get count() {
44
+ return this._count;
45
+ }
46
+ /**
47
+ * The function creates a new BSTNode with the given id, value, and count.
48
+ * @param {BinaryTreeNodeId} id - The id parameter is the unique identifier for the binary tree node. It is used to
49
+ * distinguish one node from another in the tree.
50
+ * @param {N} val - The `val` parameter represents the value that will be stored in the binary search tree node.
51
+ * @param {number} [count] - The "count" parameter is an optional parameter of type number. It represents the number of
52
+ * occurrences of the value in the binary search tree node. If not provided, the count will default to 1.
53
+ * @returns A new instance of the BSTNode class with the specified id, value, and count (if provided).
54
+ */
6
55
  createNode(id, val, count) {
7
- return new bst_1.BSTNode(id, val, count);
56
+ return new TreeMultisetNode(id, val, count);
57
+ }
58
+ /**
59
+ * The function swaps the location of two nodes in a tree data structure.
60
+ * @param {N} srcNode - The source node that we want to swap with the destination node.
61
+ * @param {N} destNode - The `destNode` parameter represents the destination node where the values from `srcNode` will
62
+ * be swapped with.
63
+ * @returns the `destNode` after swapping its values with the `srcNode`.
64
+ */
65
+ swapLocation(srcNode, destNode) {
66
+ const { id, val, count, height } = destNode;
67
+ const tempNode = this.createNode(id, val, count);
68
+ if (tempNode) {
69
+ tempNode.height = height;
70
+ destNode.id = srcNode.id;
71
+ destNode.val = srcNode.val;
72
+ destNode.count = srcNode.count;
73
+ destNode.height = srcNode.height;
74
+ srcNode.id = tempNode.id;
75
+ srcNode.val = tempNode.val;
76
+ srcNode.count = tempNode.count;
77
+ srcNode.height = tempNode.height;
78
+ }
79
+ return destNode;
80
+ }
81
+ /**
82
+ * The `add` function adds a new node to a binary search tree, maintaining the tree's properties and balancing if
83
+ * necessary.
84
+ * @param {BinaryTreeNodeId | N} idOrNode - The `idOrNode` parameter can be either a `BinaryTreeNodeId` or a `N` (which
85
+ * represents a `BinaryTreeNode`).
86
+ * @param [val] - The `val` parameter represents the value to be added to the binary tree node.
87
+ * @param {number} [count] - The `count` parameter is an optional parameter that specifies the number of times the
88
+ * value should be added to the binary tree. If the `count` parameter is not provided, it defaults to 1.
89
+ * @returns The method `add` returns either the inserted node (`N`), `null`, or `undefined`.
90
+ */
91
+ add(idOrNode, val, count) {
92
+ count = count !== null && count !== void 0 ? count : 1;
93
+ let inserted = undefined, newNode;
94
+ if (idOrNode instanceof TreeMultisetNode) {
95
+ newNode = this.createNode(idOrNode.id, idOrNode.val, idOrNode.count);
96
+ }
97
+ else if (idOrNode === null) {
98
+ newNode = null;
99
+ }
100
+ else {
101
+ newNode = this.createNode(idOrNode, val, count);
102
+ }
103
+ if (!this.root) {
104
+ this._setRoot(newNode);
105
+ this._setSize(this.size + 1);
106
+ newNode && this._setCount(this.count + newNode.count);
107
+ inserted = this.root;
108
+ }
109
+ else {
110
+ let cur = this.root;
111
+ let traversing = true;
112
+ while (traversing) {
113
+ if (cur) {
114
+ if (newNode) {
115
+ if (this._compare(cur.id, newNode.id) === types_1.CP.eq) {
116
+ cur.val = newNode.val;
117
+ cur.count += newNode.count;
118
+ this._setCount(this.count + newNode.count);
119
+ traversing = false;
120
+ inserted = cur;
121
+ }
122
+ else if (this._compare(cur.id, newNode.id) === types_1.CP.gt) {
123
+ // Traverse left of the node
124
+ if (cur.left === undefined) {
125
+ //Add to the left of the current node
126
+ cur.left = newNode;
127
+ this._setSize(this.size + 1);
128
+ this._setCount(this.count + newNode.count);
129
+ traversing = false;
130
+ inserted = cur.left;
131
+ }
132
+ else {
133
+ //Traverse the left of the current node
134
+ if (cur.left)
135
+ cur = cur.left;
136
+ }
137
+ }
138
+ else if (this._compare(cur.id, newNode.id) === types_1.CP.lt) {
139
+ // Traverse right of the node
140
+ if (cur.right === undefined) {
141
+ //Add to the right of the current node
142
+ cur.right = newNode;
143
+ this._setSize(this.size + 1);
144
+ this._setCount(this.count + newNode.count);
145
+ traversing = false;
146
+ inserted = (cur.right);
147
+ }
148
+ else {
149
+ //Traverse the left of the current node
150
+ if (cur.right)
151
+ cur = cur.right;
152
+ }
153
+ }
154
+ }
155
+ else {
156
+ // TODO may need to support null inserted
157
+ }
158
+ }
159
+ else {
160
+ traversing = false;
161
+ }
162
+ }
163
+ }
164
+ if (inserted)
165
+ this._balancePath(inserted);
166
+ return inserted;
167
+ }
168
+ /**
169
+ * 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
170
+ * node.
171
+ * @param {N | null} newNode - The `newNode` parameter represents the node that needs to be added to the tree. It can
172
+ * be either a node object (`N`) or `null`.
173
+ * @param {N} parent - The `parent` parameter represents the parent node to which the new node will be added as a
174
+ * child.
175
+ * @returns The method returns either the `parent.left`, `parent.right`, or `undefined`.
176
+ */
177
+ _addTo(newNode, parent) {
178
+ if (parent) {
179
+ if (parent.left === undefined) {
180
+ parent.left = newNode;
181
+ if (newNode !== null) {
182
+ this._setSize(this.size + 1);
183
+ this._setCount(this.count + newNode.count);
184
+ }
185
+ return parent.left;
186
+ }
187
+ else if (parent.right === undefined) {
188
+ parent.right = newNode;
189
+ if (newNode !== null) {
190
+ this._setSize(this.size + 1);
191
+ this._setCount(this.count + newNode.count);
192
+ }
193
+ return parent.right;
194
+ }
195
+ else {
196
+ return;
197
+ }
198
+ }
199
+ else {
200
+ return;
201
+ }
202
+ }
203
+ /**
204
+ * The `addMany` function adds multiple nodes to a binary tree and returns an array of the inserted nodes.
205
+ * @param {BinaryTreeNodeId[] | N[]} idsOrNodes - An array of BinaryTreeNodeId objects or N objects. These objects
206
+ * represent the IDs or nodes of the binary tree where the values will be added.
207
+ * @param {N['val'][]} [data] - Optional array of values to be associated with each node being added. If provided, the
208
+ * length of the `data` array should be equal to the length of the `idsOrNodes` array.
209
+ * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
210
+ */
211
+ addMany(idsOrNodes, data) {
212
+ var _a;
213
+ // TODO not sure addMany not be run multi times
214
+ const inserted = [];
215
+ const map = new Map();
216
+ for (const idOrNode of idsOrNodes)
217
+ map.set(idOrNode, ((_a = map.get(idOrNode)) !== null && _a !== void 0 ? _a : 0) + 1);
218
+ for (let i = 0; i < idsOrNodes.length; i++) {
219
+ const idOrNode = idsOrNodes[i];
220
+ if (map.has(idOrNode)) {
221
+ if (idOrNode instanceof TreeMultisetNode) {
222
+ inserted.push(this.add(idOrNode.id, idOrNode.val, idOrNode.count));
223
+ continue;
224
+ }
225
+ if (idOrNode === null) {
226
+ inserted.push(this.add(NaN, null, 0));
227
+ continue;
228
+ }
229
+ const val = data === null || data === void 0 ? void 0 : data[i], count = map.get(idOrNode);
230
+ inserted.push(this.add(idOrNode, val, count));
231
+ map.delete(idOrNode);
232
+ }
233
+ }
234
+ return inserted;
235
+ }
236
+ /**
237
+ * The `perfectlyBalance` function takes a binary tree, performs a depth-first search to sort the nodes, and then
238
+ * constructs a balanced binary search tree using either a recursive or iterative approach.
239
+ * @returns The function `perfectlyBalance()` returns a boolean value.
240
+ */
241
+ perfectlyBalance() {
242
+ const sorted = this.DFS('in', 'node'), n = sorted.length;
243
+ if (sorted.length < 1)
244
+ return false;
245
+ this.clear();
246
+ if (this.loopType === types_1.LoopType.RECURSIVE) {
247
+ const buildBalanceBST = (l, r) => {
248
+ if (l > r)
249
+ return;
250
+ const m = l + Math.floor((r - l) / 2);
251
+ const midNode = sorted[m];
252
+ this.add(midNode.id, midNode.val, midNode.count);
253
+ buildBalanceBST(l, m - 1);
254
+ buildBalanceBST(m + 1, r);
255
+ };
256
+ buildBalanceBST(0, n - 1);
257
+ return true;
258
+ }
259
+ else {
260
+ const stack = [[0, n - 1]];
261
+ while (stack.length > 0) {
262
+ const popped = stack.pop();
263
+ if (popped) {
264
+ const [l, r] = popped;
265
+ if (l <= r) {
266
+ const m = l + Math.floor((r - l) / 2);
267
+ const midNode = sorted[m];
268
+ this.add(midNode.id, midNode.val, midNode.count);
269
+ stack.push([m + 1, r]);
270
+ stack.push([l, m - 1]);
271
+ }
272
+ }
273
+ }
274
+ return true;
275
+ }
276
+ }
277
+ /**
278
+ * The `remove` function removes a node from a binary search tree and returns the deleted node along with the parent
279
+ * node that needs to be balanced.
280
+ * @param {N | BinaryTreeNodeId | null} nodeOrId - The `nodeOrId` parameter can be one of the following:
281
+ * @param {boolean} [ignoreCount] - The `ignoreCount` parameter is an optional boolean parameter that determines
282
+ * whether to ignore the count of the node being removed. If `ignoreCount` is set to `true`, the count of the node will
283
+ * not be taken into account when removing it. If `ignoreCount` is set to `false
284
+ * @returns The function `remove` returns an array of `BinaryTreeDeletedResult<N>` objects.
285
+ */
286
+ remove(nodeOrId, ignoreCount) {
287
+ const bstDeletedResult = [];
288
+ if (!this.root)
289
+ return bstDeletedResult;
290
+ const curr = this.get(nodeOrId);
291
+ if (!curr)
292
+ return bstDeletedResult;
293
+ const parent = (curr === null || curr === void 0 ? void 0 : curr.parent) ? curr.parent : null;
294
+ let needBalanced = null, orgCurrent = curr;
295
+ if (curr.count > 1 && !ignoreCount) {
296
+ curr.count--;
297
+ this._setCount(this.count - 1);
298
+ }
299
+ else {
300
+ if (!curr.left) {
301
+ if (!parent) {
302
+ if (curr.right !== undefined)
303
+ this._setRoot(curr.right);
304
+ }
305
+ else {
306
+ const { familyPosition: fp } = curr;
307
+ if (fp === types_1.FamilyPosition.LEFT || fp === types_1.FamilyPosition.ROOT_LEFT) {
308
+ parent.left = curr.right;
309
+ }
310
+ else if (fp === types_1.FamilyPosition.RIGHT || fp === types_1.FamilyPosition.ROOT_RIGHT) {
311
+ parent.right = curr.right;
312
+ }
313
+ needBalanced = parent;
314
+ }
315
+ }
316
+ else {
317
+ const leftSubTreeRightMost = curr.left ? this.getRightMost(curr.left) : null;
318
+ if (leftSubTreeRightMost) {
319
+ const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
320
+ orgCurrent = this.swapLocation(curr, leftSubTreeRightMost);
321
+ if (parentOfLeftSubTreeMax) {
322
+ if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost) {
323
+ parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
324
+ }
325
+ else {
326
+ parentOfLeftSubTreeMax.left = leftSubTreeRightMost.left;
327
+ }
328
+ needBalanced = parentOfLeftSubTreeMax;
329
+ }
330
+ }
331
+ }
332
+ this._setSize(this.size - 1);
333
+ // TODO How to handle when the count of target node is lesser than current node's count
334
+ this._setCount(this.count - orgCurrent.count);
335
+ }
336
+ bstDeletedResult.push({ deleted: orgCurrent, needBalanced });
337
+ if (needBalanced) {
338
+ this._balancePath(needBalanced);
339
+ }
340
+ return bstDeletedResult;
341
+ }
342
+ /**
343
+ * The function `getSubTreeCount` calculates the number of nodes and the sum of their counts in a subtree, using either
344
+ * recursive or iterative traversal.
345
+ * @param {N | null | undefined} subTreeRoot - The `subTreeRoot` parameter represents the root node of a subtree in a
346
+ * binary tree.
347
+ * @returns The function `getSubTreeCount` returns an array `[number, number]`.
348
+ */
349
+ getSubTreeCount(subTreeRoot) {
350
+ const res = [0, 0];
351
+ if (!subTreeRoot)
352
+ return res;
353
+ if (this.loopType === types_1.LoopType.RECURSIVE) {
354
+ const _traverse = (cur) => {
355
+ res[0]++;
356
+ res[1] += cur.count;
357
+ cur.left && _traverse(cur.left);
358
+ cur.right && _traverse(cur.right);
359
+ };
360
+ _traverse(subTreeRoot);
361
+ return res;
362
+ }
363
+ else {
364
+ const stack = [subTreeRoot];
365
+ while (stack.length > 0) {
366
+ const cur = stack.pop();
367
+ res[0]++;
368
+ res[1] += cur.count;
369
+ cur.right && stack.push(cur.right);
370
+ cur.left && stack.push(cur.left);
371
+ }
372
+ return res;
373
+ }
374
+ }
375
+ /**
376
+ * The function `subTreeSumCount` calculates the sum of the `count` property of each node in a subtree, either
377
+ * recursively or iteratively.
378
+ * @param {N | BinaryTreeNodeId | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a subtree
379
+ * in a binary tree. It can be either a `BinaryTreeNodeId` (a unique identifier for a node in the binary tree) or
380
+ * `null` if the subtree is empty.
381
+ * @returns the sum of the count values of all nodes in the subtree rooted at `subTreeRoot`.
382
+ */
383
+ subTreeSumCount(subTreeRoot) {
384
+ if (typeof subTreeRoot === 'number')
385
+ subTreeRoot = this.get(subTreeRoot, 'id');
386
+ if (!subTreeRoot)
387
+ return 0;
388
+ let sum = 0;
389
+ if (this.loopType === types_1.LoopType.RECURSIVE) {
390
+ const _traverse = (cur) => {
391
+ sum += cur.count;
392
+ cur.left && _traverse(cur.left);
393
+ cur.right && _traverse(cur.right);
394
+ };
395
+ _traverse(subTreeRoot);
396
+ }
397
+ else {
398
+ const stack = [subTreeRoot];
399
+ while (stack.length > 0) {
400
+ const cur = stack.pop();
401
+ sum += cur.count;
402
+ cur.right && stack.push(cur.right);
403
+ cur.left && stack.push(cur.left);
404
+ }
405
+ }
406
+ return sum;
407
+ }
408
+ /**
409
+ * The function `subTreeAddCount` recursively or iteratively traverses a binary tree and adds a given delta value to
410
+ * the `count` property of each node.
411
+ * @param {N | BinaryTreeNodeId | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a subtree
412
+ * in a binary tree. It can be either a `BinaryTreeNodeId` (a unique identifier for a node in the binary tree), a
413
+ * `BinaryTreeNode` object, or `null` if the subtree is empty.
414
+ * @param {number} delta - The delta parameter is a number that represents the amount by which the count of each node
415
+ * in the subtree should be increased or decreased.
416
+ * @returns a boolean value.
417
+ */
418
+ subTreeAddCount(subTreeRoot, delta) {
419
+ if (typeof subTreeRoot === 'number')
420
+ subTreeRoot = this.get(subTreeRoot, 'id');
421
+ if (!subTreeRoot)
422
+ return false;
423
+ const _addByProperty = (cur) => {
424
+ cur.count += delta;
425
+ this._setCount(this.count + delta);
426
+ };
427
+ if (this.loopType === types_1.LoopType.RECURSIVE) {
428
+ const _traverse = (cur) => {
429
+ _addByProperty(cur);
430
+ cur.left && _traverse(cur.left);
431
+ cur.right && _traverse(cur.right);
432
+ };
433
+ _traverse(subTreeRoot);
434
+ }
435
+ else {
436
+ const stack = [subTreeRoot];
437
+ while (stack.length > 0) {
438
+ const cur = stack.pop();
439
+ _addByProperty(cur);
440
+ cur.right && stack.push(cur.right);
441
+ cur.left && stack.push(cur.left);
442
+ }
443
+ }
444
+ return true;
445
+ }
446
+ /**
447
+ * The function `getNodesByCount` returns an array of nodes that have a specific count property, either recursively or
448
+ * using a queue.
449
+ * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a
450
+ * `N`. It represents the property of the nodes that you want to search for.
451
+ * @param {boolean} [onlyOne] - The `onlyOne` parameter is an optional boolean parameter that determines whether to
452
+ * return only one node that matches the `nodeProperty` or all nodes that match the `nodeProperty`. If `onlyOne` is set
453
+ * to `true`, the function will return only one node. If `onlyOne`
454
+ * @returns an array of nodes that match the given nodeProperty.
455
+ */
456
+ getNodesByCount(nodeProperty, onlyOne) {
457
+ if (!this.root)
458
+ return [];
459
+ const result = [];
460
+ if (this.loopType === types_1.LoopType.RECURSIVE) {
461
+ const _traverse = (cur) => {
462
+ if (cur.count === nodeProperty) {
463
+ result.push(cur);
464
+ if (onlyOne)
465
+ return;
466
+ }
467
+ if (!cur.left && !cur.right)
468
+ return;
469
+ cur.left && _traverse(cur.left);
470
+ cur.right && _traverse(cur.right);
471
+ };
472
+ _traverse(this.root);
473
+ }
474
+ else {
475
+ const queue = [this.root];
476
+ while (queue.length > 0) {
477
+ const cur = queue.shift();
478
+ if (cur) {
479
+ if (cur.count === nodeProperty) {
480
+ result.push(cur);
481
+ if (onlyOne)
482
+ return result;
483
+ }
484
+ cur.left && queue.push(cur.left);
485
+ cur.right && queue.push(cur.right);
486
+ }
487
+ }
488
+ }
489
+ return result;
490
+ }
491
+ /**
492
+ * The BFSCount function returns an array of counts from a breadth-first search of nodes.
493
+ * @returns The BFSCount() function returns an array of numbers, specifically the count property of each node in the
494
+ * BFS traversal.
495
+ */
496
+ BFSCount() {
497
+ const nodes = super.BFS('node');
498
+ return nodes.map(node => node.count);
499
+ }
500
+ /**
501
+ * The function "listLevelsCount" takes a node and returns an array of arrays, where each inner array contains the
502
+ * count property of each node at that level.
503
+ * @param {N | null} node - The parameter `node` is of type `N | null`. This means that it can either be an instance of
504
+ * the class `N` or `null`.
505
+ * @returns a 2D array of numbers. Each inner array represents a level in the binary tree, and each number in the inner
506
+ * array represents the count property of a node in that level.
507
+ */
508
+ listLevelsCount(node) {
509
+ const levels = super.listLevels(node, 'node');
510
+ return levels.map(level => level.map(node => node.count));
511
+ }
512
+ /**
513
+ * The `morrisCount` function returns an array of counts for each node in a binary tree, based on a specified traversal
514
+ * pattern.
515
+ * @param {'in' | 'pre' | 'post'} [pattern] - The `pattern` parameter is an optional parameter that specifies the
516
+ * traversal pattern for the Morris traversal algorithm. It can have one of three values: 'in', 'pre', or 'post'.
517
+ * @returns The function `morrisCount` returns an array of numbers.
518
+ */
519
+ morrisCount(pattern) {
520
+ pattern = pattern || 'in';
521
+ const nodes = super.morris(pattern, 'node');
522
+ return nodes.map(node => node.count);
523
+ }
524
+ /**
525
+ * The function DFSIterativeCount performs a depth-first search iteratively and returns an array of count values for
526
+ * each node.
527
+ * @param {'in' | 'pre' | 'post'} [pattern] - The "pattern" parameter is a string that specifies the traversal order
528
+ * for the Depth-First Search (DFS) algorithm. It can have one of three values: 'in', 'pre', or 'post'.
529
+ * @param {NodeOrPropertyName} [nodeOrPropertyName] - The `nodeOrPropertyName` parameter is an optional parameter that
530
+ * specifies whether to return the nodes or the property names during the depth-first search traversal. If it is set to
531
+ * `'node'`, the function will return the nodes. If it is set to `'property'`, the function will return the property
532
+ * @returns The DFSIterativeCount method returns an array of numbers.
533
+ */
534
+ DFSIterativeCount(pattern, nodeOrPropertyName) {
535
+ pattern = pattern !== null && pattern !== void 0 ? pattern : 'in';
536
+ const nodes = super.DFSIterative(pattern, 'node');
537
+ return nodes.map(node => node.count);
538
+ }
539
+ /**
540
+ * The DFSCount function returns an array of counts for each node in a depth-first search traversal.
541
+ * @param {DFSOrderPattern} [pattern] - The `pattern` parameter is an optional parameter that specifies the order in
542
+ * which the Depth-First Search (DFS) algorithm should traverse the nodes. It can have one of the following values:
543
+ * @param [nodeOrPropertyName] - The parameter `nodeOrPropertyName` is used to specify whether you want to retrieve the
544
+ * nodes themselves or a specific property of the nodes. If you pass `'count'` as the value for `nodeOrPropertyName`,
545
+ * the function will return an array of the `count` property of each node.
546
+ * @returns The DFSCount method returns an array of numbers representing the count property of each node in the DFS
547
+ * traversal.
548
+ */
549
+ DFSCount(pattern, nodeOrPropertyName) {
550
+ pattern = pattern !== null && pattern !== void 0 ? pattern : 'in';
551
+ const nodes = super.DFS(pattern, 'node');
552
+ return nodes.map(node => node.count);
553
+ }
554
+ /**
555
+ * The `lesserSumCount` function calculates the sum of the counts of all nodes in a binary tree that have a lesser
556
+ * value than a given node.
557
+ * @param {N | BinaryTreeNodeId | null} beginNode - The `beginNode` parameter can be one of the following:
558
+ * @returns the sum of the counts of nodes in the binary tree that have a lesser value than the given beginNode.
559
+ */
560
+ lesserSumCount(beginNode) {
561
+ if (typeof beginNode === 'number')
562
+ beginNode = this.get(beginNode, 'id');
563
+ if (!beginNode)
564
+ return 0;
565
+ if (!this.root)
566
+ return 0;
567
+ const id = beginNode.id;
568
+ let sum = 0;
569
+ if (this.loopType === types_1.LoopType.RECURSIVE) {
570
+ const _traverse = (cur) => {
571
+ const compared = this._compare(cur.id, id);
572
+ if (compared === types_1.CP.eq) {
573
+ if (cur.right)
574
+ sum += this.subTreeSumCount(cur.right);
575
+ return;
576
+ }
577
+ else if (compared === types_1.CP.lt) {
578
+ if (cur.left)
579
+ sum += this.subTreeSumCount(cur.left);
580
+ sum += cur.count;
581
+ if (cur.right)
582
+ _traverse(cur.right);
583
+ else
584
+ return;
585
+ }
586
+ else {
587
+ if (cur.left)
588
+ _traverse(cur.left);
589
+ else
590
+ return;
591
+ }
592
+ };
593
+ _traverse(this.root);
594
+ }
595
+ else {
596
+ const queue = [this.root];
597
+ while (queue.length > 0) {
598
+ const cur = queue.shift();
599
+ if (cur) {
600
+ const compared = this._compare(cur.id, id);
601
+ if (compared === types_1.CP.eq) {
602
+ if (cur.right)
603
+ sum += this.subTreeSumCount(cur.right);
604
+ return sum;
605
+ }
606
+ else if (compared === types_1.CP.lt) { // todo maybe a bug
607
+ if (cur.left)
608
+ sum += this.subTreeSumCount(cur.left);
609
+ sum += cur.count;
610
+ if (cur.right)
611
+ queue.push(cur.right);
612
+ else
613
+ return sum;
614
+ }
615
+ else {
616
+ if (cur.left)
617
+ queue.push(cur.left);
618
+ else
619
+ return sum;
620
+ }
621
+ }
622
+ }
623
+ }
624
+ return sum;
625
+ }
626
+ /**
627
+ * The function `allGreaterNodesAddCount` updates the count property of all nodes in a binary tree that have an ID
628
+ * greater than a given ID by a specified delta value.
629
+ * @param {N | BinaryTreeNodeId | null} node - The `node` parameter can be one of the following:
630
+ * @param {number} delta - The `delta` parameter is a number that represents the amount by which the `count` property
631
+ * of each node should be increased.
632
+ * @returns a boolean value.
633
+ */
634
+ allGreaterNodesAddCount(node, delta) {
635
+ if (typeof node === 'number')
636
+ node = this.get(node, 'id');
637
+ if (!node)
638
+ return false;
639
+ const id = node.id;
640
+ if (!this.root)
641
+ return false;
642
+ if (this.loopType === types_1.LoopType.RECURSIVE) {
643
+ const _traverse = (cur) => {
644
+ const compared = this._compare(cur.id, id);
645
+ if (compared === types_1.CP.gt)
646
+ cur.count += delta;
647
+ if (!cur.left && !cur.right)
648
+ return;
649
+ if (cur.left && this._compare(cur.left.id, id) === types_1.CP.gt)
650
+ _traverse(cur.left);
651
+ if (cur.right && this._compare(cur.right.id, id) === types_1.CP.gt)
652
+ _traverse(cur.right);
653
+ };
654
+ _traverse(this.root);
655
+ return true;
656
+ }
657
+ else {
658
+ const queue = [this.root];
659
+ while (queue.length > 0) {
660
+ const cur = queue.shift();
661
+ if (cur) {
662
+ const compared = this._compare(cur.id, id);
663
+ if (compared === types_1.CP.gt)
664
+ cur.count += delta;
665
+ if (cur.left && this._compare(cur.left.id, id) === types_1.CP.gt)
666
+ queue.push(cur.left);
667
+ if (cur.right && this._compare(cur.right.id, id) === types_1.CP.gt)
668
+ queue.push(cur.right);
669
+ }
670
+ }
671
+ return true;
672
+ }
8
673
  }
9
- put(id, val, count) {
10
- return super.put(id, val, count);
674
+ /**
675
+ * The clear() function clears the data and sets the count to 0.
676
+ */
677
+ clear() {
678
+ super.clear();
679
+ this._setCount(0);
11
680
  }
12
- remove(id, isUpdateAllLeftSum) {
13
- return super.remove(id, isUpdateAllLeftSum);
681
+ /**
682
+ * The function "_setCount" is used to set the value of the "_count" property.
683
+ * @param {number} v - number
684
+ */
685
+ _setCount(v) {
686
+ this._count = v;
14
687
  }
15
688
  }
16
- exports.TreeMultiSet = TreeMultiSet;
689
+ exports.TreeMultiset = TreeMultiset;