data-structure-typed 1.18.7 → 1.19.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 (269) hide show
  1. package/README.md +208 -419
  2. package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +198 -167
  3. package/dist/data-structures/binary-tree/abstract-binary-tree.js +413 -398
  4. package/dist/data-structures/binary-tree/avl-tree.d.ts +24 -16
  5. package/dist/data-structures/binary-tree/avl-tree.js +23 -17
  6. package/dist/data-structures/binary-tree/binary-tree.d.ts +12 -26
  7. package/dist/data-structures/binary-tree/binary-tree.js +12 -27
  8. package/dist/data-structures/binary-tree/bst.d.ts +66 -90
  9. package/dist/data-structures/binary-tree/bst.js +85 -163
  10. package/dist/data-structures/binary-tree/rb-tree.d.ts +6 -17
  11. package/dist/data-structures/binary-tree/rb-tree.js +5 -17
  12. package/dist/data-structures/binary-tree/tree-multiset.d.ts +187 -18
  13. package/dist/data-structures/binary-tree/tree-multiset.js +716 -39
  14. package/dist/data-structures/graph/abstract-graph.d.ts +112 -52
  15. package/dist/data-structures/graph/abstract-graph.js +138 -72
  16. package/dist/data-structures/graph/directed-graph.d.ts +104 -101
  17. package/dist/data-structures/graph/directed-graph.js +134 -129
  18. package/dist/data-structures/graph/undirected-graph.d.ts +66 -65
  19. package/dist/data-structures/graph/undirected-graph.js +107 -106
  20. package/dist/data-structures/interfaces/abstract-binary-tree.d.ts +12 -18
  21. package/dist/data-structures/interfaces/abstract-graph.d.ts +2 -4
  22. package/dist/data-structures/interfaces/avl-tree.d.ts +2 -2
  23. package/dist/data-structures/interfaces/binary-tree.d.ts +1 -1
  24. package/dist/data-structures/interfaces/bst.d.ts +4 -5
  25. package/dist/data-structures/interfaces/rb-tree.d.ts +2 -3
  26. package/dist/data-structures/interfaces/tree-multiset.d.ts +7 -1
  27. package/dist/data-structures/tree/tree.d.ts +1 -4
  28. package/dist/data-structures/tree/tree.js +1 -12
  29. package/dist/data-structures/types/abstract-binary-tree.d.ts +10 -6
  30. package/dist/data-structures/types/abstract-binary-tree.js +9 -5
  31. package/dist/data-structures/types/avl-tree.d.ts +1 -1
  32. package/dist/data-structures/types/binary-tree.d.ts +1 -1
  33. package/dist/data-structures/types/bst.d.ts +1 -1
  34. package/dist/data-structures/types/bst.js +1 -1
  35. package/dist/data-structures/types/directed-graph.js +1 -1
  36. package/dist/data-structures/types/helpers.d.ts +1 -8
  37. package/dist/data-structures/types/rb-tree.d.ts +2 -0
  38. package/dist/data-structures/types/rb-tree.js +1 -1
  39. package/dist/data-structures/types/tree-multiset.d.ts +5 -5
  40. package/dist/utils/index.d.ts +1 -0
  41. package/dist/utils/index.js +1 -0
  42. package/dist/utils/types/index.d.ts +1 -0
  43. package/dist/utils/types/index.js +1 -0
  44. package/dist/utils/types/validate-type.d.ts +19 -0
  45. package/dist/utils/types/validate-type.js +2 -0
  46. package/dist/utils/utils.d.ts +2 -2
  47. package/dist/utils/utils.js +0 -62
  48. package/dist/utils/validate-type.d.ts +45 -0
  49. package/dist/utils/validate-type.js +58 -0
  50. package/package.json +5 -2
  51. package/backup/recursive-type/src/assets/complexities-diff.jpg +0 -0
  52. package/backup/recursive-type/src/assets/data-structure-complexities.jpg +0 -0
  53. package/backup/recursive-type/src/assets/logo.png +0 -0
  54. package/backup/recursive-type/src/assets/overview-diagram-of-data-structures.png +0 -0
  55. package/backup/recursive-type/src/data-structures/binary-tree/aa-tree.ts +0 -3
  56. package/backup/recursive-type/src/data-structures/binary-tree/avl-tree.ts +0 -288
  57. package/backup/recursive-type/src/data-structures/binary-tree/b-tree.ts +0 -3
  58. package/backup/recursive-type/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -78
  59. package/backup/recursive-type/src/data-structures/binary-tree/binary-tree.ts +0 -1502
  60. package/backup/recursive-type/src/data-structures/binary-tree/bst.ts +0 -503
  61. package/backup/recursive-type/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
  62. package/backup/recursive-type/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
  63. package/backup/recursive-type/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
  64. package/backup/recursive-type/src/data-structures/binary-tree/index.ts +0 -11
  65. package/backup/recursive-type/src/data-structures/binary-tree/rb-tree.ts +0 -110
  66. package/backup/recursive-type/src/data-structures/binary-tree/segment-tree.ts +0 -243
  67. package/backup/recursive-type/src/data-structures/binary-tree/splay-tree.ts +0 -3
  68. package/backup/recursive-type/src/data-structures/binary-tree/tree-multiset.ts +0 -55
  69. package/backup/recursive-type/src/data-structures/binary-tree/two-three-tree.ts +0 -3
  70. package/backup/recursive-type/src/data-structures/diagrams/README.md +0 -5
  71. package/backup/recursive-type/src/data-structures/graph/abstract-graph.ts +0 -985
  72. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg +0 -0
  73. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-list.jpg +0 -0
  74. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg +0 -0
  75. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-matrix.jpg +0 -0
  76. package/backup/recursive-type/src/data-structures/graph/diagrams/dfs-can-do.jpg +0 -0
  77. package/backup/recursive-type/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg +0 -0
  78. package/backup/recursive-type/src/data-structures/graph/diagrams/edge-list.jpg +0 -0
  79. package/backup/recursive-type/src/data-structures/graph/diagrams/max-flow.jpg +0 -0
  80. package/backup/recursive-type/src/data-structures/graph/diagrams/mst.jpg +0 -0
  81. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
  82. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
  83. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
  84. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
  85. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan.webp +0 -0
  86. package/backup/recursive-type/src/data-structures/graph/directed-graph.ts +0 -478
  87. package/backup/recursive-type/src/data-structures/graph/index.ts +0 -3
  88. package/backup/recursive-type/src/data-structures/graph/undirected-graph.ts +0 -293
  89. package/backup/recursive-type/src/data-structures/hash/coordinate-map.ts +0 -67
  90. package/backup/recursive-type/src/data-structures/hash/coordinate-set.ts +0 -56
  91. package/backup/recursive-type/src/data-structures/hash/hash-table.ts +0 -3
  92. package/backup/recursive-type/src/data-structures/hash/index.ts +0 -6
  93. package/backup/recursive-type/src/data-structures/hash/pair.ts +0 -3
  94. package/backup/recursive-type/src/data-structures/hash/tree-map.ts +0 -3
  95. package/backup/recursive-type/src/data-structures/hash/tree-set.ts +0 -3
  96. package/backup/recursive-type/src/data-structures/heap/heap.ts +0 -176
  97. package/backup/recursive-type/src/data-structures/heap/index.ts +0 -3
  98. package/backup/recursive-type/src/data-structures/heap/max-heap.ts +0 -31
  99. package/backup/recursive-type/src/data-structures/heap/min-heap.ts +0 -34
  100. package/backup/recursive-type/src/data-structures/index.ts +0 -15
  101. package/backup/recursive-type/src/data-structures/interfaces/abstract-graph.ts +0 -42
  102. package/backup/recursive-type/src/data-structures/interfaces/avl-tree.ts +0 -1
  103. package/backup/recursive-type/src/data-structures/interfaces/binary-tree.ts +0 -56
  104. package/backup/recursive-type/src/data-structures/interfaces/bst.ts +0 -1
  105. package/backup/recursive-type/src/data-structures/interfaces/directed-graph.ts +0 -15
  106. package/backup/recursive-type/src/data-structures/interfaces/doubly-linked-list.ts +0 -1
  107. package/backup/recursive-type/src/data-structures/interfaces/heap.ts +0 -1
  108. package/backup/recursive-type/src/data-structures/interfaces/index.ts +0 -13
  109. package/backup/recursive-type/src/data-structures/interfaces/navigator.ts +0 -1
  110. package/backup/recursive-type/src/data-structures/interfaces/priority-queue.ts +0 -1
  111. package/backup/recursive-type/src/data-structures/interfaces/segment-tree.ts +0 -1
  112. package/backup/recursive-type/src/data-structures/interfaces/singly-linked-list.ts +0 -1
  113. package/backup/recursive-type/src/data-structures/interfaces/tree-multiset.ts +0 -1
  114. package/backup/recursive-type/src/data-structures/interfaces/undirected-graph.ts +0 -3
  115. package/backup/recursive-type/src/data-structures/linked-list/doubly-linked-list.ts +0 -573
  116. package/backup/recursive-type/src/data-structures/linked-list/index.ts +0 -3
  117. package/backup/recursive-type/src/data-structures/linked-list/singly-linked-list.ts +0 -490
  118. package/backup/recursive-type/src/data-structures/linked-list/skip-linked-list.ts +0 -3
  119. package/backup/recursive-type/src/data-structures/matrix/index.ts +0 -4
  120. package/backup/recursive-type/src/data-structures/matrix/matrix.ts +0 -27
  121. package/backup/recursive-type/src/data-structures/matrix/matrix2d.ts +0 -208
  122. package/backup/recursive-type/src/data-structures/matrix/navigator.ts +0 -122
  123. package/backup/recursive-type/src/data-structures/matrix/vector2d.ts +0 -316
  124. package/backup/recursive-type/src/data-structures/priority-queue/index.ts +0 -3
  125. package/backup/recursive-type/src/data-structures/priority-queue/max-priority-queue.ts +0 -49
  126. package/backup/recursive-type/src/data-structures/priority-queue/min-priority-queue.ts +0 -50
  127. package/backup/recursive-type/src/data-structures/priority-queue/priority-queue.ts +0 -354
  128. package/backup/recursive-type/src/data-structures/queue/deque.ts +0 -251
  129. package/backup/recursive-type/src/data-structures/queue/index.ts +0 -2
  130. package/backup/recursive-type/src/data-structures/queue/queue.ts +0 -120
  131. package/backup/recursive-type/src/data-structures/stack/index.ts +0 -1
  132. package/backup/recursive-type/src/data-structures/stack/stack.ts +0 -98
  133. package/backup/recursive-type/src/data-structures/tree/index.ts +0 -1
  134. package/backup/recursive-type/src/data-structures/tree/tree.ts +0 -80
  135. package/backup/recursive-type/src/data-structures/trie/index.ts +0 -1
  136. package/backup/recursive-type/src/data-structures/trie/trie.ts +0 -227
  137. package/backup/recursive-type/src/data-structures/types/abstract-graph.ts +0 -5
  138. package/backup/recursive-type/src/data-structures/types/avl-tree.ts +0 -8
  139. package/backup/recursive-type/src/data-structures/types/binary-tree.ts +0 -10
  140. package/backup/recursive-type/src/data-structures/types/bst.ts +0 -6
  141. package/backup/recursive-type/src/data-structures/types/directed-graph.ts +0 -8
  142. package/backup/recursive-type/src/data-structures/types/doubly-linked-list.ts +0 -1
  143. package/backup/recursive-type/src/data-structures/types/heap.ts +0 -5
  144. package/backup/recursive-type/src/data-structures/types/index.ts +0 -12
  145. package/backup/recursive-type/src/data-structures/types/navigator.ts +0 -13
  146. package/backup/recursive-type/src/data-structures/types/priority-queue.ts +0 -9
  147. package/backup/recursive-type/src/data-structures/types/segment-tree.ts +0 -1
  148. package/backup/recursive-type/src/data-structures/types/singly-linked-list.ts +0 -1
  149. package/backup/recursive-type/src/data-structures/types/tree-multiset.ts +0 -1
  150. package/backup/recursive-type/src/index.ts +0 -1
  151. package/backup/recursive-type/src/utils/index.ts +0 -2
  152. package/backup/recursive-type/src/utils/types/index.ts +0 -1
  153. package/backup/recursive-type/src/utils/types/utils.ts +0 -6
  154. package/backup/recursive-type/src/utils/utils.ts +0 -78
  155. package/docs/.nojekyll +0 -1
  156. package/docs/assets/highlight.css +0 -92
  157. package/docs/assets/main.js +0 -58
  158. package/docs/assets/search.js +0 -1
  159. package/docs/assets/style.css +0 -1367
  160. package/docs/classes/AVLTree.html +0 -2451
  161. package/docs/classes/AVLTreeNode.html +0 -499
  162. package/docs/classes/AaTree.html +0 -172
  163. package/docs/classes/AbstractBinaryTree.html +0 -2118
  164. package/docs/classes/AbstractBinaryTreeNode.html +0 -524
  165. package/docs/classes/AbstractEdge.html +0 -295
  166. package/docs/classes/AbstractGraph.html +0 -1043
  167. package/docs/classes/AbstractVertex.html +0 -258
  168. package/docs/classes/ArrayDeque.html +0 -439
  169. package/docs/classes/BST.html +0 -2297
  170. package/docs/classes/BSTNode.html +0 -503
  171. package/docs/classes/BTree.html +0 -172
  172. package/docs/classes/BinaryIndexedTree.html +0 -341
  173. package/docs/classes/BinaryTree.html +0 -2133
  174. package/docs/classes/BinaryTreeNode.html +0 -501
  175. package/docs/classes/Character.html +0 -220
  176. package/docs/classes/CoordinateMap.html +0 -483
  177. package/docs/classes/CoordinateSet.html +0 -444
  178. package/docs/classes/Deque.html +0 -975
  179. package/docs/classes/DirectedEdge.html +0 -366
  180. package/docs/classes/DirectedGraph.html +0 -1443
  181. package/docs/classes/DirectedVertex.html +0 -254
  182. package/docs/classes/DoublyLinkedList.html +0 -968
  183. package/docs/classes/DoublyLinkedListNode.html +0 -297
  184. package/docs/classes/HashTable.html +0 -172
  185. package/docs/classes/Heap.html +0 -423
  186. package/docs/classes/HeapItem.html +0 -255
  187. package/docs/classes/Matrix2D.html +0 -502
  188. package/docs/classes/MatrixNTI2D.html +0 -240
  189. package/docs/classes/MaxHeap.html +0 -436
  190. package/docs/classes/MaxPriorityQueue.html +0 -836
  191. package/docs/classes/MinHeap.html +0 -437
  192. package/docs/classes/MinPriorityQueue.html +0 -838
  193. package/docs/classes/Navigator.html +0 -313
  194. package/docs/classes/ObjectDeque.html +0 -455
  195. package/docs/classes/Pair.html +0 -172
  196. package/docs/classes/PriorityQueue.html +0 -760
  197. package/docs/classes/Queue.html +0 -392
  198. package/docs/classes/RBTree.html +0 -2388
  199. package/docs/classes/RBTreeNode.html +0 -516
  200. package/docs/classes/SegmentTree.html +0 -434
  201. package/docs/classes/SegmentTreeNode.html +0 -357
  202. package/docs/classes/SinglyLinkedList.html +0 -788
  203. package/docs/classes/SinglyLinkedListNode.html +0 -270
  204. package/docs/classes/SkipLinkedList.html +0 -172
  205. package/docs/classes/SplayTree.html +0 -172
  206. package/docs/classes/Stack.html +0 -368
  207. package/docs/classes/TreeMap.html +0 -172
  208. package/docs/classes/TreeMultiSet.html +0 -2297
  209. package/docs/classes/TreeMultiSetNode.html +0 -499
  210. package/docs/classes/TreeNode.html +0 -343
  211. package/docs/classes/TreeSet.html +0 -172
  212. package/docs/classes/Trie.html +0 -372
  213. package/docs/classes/TrieNode.html +0 -280
  214. package/docs/classes/TwoThreeTree.html +0 -172
  215. package/docs/classes/UndirectedEdge.html +0 -337
  216. package/docs/classes/UndirectedGraph.html +0 -1210
  217. package/docs/classes/UndirectedVertex.html +0 -254
  218. package/docs/classes/Vector2D.html +0 -805
  219. package/docs/enums/CP.html +0 -181
  220. package/docs/enums/FamilyPosition.html +0 -181
  221. package/docs/enums/LoopType.html +0 -182
  222. package/docs/enums/RBColor.html +0 -174
  223. package/docs/enums/TopologicalProperty.html +0 -181
  224. package/docs/index.html +0 -645
  225. package/docs/interfaces/IAVLTree.html +0 -1378
  226. package/docs/interfaces/IAVLTreeNode.html +0 -405
  227. package/docs/interfaces/IAbstractBinaryTree.html +0 -1124
  228. package/docs/interfaces/IAbstractBinaryTreeNode.html +0 -384
  229. package/docs/interfaces/IAbstractGraph.html +0 -433
  230. package/docs/interfaces/IBST.html +0 -1271
  231. package/docs/interfaces/IBSTNode.html +0 -408
  232. package/docs/interfaces/IDirectedGraph.html +0 -572
  233. package/docs/interfaces/IUNDirectedGraph.html +0 -465
  234. package/docs/modules.html +0 -262
  235. package/docs/types/AVLTreeOptions.html +0 -150
  236. package/docs/types/AbstractBinaryTreeNodeProperties.html +0 -152
  237. package/docs/types/AbstractBinaryTreeNodeProperty.html +0 -152
  238. package/docs/types/AbstractBinaryTreeOptions.html +0 -156
  239. package/docs/types/AbstractRecursiveBinaryTreeNode.html +0 -152
  240. package/docs/types/BSTComparator.html +0 -162
  241. package/docs/types/BSTOptions.html +0 -152
  242. package/docs/types/BinaryTreeDeletedResult.html +0 -159
  243. package/docs/types/BinaryTreeNodeId.html +0 -147
  244. package/docs/types/BinaryTreeNodePropertyName.html +0 -147
  245. package/docs/types/BinaryTreeOptions.html +0 -150
  246. package/docs/types/DFSOrderPattern.html +0 -147
  247. package/docs/types/DijkstraResult.html +0 -167
  248. package/docs/types/Direction.html +0 -147
  249. package/docs/types/EdgeId.html +0 -147
  250. package/docs/types/HeapOptions.html +0 -168
  251. package/docs/types/IdObject.html +0 -157
  252. package/docs/types/KeyValObject.html +0 -152
  253. package/docs/types/NavigatorParams.html +0 -181
  254. package/docs/types/NodeOrPropertyName.html +0 -147
  255. package/docs/types/PriorityQueueComparator.html +0 -167
  256. package/docs/types/PriorityQueueDFSOrderPattern.html +0 -147
  257. package/docs/types/PriorityQueueOptions.html +0 -161
  258. package/docs/types/RBTreeOptions.html +0 -150
  259. package/docs/types/RecursiveAVLTreeNode.html +0 -152
  260. package/docs/types/RecursiveBSTNode.html +0 -152
  261. package/docs/types/RecursiveBinaryTreeNode.html +0 -152
  262. package/docs/types/RecursiveTreeMultiSetNode.html +0 -152
  263. package/docs/types/SegmentTreeNodeVal.html +0 -147
  264. package/docs/types/TopologicalStatus.html +0 -147
  265. package/docs/types/TreeMultiSetOptions.html +0 -152
  266. package/docs/types/Turning.html +0 -147
  267. package/docs/types/VertexId.html +0 -147
  268. package/notes/bst.test.ts +0 -181
  269. package/notes/note.md +0 -34
