data-structure-typed 1.17.4 → 1.18.5

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 (293) hide show
  1. package/README.md +193 -66
  2. package/backup/recursive-type/src/assets/complexities-diff.jpg +0 -0
  3. package/backup/recursive-type/src/assets/data-structure-complexities.jpg +0 -0
  4. package/backup/recursive-type/src/assets/logo.png +0 -0
  5. package/backup/recursive-type/src/assets/overview-diagram-of-data-structures.png +0 -0
  6. package/backup/recursive-type/src/data-structures/binary-tree/aa-tree.ts +3 -0
  7. package/backup/recursive-type/src/data-structures/binary-tree/avl-tree.ts +288 -0
  8. package/backup/recursive-type/src/data-structures/binary-tree/b-tree.ts +3 -0
  9. package/backup/recursive-type/src/data-structures/binary-tree/binary-indexed-tree.ts +78 -0
  10. package/backup/recursive-type/src/data-structures/binary-tree/binary-tree.ts +1502 -0
  11. package/backup/recursive-type/src/data-structures/binary-tree/bst.ts +503 -0
  12. package/backup/recursive-type/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
  13. package/backup/recursive-type/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
  14. package/backup/recursive-type/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
  15. package/backup/recursive-type/src/data-structures/binary-tree/index.ts +11 -0
  16. package/backup/recursive-type/src/data-structures/binary-tree/rb-tree.ts +110 -0
  17. package/backup/recursive-type/src/data-structures/binary-tree/segment-tree.ts +243 -0
  18. package/backup/recursive-type/src/data-structures/binary-tree/splay-tree.ts +3 -0
  19. package/backup/recursive-type/src/data-structures/binary-tree/tree-multiset.ts +55 -0
  20. package/backup/recursive-type/src/data-structures/binary-tree/two-three-tree.ts +3 -0
  21. package/backup/recursive-type/src/data-structures/diagrams/README.md +5 -0
  22. package/backup/recursive-type/src/data-structures/graph/abstract-graph.ts +985 -0
  23. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg +0 -0
  24. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-list.jpg +0 -0
  25. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg +0 -0
  26. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-matrix.jpg +0 -0
  27. package/backup/recursive-type/src/data-structures/graph/diagrams/dfs-can-do.jpg +0 -0
  28. package/backup/recursive-type/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg +0 -0
  29. package/backup/recursive-type/src/data-structures/graph/diagrams/edge-list.jpg +0 -0
  30. package/backup/recursive-type/src/data-structures/graph/diagrams/max-flow.jpg +0 -0
  31. package/backup/recursive-type/src/data-structures/graph/diagrams/mst.jpg +0 -0
  32. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
  33. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
  34. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
  35. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
  36. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan.webp +0 -0
  37. package/backup/recursive-type/src/data-structures/graph/directed-graph.ts +478 -0
  38. package/backup/recursive-type/src/data-structures/graph/index.ts +3 -0
  39. package/backup/recursive-type/src/data-structures/graph/undirected-graph.ts +293 -0
  40. package/backup/recursive-type/src/data-structures/hash/coordinate-map.ts +67 -0
  41. package/backup/recursive-type/src/data-structures/hash/coordinate-set.ts +56 -0
  42. package/backup/recursive-type/src/data-structures/hash/hash-table.ts +3 -0
  43. package/backup/recursive-type/src/data-structures/hash/index.ts +6 -0
  44. package/backup/recursive-type/src/data-structures/hash/pair.ts +3 -0
  45. package/backup/recursive-type/src/data-structures/hash/tree-map.ts +3 -0
  46. package/backup/recursive-type/src/data-structures/hash/tree-set.ts +3 -0
  47. package/backup/recursive-type/src/data-structures/heap/heap.ts +176 -0
  48. package/backup/recursive-type/src/data-structures/heap/index.ts +3 -0
  49. package/backup/recursive-type/src/data-structures/heap/max-heap.ts +31 -0
  50. package/backup/recursive-type/src/data-structures/heap/min-heap.ts +34 -0
  51. package/backup/recursive-type/src/data-structures/index.ts +15 -0
  52. package/backup/recursive-type/src/data-structures/interfaces/abstract-graph.ts +42 -0
  53. package/backup/recursive-type/src/data-structures/interfaces/avl-tree.ts +1 -0
  54. package/backup/recursive-type/src/data-structures/interfaces/binary-tree.ts +56 -0
  55. package/backup/recursive-type/src/data-structures/interfaces/bst.ts +1 -0
  56. package/backup/recursive-type/src/data-structures/interfaces/directed-graph.ts +15 -0
  57. package/backup/recursive-type/src/data-structures/interfaces/doubly-linked-list.ts +1 -0
  58. package/backup/recursive-type/src/data-structures/interfaces/heap.ts +1 -0
  59. package/backup/recursive-type/src/data-structures/interfaces/index.ts +13 -0
  60. package/backup/recursive-type/src/data-structures/interfaces/navigator.ts +1 -0
  61. package/backup/recursive-type/src/data-structures/interfaces/priority-queue.ts +1 -0
  62. package/backup/recursive-type/src/data-structures/interfaces/segment-tree.ts +1 -0
  63. package/backup/recursive-type/src/data-structures/interfaces/singly-linked-list.ts +1 -0
  64. package/backup/recursive-type/src/data-structures/interfaces/tree-multiset.ts +1 -0
  65. package/backup/recursive-type/src/data-structures/interfaces/undirected-graph.ts +3 -0
  66. package/backup/recursive-type/src/data-structures/linked-list/doubly-linked-list.ts +573 -0
  67. package/backup/recursive-type/src/data-structures/linked-list/index.ts +3 -0
  68. package/backup/recursive-type/src/data-structures/linked-list/singly-linked-list.ts +490 -0
  69. package/backup/recursive-type/src/data-structures/linked-list/skip-linked-list.ts +3 -0
  70. package/backup/recursive-type/src/data-structures/matrix/index.ts +4 -0
  71. package/backup/recursive-type/src/data-structures/matrix/matrix.ts +27 -0
  72. package/backup/recursive-type/src/data-structures/matrix/matrix2d.ts +208 -0
  73. package/backup/recursive-type/src/data-structures/matrix/navigator.ts +122 -0
  74. package/backup/recursive-type/src/data-structures/matrix/vector2d.ts +316 -0
  75. package/backup/recursive-type/src/data-structures/priority-queue/index.ts +3 -0
  76. package/backup/recursive-type/src/data-structures/priority-queue/max-priority-queue.ts +49 -0
  77. package/backup/recursive-type/src/data-structures/priority-queue/min-priority-queue.ts +50 -0
  78. package/backup/recursive-type/src/data-structures/priority-queue/priority-queue.ts +354 -0
  79. package/backup/recursive-type/src/data-structures/queue/deque.ts +251 -0
  80. package/backup/recursive-type/src/data-structures/queue/index.ts +2 -0
  81. package/backup/recursive-type/src/data-structures/queue/queue.ts +120 -0
  82. package/backup/recursive-type/src/data-structures/stack/index.ts +1 -0
  83. package/backup/recursive-type/src/data-structures/stack/stack.ts +98 -0
  84. package/backup/recursive-type/src/data-structures/tree/index.ts +1 -0
  85. package/backup/recursive-type/src/data-structures/tree/tree.ts +80 -0
  86. package/backup/recursive-type/src/data-structures/trie/index.ts +1 -0
  87. package/backup/recursive-type/src/data-structures/trie/trie.ts +227 -0
  88. package/backup/recursive-type/src/data-structures/types/abstract-graph.ts +5 -0
  89. package/backup/recursive-type/src/data-structures/types/avl-tree.ts +8 -0
  90. package/backup/recursive-type/src/data-structures/types/binary-tree.ts +10 -0
  91. package/backup/recursive-type/src/data-structures/types/bst.ts +6 -0
  92. package/backup/recursive-type/src/data-structures/types/directed-graph.ts +8 -0
  93. package/backup/recursive-type/src/data-structures/types/doubly-linked-list.ts +1 -0
  94. package/backup/recursive-type/src/data-structures/types/heap.ts +5 -0
  95. package/backup/recursive-type/src/data-structures/types/index.ts +12 -0
  96. package/backup/recursive-type/src/data-structures/types/navigator.ts +13 -0
  97. package/backup/recursive-type/src/data-structures/types/priority-queue.ts +9 -0
  98. package/backup/recursive-type/src/data-structures/types/segment-tree.ts +1 -0
  99. package/backup/recursive-type/src/data-structures/types/singly-linked-list.ts +1 -0
  100. package/backup/recursive-type/src/data-structures/types/tree-multiset.ts +1 -0
  101. package/backup/recursive-type/src/index.ts +1 -0
  102. package/backup/recursive-type/src/utils/index.ts +2 -0
  103. package/backup/recursive-type/src/utils/types/index.ts +1 -0
  104. package/backup/recursive-type/src/utils/types/utils.ts +6 -0
  105. package/backup/recursive-type/src/utils/utils.ts +78 -0
  106. package/dist/data-structures/binary-tree/avl-tree.d.ts +19 -25
  107. package/dist/data-structures/binary-tree/avl-tree.js +12 -20
  108. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -1
  109. package/dist/data-structures/binary-tree/binary-indexed-tree.js +10 -0
  110. package/dist/data-structures/binary-tree/binary-tree.d.ts +135 -161
  111. package/dist/data-structures/binary-tree/binary-tree.js +192 -164
  112. package/dist/data-structures/binary-tree/bst.d.ts +21 -21
  113. package/dist/data-structures/binary-tree/bst.js +33 -36
  114. package/dist/data-structures/binary-tree/rb-tree.d.ts +1 -2
  115. package/dist/data-structures/binary-tree/rb-tree.js +68 -5
  116. package/dist/data-structures/binary-tree/segment-tree.d.ts +17 -39
  117. package/dist/data-structures/binary-tree/segment-tree.js +34 -47
  118. package/dist/data-structures/binary-tree/tree-multiset.d.ts +9 -8
  119. package/dist/data-structures/binary-tree/tree-multiset.js +7 -6
  120. package/dist/data-structures/graph/abstract-graph.d.ts +56 -71
  121. package/dist/data-structures/graph/abstract-graph.js +87 -92
  122. package/dist/data-structures/graph/directed-graph.d.ts +128 -105
  123. package/dist/data-structures/graph/directed-graph.js +161 -121
  124. package/dist/data-structures/graph/undirected-graph.d.ts +81 -62
  125. package/dist/data-structures/graph/undirected-graph.js +99 -78
  126. package/dist/data-structures/hash/coordinate-map.d.ts +1 -5
  127. package/dist/data-structures/hash/coordinate-map.js +3 -9
  128. package/dist/data-structures/hash/coordinate-set.d.ts +2 -6
  129. package/dist/data-structures/hash/coordinate-set.js +3 -9
  130. package/dist/data-structures/hash/hash-table.d.ts +2 -1
  131. package/dist/data-structures/hash/hash-table.js +7 -0
  132. package/dist/data-structures/hash/pair.d.ts +2 -1
  133. package/dist/data-structures/hash/pair.js +7 -0
  134. package/dist/data-structures/hash/tree-map.d.ts +2 -1
  135. package/dist/data-structures/hash/tree-map.js +7 -0
  136. package/dist/data-structures/hash/tree-set.d.ts +2 -1
  137. package/dist/data-structures/hash/tree-set.js +7 -0
  138. package/dist/data-structures/heap/heap.d.ts +0 -14
  139. package/dist/data-structures/heap/heap.js +3 -27
  140. package/dist/data-structures/index.d.ts +1 -0
  141. package/dist/data-structures/index.js +1 -0
  142. package/dist/data-structures/interfaces/abstract-graph.d.ts +22 -0
  143. package/dist/data-structures/interfaces/abstract-graph.js +2 -0
  144. package/dist/data-structures/interfaces/avl-tree.d.ts +1 -0
  145. package/dist/data-structures/interfaces/avl-tree.js +2 -0
  146. package/dist/data-structures/interfaces/binary-tree.d.ts +27 -0
  147. package/dist/data-structures/interfaces/binary-tree.js +2 -0
  148. package/dist/data-structures/interfaces/bst.d.ts +1 -0
  149. package/dist/data-structures/interfaces/bst.js +2 -0
  150. package/dist/data-structures/interfaces/directed-graph.d.ts +9 -0
  151. package/dist/data-structures/interfaces/directed-graph.js +2 -0
  152. package/dist/data-structures/interfaces/doubly-linked-list.d.ts +1 -0
  153. package/dist/data-structures/interfaces/doubly-linked-list.js +2 -0
  154. package/dist/data-structures/interfaces/heap.d.ts +1 -0
  155. package/dist/data-structures/interfaces/heap.js +2 -0
  156. package/dist/data-structures/interfaces/index.d.ts +13 -0
  157. package/dist/data-structures/interfaces/index.js +29 -0
  158. package/dist/data-structures/interfaces/navigator.d.ts +1 -0
  159. package/dist/data-structures/interfaces/navigator.js +2 -0
  160. package/dist/data-structures/interfaces/priority-queue.d.ts +1 -0
  161. package/dist/data-structures/interfaces/priority-queue.js +2 -0
  162. package/dist/data-structures/interfaces/segment-tree.d.ts +1 -0
  163. package/dist/data-structures/interfaces/segment-tree.js +2 -0
  164. package/dist/data-structures/interfaces/singly-linked-list.d.ts +1 -0
  165. package/dist/data-structures/interfaces/singly-linked-list.js +2 -0
  166. package/dist/data-structures/interfaces/tree-multiset.d.ts +1 -0
  167. package/dist/data-structures/interfaces/tree-multiset.js +2 -0
  168. package/dist/data-structures/interfaces/undirected-graph.d.ts +2 -0
  169. package/dist/data-structures/interfaces/undirected-graph.js +2 -0
  170. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +1 -3
  171. package/dist/data-structures/linked-list/doubly-linked-list.js +12 -18
  172. package/dist/data-structures/linked-list/singly-linked-list.d.ts +1 -2
  173. package/dist/data-structures/linked-list/singly-linked-list.js +12 -15
  174. package/dist/data-structures/priority-queue/priority-queue.d.ts +1 -1
  175. package/dist/data-structures/priority-queue/priority-queue.js +4 -4
  176. package/dist/data-structures/queue/deque.d.ts +5 -5
  177. package/dist/data-structures/queue/deque.js +6 -6
  178. package/dist/data-structures/queue/queue.d.ts +1 -1
  179. package/dist/data-structures/stack/stack.d.ts +1 -1
  180. package/dist/data-structures/tree/tree.d.ts +12 -4
  181. package/dist/data-structures/tree/tree.js +44 -12
  182. package/dist/data-structures/trie/trie.d.ts +3 -3
  183. package/dist/data-structures/trie/trie.js +10 -10
  184. package/dist/data-structures/types/abstract-graph.d.ts +1 -20
  185. package/dist/data-structures/types/avl-tree.d.ts +5 -4
  186. package/dist/data-structures/types/binary-tree.d.ts +6 -5
  187. package/dist/data-structures/types/bst.d.ts +4 -3
  188. package/dist/data-structures/types/directed-graph.d.ts +5 -9
  189. package/dist/data-structures/types/directed-graph.js +7 -0
  190. package/dist/data-structures/types/doubly-linked-list.d.ts +1 -1
  191. package/dist/data-structures/types/heap.d.ts +2 -2
  192. package/dist/data-structures/types/index.d.ts +0 -1
  193. package/dist/data-structures/types/index.js +0 -1
  194. package/dist/data-structures/types/navigator.d.ts +2 -2
  195. package/dist/data-structures/types/priority-queue.d.ts +2 -2
  196. package/dist/data-structures/types/tree-multiset.d.ts +3 -4
  197. package/docs/assets/search.js +1 -1
  198. package/docs/classes/AVLTree.html +552 -405
  199. package/docs/classes/AVLTreeNode.html +107 -242
  200. package/docs/classes/AaTree.html +18 -13
  201. package/docs/classes/AbstractEdge.html +77 -68
  202. package/docs/classes/AbstractGraph.html +223 -115
  203. package/docs/classes/AbstractVertex.html +71 -45
  204. package/docs/classes/ArrayDeque.html +31 -26
  205. package/docs/classes/BST.html +543 -391
  206. package/docs/classes/BSTNode.html +107 -236
  207. package/docs/classes/BTree.html +18 -13
  208. package/docs/classes/BinaryIndexedTree.html +56 -21
  209. package/docs/classes/BinaryTree.html +564 -355
  210. package/docs/classes/BinaryTreeNode.html +146 -199
  211. package/docs/classes/Character.html +21 -16
  212. package/docs/classes/CoordinateMap.html +49 -52
  213. package/docs/classes/CoordinateSet.html +50 -53
  214. package/docs/classes/Deque.html +51 -68
  215. package/docs/classes/DirectedEdge.html +98 -103
  216. package/docs/classes/DirectedGraph.html +449 -210
  217. package/docs/classes/DirectedVertex.html +63 -52
  218. package/docs/classes/DoublyLinkedList.html +56 -71
  219. package/docs/classes/DoublyLinkedListNode.html +28 -23
  220. package/docs/classes/HashTable.html +155 -0
  221. package/docs/classes/Heap.html +33 -109
  222. package/docs/classes/HeapItem.html +25 -20
  223. package/docs/classes/Matrix2D.html +33 -28
  224. package/docs/classes/MatrixNTI2D.html +21 -16
  225. package/docs/classes/MaxHeap.html +33 -114
  226. package/docs/classes/MaxPriorityQueue.html +71 -61
  227. package/docs/classes/MinHeap.html +33 -114
  228. package/docs/classes/MinPriorityQueue.html +71 -61
  229. package/docs/classes/Navigator.html +28 -23
  230. package/docs/classes/ObjectDeque.html +66 -51
  231. package/docs/classes/{RBTree.html → Pair.html} +25 -20
  232. package/docs/classes/PriorityQueue.html +66 -56
  233. package/docs/classes/Queue.html +33 -28
  234. package/docs/classes/SegmentTree.html +129 -57
  235. package/docs/classes/SegmentTreeNode.html +62 -140
  236. package/docs/classes/SinglyLinkedList.html +53 -58
  237. package/docs/classes/SinglyLinkedListNode.html +25 -20
  238. package/docs/classes/SkipLinkedList.html +18 -13
  239. package/docs/classes/SplayTree.html +18 -13
  240. package/docs/classes/Stack.html +31 -26
  241. package/docs/classes/TreeMap.html +155 -0
  242. package/docs/classes/TreeMultiSet.html +541 -388
  243. package/docs/classes/TreeNode.html +125 -35
  244. package/docs/classes/TreeSet.html +155 -0
  245. package/docs/classes/Trie.html +30 -25
  246. package/docs/classes/TrieNode.html +33 -28
  247. package/docs/classes/TwoThreeTree.html +18 -13
  248. package/docs/classes/UndirectedEdge.html +87 -80
  249. package/docs/classes/UndirectedGraph.html +356 -178
  250. package/docs/classes/UndirectedVertex.html +63 -52
  251. package/docs/classes/Vector2D.html +45 -40
  252. package/docs/enums/CP.html +21 -16
  253. package/docs/enums/FamilyPosition.html +21 -16
  254. package/docs/enums/LoopType.html +20 -15
  255. package/docs/{interfaces/AVLTreeDeleted.html → enums/TopologicalProperty.html} +47 -44
  256. package/docs/index.html +203 -69
  257. package/docs/interfaces/{PriorityQueueOptions.html → IBinaryTree.html} +49 -40
  258. package/docs/interfaces/IBinaryTreeNode.html +383 -0
  259. package/docs/interfaces/IDirectedGraph.html +24 -19
  260. package/docs/interfaces/IGraph.html +122 -89
  261. package/docs/interfaces/{HeapOptions.html → IUNDirectedGraph.html} +26 -53
  262. package/docs/modules.html +33 -23
  263. package/docs/types/{ToThunkFn.html → AVLTreeDeleted.html} +31 -22
  264. package/docs/types/BSTComparator.html +18 -13
  265. package/docs/types/BSTDeletedResult.html +23 -18
  266. package/docs/types/BinaryTreeDeleted.html +23 -18
  267. package/docs/types/BinaryTreeNodeId.html +18 -13
  268. package/docs/types/BinaryTreeNodePropertyName.html +18 -13
  269. package/docs/types/DFSOrderPattern.html +18 -13
  270. package/docs/types/DijkstraResult.html +18 -13
  271. package/docs/types/Direction.html +18 -13
  272. package/docs/types/{DoublyLinkedListGetBy.html → EdgeId.html} +22 -17
  273. package/docs/types/{TrlFn.html → HeapOptions.html} +33 -20
  274. package/docs/types/{TrlAsyncFn.html → NavigatorParams.html} +46 -20
  275. package/docs/types/NodeOrPropertyName.html +18 -13
  276. package/docs/types/PriorityQueueComparator.html +18 -13
  277. package/docs/types/PriorityQueueDFSOrderPattern.html +18 -13
  278. package/docs/types/{SpecifyOptional.html → PriorityQueueOptions.html} +32 -20
  279. package/docs/types/RecursiveAVLTreeNode.html +135 -0
  280. package/docs/types/RecursiveBSTNode.html +135 -0
  281. package/docs/types/RecursiveBinaryTreeNode.html +135 -0
  282. package/docs/types/ResultByProperty.html +21 -16
  283. package/docs/types/ResultsByProperty.html +21 -16
  284. package/docs/types/SegmentTreeNodeVal.html +18 -13
  285. package/docs/types/TopologicalStatus.html +18 -13
  286. package/docs/types/TreeMultiSetDeletedResult.html +23 -18
  287. package/docs/types/Turning.html +18 -13
  288. package/docs/types/VertexId.html +18 -13
  289. package/notes/note.md +12 -1
  290. package/package.json +11 -3
  291. package/tsconfig.json +2 -2
  292. package/docs/interfaces/NavigatorParams.html +0 -197
  293. package/docs/types/Thunk.html +0 -133
@@ -42,7 +42,7 @@ var FamilyPosition;
42
42
  FamilyPosition[FamilyPosition["root"] = 0] = "root";
43
43
  FamilyPosition[FamilyPosition["left"] = 1] = "left";
44
44
  FamilyPosition[FamilyPosition["right"] = 2] = "right";
45
- })(FamilyPosition = exports.FamilyPosition || (exports.FamilyPosition = {}));
45
+ })(FamilyPosition || (exports.FamilyPosition = FamilyPosition = {}));
46
46
  /**
47
47
  * Enum representing different loop types.
48
48
  *
@@ -53,7 +53,7 @@ var LoopType;
53
53
  (function (LoopType) {
54
54
  LoopType[LoopType["iterative"] = 1] = "iterative";
55
55
  LoopType[LoopType["recursive"] = 2] = "recursive";
56
- })(LoopType = exports.LoopType || (exports.LoopType = {}));
56
+ })(LoopType || (exports.LoopType = LoopType = {}));
57
57
  var BinaryTreeNode = /** @class */ (function () {
58
58
  function BinaryTreeNode(id, val, count) {
59
59
  this._familyPosition = FamilyPosition.root;
@@ -151,72 +151,29 @@ var BinaryTreeNode = /** @class */ (function () {
151
151
  enumerable: false,
152
152
  configurable: true
153
153
  });
154
- /**
155
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
156
- */
157
- BinaryTreeNode.prototype.getId = function () {
158
- return this._id;
159
- };
160
- /**
161
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
162
- */
163
- BinaryTreeNode.prototype.getVal = function () {
164
- return this._val;
165
- };
166
- /**
167
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
168
- */
169
- BinaryTreeNode.prototype.getLeft = function () {
170
- return this._left;
171
- };
172
- /**
173
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
174
- */
175
- BinaryTreeNode.prototype.getRight = function () {
176
- return this._right;
177
- };
178
- /**
179
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
180
- */
181
- BinaryTreeNode.prototype.getParent = function () {
182
- return this._parent;
183
- };
184
- /**
185
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
186
- */
187
- BinaryTreeNode.prototype.getFamilyPosition = function () {
188
- return this._familyPosition;
189
- };
190
- /**
191
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
192
- */
193
- BinaryTreeNode.prototype.getCount = function () {
194
- return this._count;
195
- };
196
- /**
197
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
198
- */
199
- BinaryTreeNode.prototype.getHeight = function () {
200
- return this._height;
154
+ BinaryTreeNode.prototype._createNode = function (id, val, count) {
155
+ return val !== null ? new BinaryTreeNode(id, val, count) : null;
201
156
  };
202
157
  BinaryTreeNode.prototype.swapLocation = function (swapNode) {
203
158
  var val = swapNode.val, count = swapNode.count, height = swapNode.height;
204
- var tempNode = new BinaryTreeNode(swapNode.id, val);
205
- tempNode.val = val;
206
- tempNode.count = count;
207
- tempNode.height = height;
208
- swapNode.id = this.id;
209
- swapNode.val = this.val;
210
- swapNode.count = this.count;
211
- swapNode.height = this.height;
212
- this.id = tempNode.id;
213
- this.val = tempNode.val;
214
- this.count = tempNode.count;
215
- this.height = tempNode.height;
159
+ var tempNode = this._createNode(swapNode.id, val);
160
+ if (tempNode instanceof BinaryTreeNode) {
161
+ tempNode.val = val;
162
+ tempNode.count = count;
163
+ tempNode.height = height;
164
+ swapNode.id = this.id;
165
+ swapNode.val = this.val;
166
+ swapNode.count = this.count;
167
+ swapNode.height = this.height;
168
+ this.id = tempNode.id;
169
+ this.val = tempNode.val;
170
+ this.count = tempNode.count;
171
+ this.height = tempNode.height;
172
+ }
216
173
  return swapNode;
217
174
  };
218
175
  BinaryTreeNode.prototype.clone = function () {
219
- return new BinaryTreeNode(this.id, this.val, this.count);
176
+ return this._createNode(this.id, this.val, this.count);
220
177
  };
221
178
  return BinaryTreeNode;
222
179
  }());
@@ -247,17 +204,73 @@ var BinaryTree = /** @class */ (function () {
247
204
  this._loopType = loopType;
248
205
  }
249
206
  }
207
+ Object.defineProperty(BinaryTree.prototype, "loopType", {
208
+ get: function () {
209
+ return this._loopType;
210
+ },
211
+ enumerable: false,
212
+ configurable: true
213
+ });
214
+ Object.defineProperty(BinaryTree.prototype, "visitedId", {
215
+ get: function () {
216
+ return this._visitedId;
217
+ },
218
+ enumerable: false,
219
+ configurable: true
220
+ });
221
+ Object.defineProperty(BinaryTree.prototype, "visitedVal", {
222
+ get: function () {
223
+ return this._visitedVal;
224
+ },
225
+ enumerable: false,
226
+ configurable: true
227
+ });
228
+ Object.defineProperty(BinaryTree.prototype, "visitedNode", {
229
+ get: function () {
230
+ return this._visitedNode;
231
+ },
232
+ enumerable: false,
233
+ configurable: true
234
+ });
235
+ Object.defineProperty(BinaryTree.prototype, "visitedCount", {
236
+ get: function () {
237
+ return this._visitedCount;
238
+ },
239
+ enumerable: false,
240
+ configurable: true
241
+ });
242
+ Object.defineProperty(BinaryTree.prototype, "visitedLeftSum", {
243
+ get: function () {
244
+ return this._visitedLeftSum;
245
+ },
246
+ enumerable: false,
247
+ configurable: true
248
+ });
249
+ Object.defineProperty(BinaryTree.prototype, "autoIncrementId", {
250
+ get: function () {
251
+ return this._autoIncrementId;
252
+ },
253
+ enumerable: false,
254
+ configurable: true
255
+ });
256
+ Object.defineProperty(BinaryTree.prototype, "maxId", {
257
+ get: function () {
258
+ return this._maxId;
259
+ },
260
+ enumerable: false,
261
+ configurable: true
262
+ });
263
+ Object.defineProperty(BinaryTree.prototype, "isDuplicatedVal", {
264
+ get: function () {
265
+ return this._isDuplicatedVal;
266
+ },
267
+ enumerable: false,
268
+ configurable: true
269
+ });
250
270
  Object.defineProperty(BinaryTree.prototype, "root", {
251
271
  get: function () {
252
272
  return this._root;
253
273
  },
254
- set: function (v) {
255
- if (v) {
256
- v.parent = null;
257
- v.familyPosition = FamilyPosition.root;
258
- }
259
- this._root = v;
260
- },
261
274
  enumerable: false,
262
275
  configurable: true
263
276
  });
@@ -265,9 +278,6 @@ var BinaryTree = /** @class */ (function () {
265
278
  get: function () {
266
279
  return this._size;
267
280
  },
268
- set: function (v) {
269
- this._size = v;
270
- },
271
281
  enumerable: false,
272
282
  configurable: true
273
283
  });
@@ -275,54 +285,32 @@ var BinaryTree = /** @class */ (function () {
275
285
  get: function () {
276
286
  return this._count;
277
287
  },
278
- set: function (v) {
279
- this._count = v;
280
- },
281
288
  enumerable: false,
282
289
  configurable: true
283
290
  });
284
291
  /**
285
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Getters (using the same name as the property) while utilizing separate method names for Setters.
286
- * @returns The method is returning either a BinaryTreeNode object of type T or null.
287
- */
288
- BinaryTree.prototype.getRoot = function () {
289
- return this._root;
290
- };
291
- /**
292
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
293
- */
294
- BinaryTree.prototype.getSize = function () {
295
- return this._size;
296
- };
297
- /**
298
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
299
- */
300
- BinaryTree.prototype.getCount = function () {
301
- return this._count;
302
- };
303
- /**
304
- * The function creates a new binary tree node with the given id, value, and count, or returns null if the value is
305
- * null.
292
+ * The function creates a new binary tree node with the given id, value, and count if the value is not null, otherwise
293
+ * it returns null.
306
294
  * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is of type
307
- * `BinaryTreeNodeId`, which could be a string or a number, depending on how you want to identify your nodes.
308
- * @param {T | null} val - The `val` parameter represents the value to be stored in the binary tree node. It can be of
309
- * any type `T` or `null`.
310
- * @param {number} [count] - The count parameter is an optional parameter that represents the number of occurrences of
311
- * the value in the binary tree node. It is of type number.
312
- * @returns The function `createNode` returns a `BinaryTreeNode<T>` object if the `val` parameter is not null.
313
- * Otherwise, it returns null.
295
+ * `BinaryTreeNodeId`.
296
+ * @param {N | null} val - The `val` parameter represents the value of the node. It can be of type `N` (generic type)
297
+ * or `null`.
298
+ * @param {number} [count] - The `count` parameter is an optional parameter of type `number`. It represents the number
299
+ * of occurrences of the value in the binary tree node. If not provided, the default value is `undefined`.
300
+ * @returns a BinaryTreeNode object if the value is not null, otherwise it returns null.
314
301
  */
315
- BinaryTree.prototype.createNode = function (id, val, count) {
316
- return val !== null ? new BinaryTreeNode(id, val, count) : null;
302
+ BinaryTree.prototype._createNode = function (id, val, count) {
303
+ var node = new BinaryTreeNode(id, val, count);
304
+ return node;
317
305
  };
318
306
  /**
319
307
  * The clear function resets the state of an object by setting its properties to their initial values.
320
308
  */
321
309
  BinaryTree.prototype.clear = function () {
322
- this.root = null;
323
- this.size = 0;
324
- this.count = 0;
325
- this._maxId = -1;
310
+ this._setRoot(null);
311
+ this._setSize(0);
312
+ this._setCount(0);
313
+ this._setMaxId(-1);
326
314
  };
327
315
  /**
328
316
  * The function checks if the size of an object is equal to zero and returns a boolean value.
@@ -336,10 +324,10 @@ var BinaryTree = /** @class */ (function () {
336
324
  * already exists.
337
325
  * @param {BinaryTreeNodeId} id - The id parameter is the identifier of the binary tree node. It is used to uniquely
338
326
  * identify each node in the binary tree.
339
- * @param {T} val - The value to be inserted into the binary tree.
327
+ * @param {N} val - The value to be inserted into the binary tree.
340
328
  * @param {number} [count] - The `count` parameter is an optional parameter that specifies the number of times the
341
329
  * value should be inserted into the binary tree. If not provided, it defaults to 1.
342
- * @returns The function `add` returns a `BinaryTreeNode<T>` object if a new node is inserted, or `null` if no new node
330
+ * @returns The function `add` returns a `N` object if a new node is inserted, or `null` if no new node
343
331
  * is inserted, or `undefined` if the insertion fails.
344
332
  */
345
333
  BinaryTree.prototype.add = function (id, val, count) {
@@ -364,14 +352,14 @@ var BinaryTree = /** @class */ (function () {
364
352
  return;
365
353
  };
366
354
  var inserted;
367
- var needInsert = val !== null ? new BinaryTreeNode(id, val, count) : null;
355
+ var needInsert = val !== null ? this._createNode(id, val, count) : null;
368
356
  var existNode = val !== null ? this.get(id, 'id') : null;
369
357
  if (this.root) {
370
358
  if (existNode) {
371
359
  existNode.count += count;
372
360
  existNode.val = val;
373
361
  if (needInsert !== null) {
374
- this.count += count;
362
+ this._setCount(this.count + count);
375
363
  inserted = existNode;
376
364
  }
377
365
  }
@@ -380,10 +368,10 @@ var BinaryTree = /** @class */ (function () {
380
368
  }
381
369
  }
382
370
  else {
383
- this.root = val !== null ? new BinaryTreeNode(id, val, count) : null;
371
+ this._setRoot(val !== null ? this._createNode(id, val, count) : null);
384
372
  if (needInsert !== null) {
385
- this.size = 1;
386
- this.count = count;
373
+ this._setSize(1);
374
+ this._setCount(count);
387
375
  }
388
376
  inserted = this.root;
389
377
  }
@@ -391,7 +379,7 @@ var BinaryTree = /** @class */ (function () {
391
379
  };
392
380
  /**
393
381
  * The function inserts a new node into a binary tree as the left or right child of a given parent node.
394
- * @param {BinaryTreeNode<T> | null} newNode - The `newNode` parameter is an instance of the `BinaryTreeNode` class or
382
+ * @param {N | null} newNode - The `newNode` parameter is an instance of the `BinaryTreeNode` class or
395
383
  * `null`. It represents the node that needs to be inserted into the binary tree.
396
384
  * @param parent - The `parent` parameter is a BinaryTreeNode object representing the parent node to which the new node
397
385
  * will be inserted as a child.
@@ -407,8 +395,8 @@ var BinaryTree = /** @class */ (function () {
407
395
  }
408
396
  parent.left = newNode;
409
397
  if (newNode !== null) {
410
- this.size++;
411
- this.count += (_a = newNode === null || newNode === void 0 ? void 0 : newNode.count) !== null && _a !== void 0 ? _a : 0;
398
+ this._setSize(this.size + 1);
399
+ this._setCount((_a = this.count + newNode.count) !== null && _a !== void 0 ? _a : 0);
412
400
  }
413
401
  return parent.left;
414
402
  }
@@ -419,8 +407,8 @@ var BinaryTree = /** @class */ (function () {
419
407
  }
420
408
  parent.right = newNode;
421
409
  if (newNode !== null) {
422
- this.size++;
423
- this.count += (_b = newNode === null || newNode === void 0 ? void 0 : newNode.count) !== null && _b !== void 0 ? _b : 0;
410
+ this._setSize(this.size + 1);
411
+ this._setCount((_b = this.count + newNode.count) !== null && _b !== void 0 ? _b : 0);
424
412
  }
425
413
  return parent.right;
426
414
  }
@@ -435,9 +423,9 @@ var BinaryTree = /** @class */ (function () {
435
423
  /**
436
424
  * The `addMany` function inserts multiple items into a binary tree and returns an array of the inserted nodes or
437
425
  * null/undefined values.
438
- * @param {T[] | BinaryTreeNode<T>[]} data - The `data` parameter can be either an array of elements of type `T` or an
439
- * array of `BinaryTreeNode<T>` objects.
440
- * @returns The function `addMany` returns an array of `BinaryTreeNode<T>`, `null`, or `undefined` values.
426
+ * @param {N[] | N[]} data - The `data` parameter can be either an array of elements of type `N` or an
427
+ * array of `N` objects.
428
+ * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
441
429
  */
442
430
  BinaryTree.prototype.addMany = function (data) {
443
431
  var e_1, _a, e_2, _b;
@@ -507,8 +495,8 @@ var BinaryTree = /** @class */ (function () {
507
495
  /**
508
496
  * The `fill` function clears the current data and inserts new data, returning a boolean indicating if the insertion
509
497
  * was successful.
510
- * @param {T[] | BinaryTreeNode<T>[]} data - The `data` parameter can be either an array of elements of type `T` or an
511
- * array of `BinaryTreeNode<T>` objects.
498
+ * @param {N[] | N[]} data - The `data` parameter can be either an array of elements of type `N` or an
499
+ * array of `N` objects.
512
500
  * @returns The method is returning a boolean value.
513
501
  */
514
502
  BinaryTree.prototype.fill = function (data) {
@@ -533,27 +521,27 @@ var BinaryTree = /** @class */ (function () {
533
521
  node = undefined;
534
522
  else if (node.count > 1 && !ignoreCount) {
535
523
  node.count--;
536
- this.count--;
524
+ this._setCount(this.count - 1);
537
525
  }
538
526
  else if (node instanceof BinaryTreeNode) {
539
527
  var _a = __read(this.getSubTreeSizeAndCount(node), 2), subSize = _a[0], subCount = _a[1];
540
528
  switch (node.familyPosition) {
541
529
  case 0:
542
- this.size -= subSize;
543
- this.count -= subCount;
530
+ this._setSize(this.size - subSize);
531
+ this._setCount(this.count - subCount);
544
532
  node = undefined;
545
533
  break;
546
534
  case 1:
547
535
  if (node.parent) {
548
- this.size -= subSize;
549
- this.count -= subCount;
536
+ this._setSize(this.size - subSize);
537
+ this._setCount(this.count - subCount);
550
538
  node.parent.left = null;
551
539
  }
552
540
  break;
553
541
  case 2:
554
542
  if (node.parent) {
555
- this.size -= subSize;
556
- this.count -= subCount;
543
+ this._setSize(this.size - subSize);
544
+ this._setCount(this.count - subCount);
557
545
  node.parent.right = null;
558
546
  }
559
547
  break;
@@ -563,7 +551,7 @@ var BinaryTree = /** @class */ (function () {
563
551
  };
564
552
  /**
565
553
  * The function calculates the depth of a binary tree node by traversing its parent nodes.
566
- * @param node - BinaryTreeNode<T> - This is the node for which we want to calculate the depth. It is a generic type,
554
+ * @param node - N - This is the node for which we want to calculate the depth. It is a generic type,
567
555
  * meaning it can represent any type of data that we want to store in the node.
568
556
  * @returns The depth of the given binary tree node.
569
557
  */
@@ -578,8 +566,8 @@ var BinaryTree = /** @class */ (function () {
578
566
  /**
579
567
  * The `getHeight` function calculates the maximum height of a binary tree using either a recursive or iterative
580
568
  * approach.
581
- * @param {BinaryTreeNode<T> | null} [beginRoot] - The `beginRoot` parameter is an optional parameter of type
582
- * `BinaryTreeNode<T> | null`. It represents the starting node from which to calculate the height of the binary tree.
569
+ * @param {N | null} [beginRoot] - The `beginRoot` parameter is an optional parameter of type
570
+ * `N | null`. It represents the starting node from which to calculate the height of the binary tree.
583
571
  * If no value is provided for `beginRoot`, the function will use the `root` property of the class instance as
584
572
  * @returns the height of the binary tree.
585
573
  */
@@ -629,8 +617,8 @@ var BinaryTree = /** @class */ (function () {
629
617
  /**
630
618
  * The `getMinHeight` function calculates the minimum height of a binary tree using either a recursive or iterative
631
619
  * approach.
632
- * @param {BinaryTreeNode<T> | null} [beginRoot] - The `beginRoot` parameter is an optional parameter of type
633
- * `BinaryTreeNode<T> | null`. It represents the starting node from which to calculate the minimum height of the binary
620
+ * @param {N | null} [beginRoot] - The `beginRoot` parameter is an optional parameter of type
621
+ * `N | null`. It represents the starting node from which to calculate the minimum height of the binary
634
622
  * tree. If no value is provided for `beginRoot`, the function will use the root node of the binary tree.
635
623
  * @returns The function `getMinHeight` returns the minimum height of the binary tree.
636
624
  */
@@ -681,8 +669,8 @@ var BinaryTree = /** @class */ (function () {
681
669
  };
682
670
  /**
683
671
  * The function checks if a binary tree is balanced by comparing the minimum height and the maximum height of the tree.
684
- * @param {BinaryTreeNode<T> | null} [beginRoot] - The `beginRoot` parameter is the root node of a binary tree. It is
685
- * of type `BinaryTreeNode<T> | null`, which means it can either be a `BinaryTreeNode` object or `null`.
672
+ * @param {N | null} [beginRoot] - The `beginRoot` parameter is the root node of a binary tree. It is
673
+ * of type `N | null`, which means it can either be a `BinaryTreeNode` object or `null`.
686
674
  * @returns The method is returning a boolean value.
687
675
  */
688
676
  BinaryTree.prototype.isBalanced = function (beginRoot) {
@@ -691,14 +679,14 @@ var BinaryTree = /** @class */ (function () {
691
679
  /**
692
680
  * The function `getNodes` returns an array of binary tree nodes that match a given property value, with options for
693
681
  * searching recursively or iteratively.
694
- * @param {BinaryTreeNodeId | T} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a
695
- * generic type `T`. It represents the property of the binary tree node that you want to search for.
682
+ * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a
683
+ * generic type `N`. It represents the property of the binary tree node that you want to search for.
696
684
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
697
685
  * specifies the property name to use when searching for nodes. If not provided, it defaults to 'id'.
698
686
  * @param {boolean} [onlyOne] - The `onlyOne` parameter is an optional boolean parameter that determines whether to
699
687
  * return only one node that matches the `nodeProperty` or `propertyName` criteria. If `onlyOne` is set to `true`, the
700
688
  * function will stop traversing the tree and return the first matching node. If `
701
- * @returns The function `getNodes` returns an array of `BinaryTreeNode<T> | null | undefined` objects.
689
+ * @returns The function `getNodes` returns an array of `N | null | undefined` objects.
702
690
  */
703
691
  BinaryTree.prototype.getNodes = function (nodeProperty, propertyName, onlyOne) {
704
692
  var _this = this;
@@ -734,8 +722,8 @@ var BinaryTree = /** @class */ (function () {
734
722
  /**
735
723
  * The function checks if a binary tree node has a specific property or if any node in the tree has a specific
736
724
  * property.
737
- * @param {BinaryTreeNodeId | T} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a
738
- * generic type `T`. It represents the property of a binary tree node that you want to check.
725
+ * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a
726
+ * generic type `N`. It represents the property of a binary tree node that you want to check.
739
727
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
740
728
  * specifies the name of the property to check for in the nodes.
741
729
  * @returns a boolean value.
@@ -746,8 +734,8 @@ var BinaryTree = /** @class */ (function () {
746
734
  /**
747
735
  * The function returns the first binary tree node that matches the given property name and value, or null if no match
748
736
  * is found.
749
- * @param {BinaryTreeNodeId | T} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a
750
- * generic type `T`. It represents the property of the binary tree node that you want to search for.
737
+ * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a
738
+ * generic type `N`. It represents the property of the binary tree node that you want to search for.
751
739
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
752
740
  * specifies the property of the binary tree node to search for. If not provided, it defaults to `'id'`.
753
741
  * @returns a BinaryTreeNode object or null.
@@ -761,7 +749,7 @@ var BinaryTree = /** @class */ (function () {
761
749
  * The function getPathToRoot returns an array of BinaryTreeNode objects representing the path from a given node to the
762
750
  * root of a binary tree.
763
751
  * @param node - The `node` parameter is a BinaryTreeNode object.
764
- * @returns The function `getPathToRoot` returns an array of `BinaryTreeNode<T>` objects, representing the path from
752
+ * @returns The function `getPathToRoot` returns an array of `N` objects, representing the path from
765
753
  * the given `node` to the root of the binary tree.
766
754
  */
767
755
  BinaryTree.prototype.getPathToRoot = function (node) {
@@ -776,7 +764,7 @@ var BinaryTree = /** @class */ (function () {
776
764
  /**
777
765
  * The `getLeftMost` function returns the leftmost node in a binary tree, either recursively or iteratively using tail
778
766
  * recursion optimization.
779
- * @param {BinaryTreeNode<T> | null} [node] - The `node` parameter is an optional parameter of type `BinaryTreeNode<T>
767
+ * @param {N | null} [node] - The `node` parameter is an optional parameter of type `N
780
768
  * | null`. It represents the starting node from which to find the leftmost node in a binary tree. If no node is
781
769
  * provided, the function will use the root node of the binary tree.
782
770
  * @returns The `getLeftMost` function returns the leftmost node in a binary tree.
@@ -806,7 +794,7 @@ var BinaryTree = /** @class */ (function () {
806
794
  /**
807
795
  * The `getRightMost` function returns the rightmost node in a binary tree, either recursively or iteratively using
808
796
  * tail recursion optimization.
809
- * @param {BinaryTreeNode<T> | null} [node] - The `node` parameter is an optional parameter of type `BinaryTreeNode<T>
797
+ * @param {N | null} [node] - The `node` parameter is an optional parameter of type `N
810
798
  * | null`. It represents the starting node from which to find the rightmost node in a binary tree. If no node is
811
799
  * provided, the function will use the root node of the binary tree.
812
800
  * @returns The `getRightMost` function returns the rightmost node in a binary tree.
@@ -833,10 +821,9 @@ var BinaryTree = /** @class */ (function () {
833
821
  return _traverse_5(node);
834
822
  }
835
823
  };
836
- // --- start additional methods ---
837
824
  /**
838
825
  * The `isBST` function checks if a binary tree is a binary search tree.
839
- * @param {BinaryTreeNode<T> | null} [node] - The `node` parameter is an optional parameter of type `BinaryTreeNode<T>
826
+ * @param {N | null} [node] - The `node` parameter is an optional parameter of type `N
840
827
  * | null`. It represents the root node of the binary search tree (BST) that we want to check for validity. If no node
841
828
  * is provided, the function will default to using the root node of the BST instance that
842
829
  * @returns The `isBST` function returns a boolean value. It returns `true` if the binary tree is a valid binary search
@@ -876,7 +863,7 @@ var BinaryTree = /** @class */ (function () {
876
863
  /**
877
864
  * The function calculates the size and count of a subtree in a binary tree using either recursive or iterative
878
865
  * traversal.
879
- * @param {BinaryTreeNode<T> | null | undefined} subTreeRoot - The `subTreeRoot` parameter is the root node of a binary
866
+ * @param {N | null | undefined} subTreeRoot - The `subTreeRoot` parameter is the root node of a binary
880
867
  * tree.
881
868
  * @returns The function `getSubTreeSizeAndCount` returns an array `[number, number]`. The first element of the array
882
869
  * represents the size of the subtree, and the second element represents the count of the nodes in the subtree.
@@ -907,6 +894,7 @@ var BinaryTree = /** @class */ (function () {
907
894
  return res;
908
895
  }
909
896
  };
897
+ // --- start additional methods ---
910
898
  /**
911
899
  * The function `subTreeSum` calculates the sum of a specified property in a binary tree, either recursively or
912
900
  * iteratively.
@@ -980,7 +968,7 @@ var BinaryTree = /** @class */ (function () {
980
968
  break;
981
969
  case 'count':
982
970
  cur.count += delta;
983
- _this.count += delta;
971
+ _this._setCount(_this.count + delta);
984
972
  break;
985
973
  default:
986
974
  cur.id += delta;
@@ -1013,7 +1001,7 @@ var BinaryTree = /** @class */ (function () {
1013
1001
  * represents either a node or a property name. If a node is provided, the breadth-first search algorithm will be
1014
1002
  * performed starting from that node. If a property name is provided, the breadth-first search algorithm will be
1015
1003
  * performed starting from the root node
1016
- * @returns an object of type `ResultsByProperty<T>`.
1004
+ * @returns an object of type `ResultsByProperty<N>`.
1017
1005
  */
1018
1006
  BinaryTree.prototype.BFS = function (nodeOrPropertyName) {
1019
1007
  nodeOrPropertyName = nodeOrPropertyName !== null && nodeOrPropertyName !== void 0 ? nodeOrPropertyName : 'id';
@@ -1041,7 +1029,7 @@ var BinaryTree = /** @class */ (function () {
1041
1029
  * either the name of a property in the `BinaryTreeNode` object or the value of the `id` property in the
1042
1030
  * `BinaryTreeNode` object. This parameter is used to accumulate the results based on the specified property name. If
1043
1031
  * no value
1044
- * @returns an object of type `ResultsByProperty<T>`.
1032
+ * @returns an object of type `ResultsByProperty<N>`.
1045
1033
  */
1046
1034
  BinaryTree.prototype.DFS = function (pattern, nodeOrPropertyName) {
1047
1035
  var _this = this;
@@ -1128,14 +1116,14 @@ var BinaryTree = /** @class */ (function () {
1128
1116
  /**
1129
1117
  * The `levelIterative` function performs a level-order traversal on a binary tree and returns the values of the nodes
1130
1118
  * in an array, based on a specified property name.
1131
- * @param {BinaryTreeNode<T> | null} node - The `node` parameter is a BinaryTreeNode object representing the starting
1119
+ * @param {N | null} node - The `node` parameter is a BinaryTreeNode object representing the starting
1132
1120
  * node for the level order traversal. It can be null if no specific node is provided, in which case the root node of
1133
1121
  * the tree is used as the starting node.
1134
1122
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - The `nodeOrPropertyName` parameter is an optional parameter that
1135
1123
  * can be either a `BinaryTreeNode` property name or the string `'id'`. If a property name is provided, the function
1136
1124
  * will accumulate results based on that property. If no property name is provided, the function will default to
1137
1125
  * accumulating results
1138
- * @returns The function `levelIterative` returns an object of type `ResultsByProperty<T>`.
1126
+ * @returns The function `levelIterative` returns an object of type `ResultsByProperty<N>`.
1139
1127
  */
1140
1128
  BinaryTree.prototype.levelIterative = function (node, nodeOrPropertyName) {
1141
1129
  nodeOrPropertyName = nodeOrPropertyName || 'id';
@@ -1160,12 +1148,12 @@ var BinaryTree = /** @class */ (function () {
1160
1148
  };
1161
1149
  /**
1162
1150
  * The `listLevels` function collects nodes from a binary tree by a specified property and organizes them into levels.
1163
- * @param {BinaryTreeNode<T> | null} node - The `node` parameter is a BinaryTreeNode object or null. It represents the
1151
+ * @param {N | null} node - The `node` parameter is a BinaryTreeNode object or null. It represents the
1164
1152
  * root node of a binary tree. If it is null, the function will use the root node of the current binary tree instance.
1165
1153
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - The `nodeOrPropertyName` parameter is an optional parameter that
1166
1154
  * specifies the property of the `BinaryTreeNode` object to collect at each level. It can be one of the following
1167
1155
  * values:
1168
- * @returns The function `listLevels` returns a 2D array of `ResultByProperty<T>` objects.
1156
+ * @returns The function `listLevels` returns a 2D array of `ResultByProperty<N>` objects.
1169
1157
  */
1170
1158
  BinaryTree.prototype.listLevels = function (node, nodeOrPropertyName) {
1171
1159
  nodeOrPropertyName = nodeOrPropertyName || 'id';
@@ -1249,7 +1237,7 @@ var BinaryTree = /** @class */ (function () {
1249
1237
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - The `nodeOrPropertyName` parameter is used to specify the
1250
1238
  * property of the nodes that you want to retrieve in the results. It can be either the node itself or the name of the
1251
1239
  * property. If not provided, it defaults to `'id'`.
1252
- * @returns The function `morris` returns an object of type `ResultsByProperty<T>`.
1240
+ * @returns The function `morris` returns an object of type `ResultsByProperty<N>`.
1253
1241
  */
1254
1242
  BinaryTree.prototype.morris = function (pattern, nodeOrPropertyName) {
1255
1243
  var _this = this;
@@ -1338,6 +1326,46 @@ var BinaryTree = /** @class */ (function () {
1338
1326
  }
1339
1327
  return this._getResultByPropertyName(nodeOrPropertyName);
1340
1328
  };
1329
+ BinaryTree.prototype._setLoopType = function (value) {
1330
+ this._loopType = value;
1331
+ };
1332
+ BinaryTree.prototype._setVisitedId = function (value) {
1333
+ this._visitedId = value;
1334
+ };
1335
+ BinaryTree.prototype._setVisitedVal = function (value) {
1336
+ this._visitedVal = value;
1337
+ };
1338
+ BinaryTree.prototype._setVisitedNode = function (value) {
1339
+ this._visitedNode = value;
1340
+ };
1341
+ BinaryTree.prototype.setVisitedCount = function (value) {
1342
+ this._visitedCount = value;
1343
+ };
1344
+ BinaryTree.prototype._setVisitedLeftSum = function (value) {
1345
+ this._visitedLeftSum = value;
1346
+ };
1347
+ BinaryTree.prototype._setAutoIncrementId = function (value) {
1348
+ this._autoIncrementId = value;
1349
+ };
1350
+ BinaryTree.prototype._setMaxId = function (value) {
1351
+ this._maxId = value;
1352
+ };
1353
+ BinaryTree.prototype._setIsDuplicatedVal = function (value) {
1354
+ this._isDuplicatedVal = value;
1355
+ };
1356
+ BinaryTree.prototype._setRoot = function (v) {
1357
+ if (v) {
1358
+ v.parent = null;
1359
+ v.familyPosition = FamilyPosition.root;
1360
+ }
1361
+ this._root = v;
1362
+ };
1363
+ BinaryTree.prototype._setSize = function (v) {
1364
+ this._size = v;
1365
+ };
1366
+ BinaryTree.prototype._setCount = function (v) {
1367
+ this._count = v;
1368
+ };
1341
1369
  /**
1342
1370
  * The function resets the values of several arrays used for tracking visited nodes and their properties.
1343
1371
  */
@@ -1352,9 +1380,9 @@ var BinaryTree = /** @class */ (function () {
1352
1380
  * The function checks if a given property of a binary tree node matches a specified value, and if so, adds the node to
1353
1381
  * a result array.
1354
1382
  * @param cur - The current binary tree node that is being checked.
1355
- * @param {(BinaryTreeNode<T> | null | undefined)[]} result - An array that stores the matching nodes found during the
1383
+ * @param {(N | null | undefined)[]} result - An array that stores the matching nodes found during the
1356
1384
  * traversal.
1357
- * @param {BinaryTreeNodeId | T} nodeProperty - The `nodeProperty` parameter is the value that we are searching for in
1385
+ * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter is the value that we are searching for in
1358
1386
  * the binary tree nodes. It can be either the `id`, `count`, or `val` property of the node.
1359
1387
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
1360
1388
  * specifies the property of the `BinaryTreeNode` object that you want to compare with the `nodeProperty` value. It can
@@ -1395,7 +1423,7 @@ var BinaryTree = /** @class */ (function () {
1395
1423
  /**
1396
1424
  * The function `_accumulatedByPropertyName` pushes a property value of a binary tree node into an array based on the
1397
1425
  * provided property name or a default property name.
1398
- * @param node - The `node` parameter is of type `BinaryTreeNode<T>`, which represents a node in a binary tree.
1426
+ * @param node - The `node` parameter is of type `N`, which represents a node in a binary tree.
1399
1427
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - The parameter `nodeOrPropertyName` is an optional parameter that
1400
1428
  * can be either a string representing a property name or a reference to a node object. If it is a string, it specifies
1401
1429
  * the property name of the node that should be accumulated. If it is a node object, it specifies the node itself