@@ -14,17 +14,6 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
- var __values = (this && this.__values) || function(o) {
18
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
19
- if (m) return m.call(o);
20
- if (o && typeof o.length === "number") return {
21
- next: function () {
22
- if (o && i >= o.length) o = void 0;
23
- return { value: o && o[i++], done: !o };
24
- }
25
- };
26
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
27
- };
28
17
  var __read = (this && this.__read) || function (o, n) {
29
18
  var m = typeof Symbol === "function" && o[Symbol.iterator];
30
19
  if (!m) return o;
@@ -50,6 +39,17 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
39
  }
51
40
  return to.concat(ar || Array.prototype.slice.call(from));
52
41
  };
42
+ var __values = (this && this.__values) || function(o) {
43
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
44
+ if (m) return m.call(o);
45
+ if (o && typeof o.length === "number") return {
46
+ next: function () {
47
+ if (o && i >= o.length) o = void 0;
48
+ return { value: o && o[i++], done: !o };
49
+ }
50
+ };
51
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
52
+ };
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  exports.UndirectedGraph = exports.UndirectedEdge = exports.UndirectedVertex = void 0;
55
55
  /**
@@ -65,8 +65,8 @@ var UndirectedVertex = /** @class */ (function (_super) {
65
65
  __extends(UndirectedVertex, _super);
66
66
  /**
67
67
  * The constructor function initializes a vertex with an optional value.
68
- * @param {VertexId} id - The `id` parameter is the identifier for the vertex. It is of type `VertexId`, which is
69
- * typically a unique identifier for each vertex in a graph.
68
+ * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex. It is
69
+ * used to uniquely identify the vertex within a graph or network.
70
70
  * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to initialize the value of the
71
71
  * vertex. If no value is provided, the vertex will be initialized with a default value.
72
72
  */
@@ -79,14 +79,14 @@ exports.UndirectedVertex = UndirectedVertex;
79
79
  var UndirectedEdge = /** @class */ (function (_super) {
80
80
  __extends(UndirectedEdge, _super);
81
81
  /**
82
- * The constructor function initializes an instance of a class with two vertex IDs, an optional weight, and an optional
82
+ * The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional
83
83
  * value.
84
- * @param {VertexId} v1 - The parameter `v1` is of type `VertexId` and represents the first vertex in the edge.
84
+ * @param {VertexId} v1 - The first vertex ID of the edge.
85
85
  * @param {VertexId} v2 - The parameter `v2` is a `VertexId`, which represents the identifier of the second vertex in a
86
86
  * graph edge.
87
87
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
88
- * @param {T} [val] - The "val" parameter is an optional parameter of type T. It represents the value associated with
89
- * the edge.
88
+ * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to store a value associated
89
+ * with the edge.
90
90
  */
91
91
  function UndirectedEdge(v1, v2, weight, val) {
92
92
  var _this = _super.call(this, weight, val) || this;
@@ -108,6 +108,9 @@ var UndirectedEdge = /** @class */ (function (_super) {
108
108
  exports.UndirectedEdge = UndirectedEdge;
109
109
  var UndirectedGraph = /** @class */ (function (_super) {
110
110
  __extends(UndirectedGraph, _super);
111
+ /**
112
+ * The constructor initializes a new Map object to store edges.
113
+ */
111
114
  function UndirectedGraph() {
112
115
  var _this = _super.call(this) || this;
113
116
  _this._edges = new Map();
@@ -121,37 +124,37 @@ var UndirectedGraph = /** @class */ (function (_super) {
121
124
  configurable: true
122
125
  });
123
126
  /**
124
- * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
125
- * This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
126
- * @param id
127
- * @param val
127
+ * The function creates a new vertex with an optional value and returns it.
128
+ * @param {VertexId} id - The `id` parameter is the unique identifier for the vertex. It is used to distinguish one
129
+ * vertex from another in the graph.
130
+ * @param [val] - The `val` parameter is an optional value that can be assigned to the vertex. If a value is provided,
131
+ * it will be used as the value of the vertex. If no value is provided, the `id` parameter will be used as the value of
132
+ * the vertex.
133
+ * @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `V`.
128
134
  */
129
135
  UndirectedGraph.prototype.createVertex = function (id, val) {
130
136
  return new UndirectedVertex(id, val !== null && val !== void 0 ? val : id);
131
137
  };
132
138
  /**
133
- * The function createEdge creates an undirected edge between two vertices with an optional weight and value.
134
- * @param {VertexId} v1 - The parameter `v1` represents the first vertex of the edge. It is of type `VertexId`, which
135
- * could be a unique identifier or label for the vertex.
136
- * @param {VertexId} v2 - The parameter `v2` represents the second vertex of the edge. It is of type `VertexId`, which
137
- * is typically a unique identifier for a vertex in a graph.
138
- * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge. If no
139
- * weight is provided, the default value is 1.
139
+ * The function creates an undirected edge between two vertices with an optional weight and value.
140
+ * @param {VertexId} v1 - The parameter `v1` represents the first vertex of the edge.
141
+ * @param {VertexId} v2 - The parameter `v2` represents the second vertex of the edge.
142
+ * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. If
143
+ * no weight is provided, it defaults to 1.
140
144
  * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type and
141
145
  * is used to store additional information or data associated with the edge.
142
- * @returns an instance of the UndirectedEdge class, casted as type E.
146
+ * @returns a new instance of the `UndirectedEdge` class, which is casted as type `E`.
143
147
  */
144
148
  UndirectedGraph.prototype.createEdge = function (v1, v2, weight, val) {
145
149
  return new UndirectedEdge(v1, v2, weight !== null && weight !== void 0 ? weight : 1, val);
146
150
  };
147
151
  /**
148
- * The function `getEdge` returns the first undirected edge that connects two given vertices, or null if no such edge
149
- * exists.
150
- * @param {V | null | VertexId} v1 - The parameter `v1` represents either an `V`
151
- * object, `null`, or a `VertexId`. It is used to specify one of the vertices of the edge.
152
- * @param {V | null | VertexId} v2 - The parameter `v2` represents either an `UndirectedVertex`
153
- * object or a `VertexId` (identifier) of an undirected vertex.
154
- * @returns an instance of `E` or `null`.
152
+ * The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
153
+ * @param {V | null | VertexId} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `V` (vertex
154
+ * object), `null`, or `VertexId` (a string or number representing the ID of a vertex).
155
+ * @param {V | null | VertexId} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `V` (vertex
156
+ * object), `null`, or `VertexId` (vertex ID).
157
+ * @returns an edge (E) or null.
155
158
  */
156
159
  UndirectedGraph.prototype.getEdge = function (v1, v2) {
157
160
  var _a;
@@ -166,49 +169,11 @@ var UndirectedGraph = /** @class */ (function (_super) {
166
169
  return edges ? edges[0] || null : null;
167
170
  };
168
171
  /**
169
- * The function adds an undirected edge to a graph by updating the adjacency list.
170
- * @param edge - An object representing an undirected edge in a graph. It has a property called "vertices" which is an
171
- * array of two vertices connected by the edge.
172
- * @returns a boolean value.
173
- */
174
- UndirectedGraph.prototype.addEdge = function (edge) {
175
- var e_1, _a;
176
- try {
177
- for (var _b = __values(edge.vertices), _c = _b.next(); !_c.done; _c = _b.next()) {
178
- var end = _c.value;
179
- var endVertex = this._getVertex(end);
180
- if (endVertex === null)
181
- return false;
182
- if (endVertex) {
183
- var edges = this._edges.get(endVertex);
184
- if (edges) {
185
- edges.push(edge);
186
- }
187
- else {
188
- this._edges.set(endVertex, [edge]);
189
- }
190
- }
191
- }
192
- }
193
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
194
- finally {
195
- try {
196
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
197
- }
198
- finally { if (e_1) throw e_1.error; }
199
- }
200
- return true;
201
- };
202
- /**
203
- * The function removes an edge between two vertices in an undirected graph.
204
- * @param {V | VertexId} v1 - The parameter `v1` represents either an `V` object or
205
- * a `VertexId`. It is used to specify one of the vertices of the edge that needs to be removed.
206
- * @param {V | VertexId} v2 - The parameter `v2` represents either an instance of the
207
- * `UndirectedVertex` class or a `VertexId`. It is used to identify the second vertex of the edge that needs to be
208
- * removed.
209
- * @returns The function `removeEdgeBetween` returns an `E` object if an edge is successfully removed
210
- * between the two vertices `v1` and `v2`. If either `v1` or `v2` is not found in the graph, or if there is no edge
211
- * between them, the function returns `null`.
172
+ * The function removes an edge between two vertices in a graph and returns the removed edge.
173
+ * @param {V | VertexId} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexId`).
174
+ * @param {V | VertexId} v2 - V | VertexId - This parameter can be either a vertex object (V) or a vertex ID
175
+ * (VertexId). It represents the second vertex of the edge that needs to be removed.
176
+ * @returns the removed edge (E) if it exists, or null if either of the vertices (V) does not exist.
212
177
  */
213
178
  UndirectedGraph.prototype.removeEdgeBetween = function (v1, v2) {
214
179
  var vertex1 = this._getVertex(v1);
@@ -228,19 +193,19 @@ var UndirectedGraph = /** @class */ (function (_super) {
228
193
  return removed;
229
194
  };
230
195
  /**
231
- * The removeEdge function removes an edge between two vertices in an undirected graph.
232
- * @param edge - An object representing an undirected edge. It has a property called "vertices" which is an array
233
- * containing the two vertices connected by the edge.
234
- * @returns The method is returning an UndirectedEdge object or null.
196
+ * The removeEdge function removes an edge between two vertices in a graph.
197
+ * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
198
+ * @returns The method is returning either the removed edge (of type E) or null if the edge was not found.
235
199
  */
236
200
  UndirectedGraph.prototype.removeEdge = function (edge) {
237
201
  return this.removeEdgeBetween(edge.vertices[0], edge.vertices[1]);
238
202
  };
239
203
  /**
240
- * The function "degreeOf" returns the degree of a given vertex in an undirected graph.
241
- * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or an
242
- * `V`.
243
- * @returns the degree of the vertex.
204
+ * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
205
+ * vertex.
206
+ * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`.
207
+ * @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
208
+ * edges connected to that vertex.
244
209
  */
245
210
  UndirectedGraph.prototype.degreeOf = function (vertexOrId) {
246
211
  var _a;
@@ -253,10 +218,10 @@ var UndirectedGraph = /** @class */ (function (_super) {
253
218
  }
254
219
  };
255
220
  /**
256
- * The function "edgesOf" returns an array of undirected edges connected to a given vertex or vertex ID.
257
- * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or an
258
- * `V`.
259
- * @returns an array of UndirectedEdge objects.
221
+ * The function returns the edges of a given vertex or vertex ID.
222
+ * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`. A `VertexId` is a
223
+ * unique identifier for a vertex in a graph, while `V` represents the type of the vertex.
224
+ * @returns an array of edges.
260
225
  */
261
226
  UndirectedGraph.prototype.edgesOf = function (vertexOrId) {
262
227
  var vertex = this._getVertex(vertexOrId);
@@ -268,8 +233,8 @@ var UndirectedGraph = /** @class */ (function (_super) {
268
233
  }
269
234
  };
270
235
  /**
271
- * The function "edgeSet" returns an array of unique undirected edges from a set of edges.
272
- * @returns The method `edgeSet()` returns an array of `E` objects.
236
+ * The function "edgeSet" returns an array of unique edges from a set of edges.
237
+ * @returns The method `edgeSet()` returns an array of type `E[]`.
273
238
  */
274
239
  UndirectedGraph.prototype.edgeSet = function () {
275
240
  var edgeSet = new Set();
@@ -281,13 +246,13 @@ var UndirectedGraph = /** @class */ (function (_super) {
281
246
  return __spreadArray([], __read(edgeSet), false);
282
247
  };
283
248
  /**
284
- * The function `getNeighbors` returns an array of neighboring vertices of a given vertex in an undirected graph.
285
- * @param {V | VertexId} vertexOrId - The `vertexOrId` parameter can be either an
286
- * `V` object or a `VertexId`. It represents the vertex for which we want to find the neighbors.
287
- * @returns an array of UndirectedVertex objects.
249
+ * The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
250
+ * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a vertex object (`V`) or a vertex ID
251
+ * (`VertexId`).
252
+ * @returns an array of vertices (V[]).
288
253
  */
289
254
  UndirectedGraph.prototype.getNeighbors = function (vertexOrId) {
290
- var e_2, _a;
255
+ var e_1, _a;
291
256
  var neighbors = [];
292
257
  var vertex = this._getVertex(vertexOrId);
293
258
  if (vertex) {
@@ -301,23 +266,22 @@ var UndirectedGraph = /** @class */ (function (_super) {
301
266
  }
302
267
  }
303
268
  }
304
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
269
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
305
270
  finally {
306
271
  try {
307
272
  if (neighborEdges_1_1 && !neighborEdges_1_1.done && (_a = neighborEdges_1.return)) _a.call(neighborEdges_1);
308
273
  }
309
- finally { if (e_2) throw e_2.error; }
274
+ finally { if (e_1) throw e_1.error; }
310
275
  }
311
276
  }
312
277
  return neighbors;
313
278
  };
314
279
  /**
315
- * The function "getEndsOfEdge" returns the two vertices that form the ends of a given undirected edge, or null if the
316
- * edge does not exist in the graph.
317
- * @param edge - An object representing an undirected edge in a graph. It has a property called "vertices" which is an
318
- * array containing two vertices that the edge connects.
319
- * @returns The function `getEndsOfEdge` returns an array containing the two ends of the given `edge` if the edge
320
- * exists in the graph. If the edge does not exist, it returns `null`.
280
+ * The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
281
+ * it returns null.
282
+ * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
283
+ * @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
284
+ * graph. If the edge does not exist, it returns `null`.
321
285
  */
322
286
  UndirectedGraph.prototype.getEndsOfEdge = function (edge) {
323
287
  if (!this.hasEdge(edge.vertices[0], edge.vertices[1])) {
@@ -332,6 +296,43 @@ var UndirectedGraph = /** @class */ (function (_super) {
332
296
  return null;
333
297
  }
334
298
  };
299
+ /**
300
+ * The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
301
+ * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
302
+ * @returns a boolean value.
303
+ */
304
+ UndirectedGraph.prototype._addEdgeOnly = function (edge) {
305
+ var e_2, _a;
306
+ try {
307
+ for (var _b = __values(edge.vertices), _c = _b.next(); !_c.done; _c = _b.next()) {
308
+ var end = _c.value;
309
+ var endVertex = this._getVertex(end);
310
+ if (endVertex === null)
311
+ return false;
312
+ if (endVertex) {
313
+ var edges = this._edges.get(endVertex);
314
+ if (edges) {
315
+ edges.push(edge);
316
+ }
317
+ else {
318
+ this._edges.set(endVertex, [edge]);
319
+ }
320
+ }
321
+ }
322
+ }
323
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
324
+ finally {
325
+ try {
326
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
327
+ }
328
+ finally { if (e_2) throw e_2.error; }
329
+ }
330
+ return true;
331
+ };
332
+ /**
333
+ * The function sets the edges of a graph.
334
+ * @param v - A map where the keys are of type V and the values are arrays of type E.
335
+ */
335
336
  UndirectedGraph.prototype._setEdges = function (v) {
336
337
  this._edges = v;
337
338
  };
@@ -1,28 +1,22 @@
1
1
  import { AbstractBinaryTreeNodeProperties, AbstractBinaryTreeNodeProperty, BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName, DFSOrderPattern, FamilyPosition, LoopType, NodeOrPropertyName } from '../types';
2
2
  import { AbstractBinaryTreeNode } from '../binary-tree';
3
- export interface IAbstractBinaryTreeNode<T, FAMILY extends IAbstractBinaryTreeNode<T, FAMILY>> {
4
- createNode(id: BinaryTreeNodeId, val?: T, count?: number): FAMILY;
3
+ export interface IAbstractBinaryTreeNode<T, NEIGHBOR extends IAbstractBinaryTreeNode<T, NEIGHBOR>> {
5
4
  get id(): BinaryTreeNodeId;
6
5
  set id(v: BinaryTreeNodeId);
7
6
  get val(): T | undefined;
8
7
  set val(v: T | undefined);
9
- get left(): FAMILY | null | undefined;
10
- set left(v: FAMILY | null | undefined);
11
- get right(): FAMILY | null | undefined;
12
- set right(v: FAMILY | null | undefined);
13
- get parent(): FAMILY | null | undefined;
14
- set parent(v: FAMILY | null | undefined);
8
+ get left(): NEIGHBOR | null | undefined;
9
+ set left(v: NEIGHBOR | null | undefined);
10
+ get right(): NEIGHBOR | null | undefined;
11
+ set right(v: NEIGHBOR | null | undefined);
12
+ get parent(): NEIGHBOR | null | undefined;
13
+ set parent(v: NEIGHBOR | null | undefined);
15
14
  get familyPosition(): FamilyPosition;
16
- set familyPosition(v: FamilyPosition);
17
- get count(): number;
18
- set count(v: number);
19
15
  get height(): number;
20
16
  set height(v: number);
21
- swapLocation(swapNode: FAMILY): FAMILY;
22
- clone(): FAMILY | null;
23
17
  }
24
18
  export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N>> {
25
- createNode(id: BinaryTreeNodeId, val: N['val'] | null, count?: number): N | null;
19
+ createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N | null;
26
20
  get loopType(): LoopType;
27
21
  get visitedId(): BinaryTreeNodeId[];
28
22
  get visitedVal(): Array<N['val']>;
@@ -31,10 +25,10 @@ export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'],
31
25
  get visitedLeftSum(): number[];
32
26
  get autoIncrementId(): boolean;
33
27
  get maxId(): number;
34
- get isDuplicatedVal(): boolean;
28
+ get isMergeDuplicatedVal(): boolean;
35
29
  get root(): N | null;
36
30
  get size(): number;
37
- get count(): number;
31
+ swapLocation(srcNode: N, destNode: N): N;
38
32
  clear(): void;
39
33
  isEmpty(): boolean;
40
34
  add(id: BinaryTreeNodeId, val?: N['val'], count?: number): N | null | undefined;
@@ -45,7 +39,7 @@ export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'],
45
39
  getDepth(node: N): number;
46
40
  getHeight(beginRoot?: N | null): number;
47
41
  getMinHeight(beginRoot?: N | null): number;
48
- isBalanced(beginRoot?: N | null): boolean;
42
+ isPerfectlyBalanced(beginRoot?: N | null): boolean;
49
43
  getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
50
44
  has(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): boolean;
51
45
  get(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): N | null;
@@ -58,7 +52,7 @@ export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'],
58
52
  getRightMost(node?: N | null): N | null;
59
53
  isBSTByRooted(node: N | null): boolean;
60
54
  isBST(node?: N | null): boolean;
61
- getSubTreeSizeAndCount(subTreeRoot: N | null | undefined): [number, number];
55
+ getSubTreeSize(subTreeRoot: N | null | undefined): number;
62
56
  subTreeSum(subTreeRoot: N, propertyName?: BinaryTreeNodePropertyName): number;
63
57
  subTreeAdd(subTreeRoot: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
64
58
  BFS(): BinaryTreeNodeId[];
@@ -1,8 +1,7 @@
1
1
  import { VertexId } from '../types';
2
2
  export interface IAbstractGraph<V, E> {
3
3
  hasVertex(vertexOrId: V | VertexId): boolean;
4
- createAddVertex(id: VertexId, val?: V): boolean;
5
- addVertex(newVertex: V): boolean;
4
+ addVertex(id: VertexId, val?: V): boolean;
6
5
  removeVertex(vertexOrId: V | VertexId): boolean;
7
6
  removeAllVertices(vertices: V[] | VertexId[]): boolean;
8
7
  degreeOf(vertexOrId: V | VertexId): number;
@@ -10,8 +9,7 @@ export interface IAbstractGraph<V, E> {
10
9
  hasEdge(src: V | VertexId, dest: V | VertexId): boolean;
11
10
  getEdge(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
12
11
  edgeSet(): E[];
13
- createAddEdge(src: V | VertexId, dest: V | VertexId, weight: number, val: E): boolean;
14
- addEdge(edge: E): boolean;
12
+ addEdge(src: V | VertexId, dest: V | VertexId, weight: number, val: E): boolean;
15
13
  removeEdge(edge: E): E | null;
16
14
  setEdgeWeight(srcOrId: V | VertexId, destOrId: V | VertexId, weight: number): boolean;
17
15
  getMinPathBetween(v1: V | VertexId, v2: V | VertexId, isWeight?: boolean): V[] | null;
@@ -1,10 +1,10 @@
1
1
  import { AVLTreeNode } from '../binary-tree';
2
2
  import { IBST, IBSTNode } from './bst';
3
3
  import { BinaryTreeDeletedResult, BinaryTreeNodeId } from '../types';
4
- export interface IAVLTreeNode<T, FAMILY extends IAVLTreeNode<T, FAMILY>> extends IBSTNode<T, FAMILY> {
4
+ export interface IAVLTreeNode<T, NEIGHBOR extends IAVLTreeNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {
5
5
  }
6
6
  export interface IAVLTree<N extends AVLTreeNode<N['val'], N>> extends IBST<N> {
7
- add(id: BinaryTreeNodeId, val: N['val'] | null, count?: number): N | null;
7
+ add(id: BinaryTreeNodeId, val?: N['val'] | null): N | null | undefined;
8
8
  remove(id: BinaryTreeNodeId, isUpdateAllLeftSum?: boolean): BinaryTreeDeletedResult<N>[];
9
9
  balanceFactor(node: N): number;
10
10
  updateHeight(node: N): void;
@@ -1,6 +1,6 @@
1
1
  import { BinaryTreeNode } from '../binary-tree';
2
2
  import { IAbstractBinaryTree, IAbstractBinaryTreeNode } from './abstract-binary-tree';
3
- export interface IBinaryTreeNode<T, FAMILY extends IBinaryTreeNode<T, FAMILY>> extends IAbstractBinaryTreeNode<T, FAMILY> {
3
+ export interface IBinaryTreeNode<T, NEIGHBOR extends IBinaryTreeNode<T, NEIGHBOR>> extends IAbstractBinaryTreeNode<T, NEIGHBOR> {
4
4
  }
5
5
  export interface IBinaryTree<N extends BinaryTreeNode<N['val'], N>> extends IAbstractBinaryTree<N> {
6
6
  }
@@ -1,18 +1,17 @@
1
1
  import { BSTNode } from '../binary-tree';
2
2
  import { IBinaryTree, IBinaryTreeNode } from './binary-tree';
3
3
  import { BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName } from '../types';
4
- export interface IBSTNode<T, FAMILY extends IBSTNode<T, FAMILY>> extends IBinaryTreeNode<T, FAMILY> {
5
- createNode(id: BinaryTreeNodeId, val?: T, count?: number): FAMILY;
4
+ export interface IBSTNode<T, NEIGHBOR extends IBSTNode<T, NEIGHBOR>> extends IBinaryTreeNode<T, NEIGHBOR> {
6
5
  }
7
6
  export interface IBST<N extends BSTNode<N['val'], N>> extends IBinaryTree<N> {
8
- createNode(id: BinaryTreeNodeId, val?: N['val'] | null, count?: number): N;
9
- add(id: BinaryTreeNodeId, val: N['val'] | null, count: number): N | null;
7
+ createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N;
8
+ add(id: BinaryTreeNodeId, val?: N['val'] | null, count?: number): N | null | undefined;
10
9
  get(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): N | null;
11
10
  lastKey(): BinaryTreeNodeId;
12
11
  remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
13
12
  getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
14
13
  lesserSum(id: BinaryTreeNodeId, propertyName?: BinaryTreeNodePropertyName): number;
15
14
  allGreaterNodesAdd(node: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
16
- balance(): boolean;
15
+ perfectlyBalance(): boolean;
17
16
  isAVLBalanced(): boolean;
18
17
  }
@@ -1,9 +1,8 @@
1
1
  import { RBTreeNode } from '../binary-tree';
2
2
  import { IBST, IBSTNode } from './bst';
3
3
  import { BinaryTreeNodeId } from '../types';
4
- export interface IRBTreeNode<T, FAMILY extends IRBTreeNode<T, FAMILY>> extends IBSTNode<T, FAMILY> {
5
- createNode(id: BinaryTreeNodeId, val?: T | null, count?: number): FAMILY;
4
+ export interface IRBTreeNode<T, NEIGHBOR extends IRBTreeNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {
6
5
  }
7
6
  export interface IRBTree<N extends RBTreeNode<N['val'], N>> extends IBST<N> {
8
- createNode(id: BinaryTreeNodeId, val?: N | null, count?: number): N;
7
+ createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N;
9
8
  }
@@ -1 +1,7 @@
1
- export {};
1
+ import { TreeMultisetNode } from '../binary-tree';
2
+ import { IBSTNode } from './bst';
3
+ import { IAVLTree } from './avl-tree';
4
+ export interface ITreeMultisetNode<T, NEIGHBOR extends ITreeMultisetNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {
5
+ }
6
+ export interface ITreeMultiset<N extends TreeMultisetNode<N['val'], N>> extends IAVLTree<N> {
7
+ }
@@ -1,11 +1,8 @@
1
1
  export declare class TreeNode<T = number> {
2
- constructor(id: string, name?: string, value?: T, children?: TreeNode<T>[]);
2
+ constructor(id: string, value?: T, children?: TreeNode<T>[]);
3
3
  private _id;
4
4
  get id(): string;
5
5
  set id(value: string);
6
- private _name?;
7
- get name(): string | undefined;
8
- set name(value: string | undefined);
9
6
  private _value?;
10
7
  get value(): T | undefined;
11
8
  set value(value: T | undefined);
@@ -2,9 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TreeNode = void 0;
4
4
  var TreeNode = /** @class */ (function () {
5
- function TreeNode(id, name, value, children) {
5
+ function TreeNode(id, value, children) {
6
6
  this._id = id;
7
- this._name = name || '';
8
7
  this._value = value || undefined;
9
8
  this._children = children || [];
10
9
  }
@@ -18,16 +17,6 @@ var TreeNode = /** @class */ (function () {
18
17
  enumerable: false,
19
18
  configurable: true
20
19
  });
21
- Object.defineProperty(TreeNode.prototype, "name", {
22
- get: function () {
23
- return this._name;
24
- },
25
- set: function (value) {
26
- this._name = value;
27
- },
28
- enumerable: false,
29
- configurable: true
30
- });
31
20
  Object.defineProperty(TreeNode.prototype, "value", {
32
21
  get: function () {
33
22
  return this._value;
@@ -10,11 +10,15 @@ export declare enum LoopType {
10
10
  RECURSIVE = "RECURSIVE"
11
11
  }
12
12
  export declare enum FamilyPosition {
13
- ROOT = 0,
14
- LEFT = 1,
15
- RIGHT = 2
13
+ ROOT = "ROOT",
14
+ LEFT = "LEFT",
15
+ RIGHT = "RIGHT",
16
+ ROOT_LEFT = "ROOT_LEFT",
17
+ ROOT_RIGHT = "ROOT_RIGHT",
18
+ ISOLATED = "ISOLATED",
19
+ MAL_NODE = "MAL_NODE"
16
20
  }
17
- export type BinaryTreeNodePropertyName = 'id' | 'val' | 'count';
21
+ export type BinaryTreeNodePropertyName = 'id' | 'val';
18
22
  export type NodeOrPropertyName = 'node' | BinaryTreeNodePropertyName;
19
23
  export type DFSOrderPattern = 'in' | 'pre' | 'post';
20
24
  export type BinaryTreeNodeId = number;
@@ -24,9 +28,9 @@ export type BinaryTreeDeletedResult<N> = {
24
28
  };
25
29
  export type AbstractBinaryTreeNodeProperty<N extends AbstractBinaryTreeNode<N['val'], N>> = N['val'] | N | number | BinaryTreeNodeId;
26
30
  export type AbstractBinaryTreeNodeProperties<N extends AbstractBinaryTreeNode<N['val'], N>> = AbstractBinaryTreeNodeProperty<N>[];
27
- export type AbstractRecursiveBinaryTreeNode<T> = AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
31
+ export type AbstractBinaryTreeNodeNested<T> = AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
28
32
  export type AbstractBinaryTreeOptions = {
29
33
  loopType?: LoopType;
30
34
  autoIncrementId?: boolean;
31
- isDuplicatedVal?: boolean;
35
+ isMergeDuplicatedVal?: boolean;
32
36
  };
@@ -11,11 +11,15 @@ var LoopType;
11
11
  (function (LoopType) {
12
12
  LoopType["ITERATIVE"] = "ITERATIVE";
13
13
  LoopType["RECURSIVE"] = "RECURSIVE";
14
- })(LoopType || (exports.LoopType = LoopType = {}));
14
+ })(LoopType = exports.LoopType || (exports.LoopType = {}));
15
15
  /* This enumeration defines the position of a node within a family tree composed of three associated nodes, where 'root' represents the root node of the family tree, 'left' represents the left child node, and 'right' represents the right child node. */
16
16
  var FamilyPosition;
17
17
  (function (FamilyPosition) {
18
- FamilyPosition[FamilyPosition["ROOT"] = 0] = "ROOT";
19
- FamilyPosition[FamilyPosition["LEFT"] = 1] = "LEFT";
20
- FamilyPosition[FamilyPosition["RIGHT"] = 2] = "RIGHT";
21
- })(FamilyPosition || (exports.FamilyPosition = FamilyPosition = {}));
18
+ FamilyPosition["ROOT"] = "ROOT";
19
+ FamilyPosition["LEFT"] = "LEFT";
20
+ FamilyPosition["RIGHT"] = "RIGHT";
21
+ FamilyPosition["ROOT_LEFT"] = "ROOT_LEFT";
22
+ FamilyPosition["ROOT_RIGHT"] = "ROOT_RIGHT";
23
+ FamilyPosition["ISOLATED"] = "ISOLATED";
24
+ FamilyPosition["MAL_NODE"] = "MAL_NODE";
25
+ })(FamilyPosition = exports.FamilyPosition || (exports.FamilyPosition = {}));
@@ -1,4 +1,4 @@
1
1
  import { AVLTreeNode } from '../binary-tree';
2
2
  import { BSTOptions } from './bst';
3
- export type RecursiveAVLTreeNode<T> = AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
3
+ export type AVLTreeNodeNested<T> = AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
4
  export type AVLTreeOptions = BSTOptions & {};
@@ -1,4 +1,4 @@
1
1
  import { BinaryTreeNode } from '../binary-tree';
2
2
  import { AbstractBinaryTreeOptions } from './abstract-binary-tree';
3
- export type RecursiveBinaryTreeNode<T> = BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
3
+ export type BinaryTreeNodeNested<T> = BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
4
  export type BinaryTreeOptions = AbstractBinaryTreeOptions & {};