data-structure-typed 1.33.0 → 1.33.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 (222) hide show
  1. package/{.eslintrc.json → .eslintrc.js} +2 -1
  2. package/.github/workflows/ci.yml +15 -3
  3. package/.github/workflows/release-package.yml +32 -0
  4. package/{.prettierrc → .prettierrc.js} +1 -1
  5. package/CHANGELOG.md +5 -1
  6. package/README.md +196 -257
  7. package/coverage/coverage-final.json +64 -64
  8. package/coverage/coverage-summary.json +16 -16
  9. package/dist/data-structures/binary-tree/abstract-binary-tree.js +1 -16
  10. package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -1
  11. package/dist/data-structures/binary-tree/avl-tree.js +2 -2
  12. package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
  13. package/dist/data-structures/binary-tree/rb-tree.js +3 -4
  14. package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
  15. package/dist/data-structures/graph/abstract-graph.js +12 -12
  16. package/dist/data-structures/graph/abstract-graph.js.map +1 -1
  17. package/dist/data-structures/graph/directed-graph.js.map +1 -1
  18. package/dist/data-structures/graph/undirected-graph.js.map +1 -1
  19. package/dist/data-structures/hash/hash-table.js +107 -2
  20. package/dist/data-structures/hash/hash-table.js.map +1 -1
  21. package/dist/data-structures/heap/max-heap.js.map +1 -1
  22. package/dist/data-structures/heap/min-heap.js.map +1 -1
  23. package/dist/data-structures/linked-list/doubly-linked-list.js +30 -0
  24. package/dist/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  25. package/dist/data-structures/matrix/matrix2d.js +5 -8
  26. package/dist/data-structures/matrix/matrix2d.js.map +1 -1
  27. package/dist/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  28. package/dist/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  29. package/dist/data-structures/priority-queue/priority-queue.js +6 -6
  30. package/dist/data-structures/priority-queue/priority-queue.js.map +1 -1
  31. package/dist/data-structures/queue/deque.js.map +1 -1
  32. package/docs/index.html +196 -256
  33. package/docs/modules.html +2 -0
  34. package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +8 -18
  35. package/lib/data-structures/binary-tree/abstract-binary-tree.js +5 -23
  36. package/lib/data-structures/binary-tree/avl-tree.d.ts +7 -10
  37. package/lib/data-structures/binary-tree/avl-tree.js +6 -9
  38. package/lib/data-structures/binary-tree/binary-tree.d.ts +2 -2
  39. package/lib/data-structures/binary-tree/bst.d.ts +2 -2
  40. package/lib/data-structures/binary-tree/rb-tree.d.ts +3 -3
  41. package/lib/data-structures/binary-tree/rb-tree.js +3 -3
  42. package/lib/data-structures/binary-tree/tree-multiset.d.ts +3 -3
  43. package/lib/data-structures/binary-tree/tree-multiset.js +1 -1
  44. package/lib/data-structures/graph/abstract-graph.d.ts +10 -10
  45. package/lib/data-structures/graph/abstract-graph.js +2 -2
  46. package/lib/data-structures/graph/directed-graph.d.ts +6 -6
  47. package/lib/data-structures/graph/directed-graph.js +2 -2
  48. package/lib/data-structures/graph/map-graph.d.ts +6 -6
  49. package/lib/data-structures/graph/map-graph.js +2 -2
  50. package/lib/data-structures/graph/undirected-graph.d.ts +6 -6
  51. package/lib/data-structures/graph/undirected-graph.js +2 -2
  52. package/lib/data-structures/hash/hash-table.d.ts +61 -1
  53. package/lib/data-structures/hash/hash-table.js +136 -0
  54. package/lib/data-structures/heap/heap.d.ts +31 -31
  55. package/lib/data-structures/heap/heap.js +11 -11
  56. package/lib/data-structures/heap/max-heap.d.ts +4 -4
  57. package/lib/data-structures/heap/max-heap.js +1 -1
  58. package/lib/data-structures/heap/min-heap.d.ts +4 -4
  59. package/lib/data-structures/heap/min-heap.js +1 -1
  60. package/lib/data-structures/linked-list/doubly-linked-list.d.ts +93 -54
  61. package/lib/data-structures/linked-list/doubly-linked-list.js +79 -22
  62. package/lib/data-structures/linked-list/singly-linked-list.d.ts +46 -46
  63. package/lib/data-structures/linked-list/singly-linked-list.js +20 -20
  64. package/lib/data-structures/matrix/matrix.d.ts +3 -3
  65. package/lib/data-structures/matrix/matrix2d.d.ts +1 -1
  66. package/lib/data-structures/matrix/matrix2d.js +3 -2
  67. package/lib/data-structures/priority-queue/max-priority-queue.d.ts +4 -4
  68. package/lib/data-structures/priority-queue/min-priority-queue.d.ts +4 -4
  69. package/lib/data-structures/priority-queue/priority-queue.d.ts +26 -26
  70. package/lib/data-structures/priority-queue/priority-queue.js +8 -8
  71. package/lib/data-structures/queue/deque.d.ts +30 -30
  72. package/lib/data-structures/queue/deque.js +7 -7
  73. package/lib/data-structures/queue/queue.d.ts +27 -27
  74. package/lib/data-structures/queue/queue.js +8 -8
  75. package/lib/data-structures/stack/stack.d.ts +15 -15
  76. package/lib/data-structures/stack/stack.js +6 -6
  77. package/lib/data-structures/tree/tree.d.ts +7 -7
  78. package/lib/interfaces/abstract-binary-tree.d.ts +0 -1
  79. package/lib/interfaces/avl-tree.d.ts +1 -1
  80. package/lib/types/data-structures/navigator.d.ts +1 -1
  81. package/package.json +68 -62
  82. package/src/data-structures/binary-tree/aa-tree.ts +1 -0
  83. package/src/data-structures/binary-tree/abstract-binary-tree.ts +1608 -0
  84. package/src/data-structures/binary-tree/avl-tree.ts +307 -0
  85. package/src/data-structures/binary-tree/b-tree.ts +1 -0
  86. package/src/data-structures/binary-tree/binary-indexed-tree.ts +76 -0
  87. package/src/data-structures/binary-tree/binary-tree.ts +47 -0
  88. package/src/data-structures/binary-tree/bst.ts +537 -0
  89. package/src/data-structures/binary-tree/index.ts +12 -0
  90. package/src/data-structures/binary-tree/rb-tree.ts +366 -0
  91. package/src/data-structures/binary-tree/segment-tree.ts +242 -0
  92. package/src/data-structures/binary-tree/splay-tree.ts +1 -0
  93. package/src/data-structures/binary-tree/tree-multiset.ts +700 -0
  94. package/src/data-structures/binary-tree/two-three-tree.ts +1 -0
  95. package/src/data-structures/graph/abstract-graph.ts +1040 -0
  96. package/src/data-structures/graph/directed-graph.ts +470 -0
  97. package/src/data-structures/graph/index.ts +4 -0
  98. package/src/data-structures/graph/map-graph.ts +129 -0
  99. package/src/data-structures/graph/undirected-graph.ts +274 -0
  100. package/src/data-structures/hash/coordinate-map.ts +67 -0
  101. package/src/data-structures/hash/coordinate-set.ts +56 -0
  102. package/src/data-structures/hash/hash-table.ts +157 -0
  103. package/src/data-structures/hash/index.ts +6 -0
  104. package/src/data-structures/hash/pair.ts +1 -0
  105. package/src/data-structures/hash/tree-map.ts +1 -0
  106. package/src/data-structures/hash/tree-set.ts +1 -0
  107. package/src/data-structures/heap/heap.ts +212 -0
  108. package/src/data-structures/heap/index.ts +3 -0
  109. package/src/data-structures/heap/max-heap.ts +31 -0
  110. package/src/data-structures/heap/min-heap.ts +32 -0
  111. package/src/data-structures/index.ts +11 -0
  112. package/src/data-structures/linked-list/doubly-linked-list.ts +636 -0
  113. package/src/data-structures/linked-list/index.ts +3 -0
  114. package/src/data-structures/linked-list/singly-linked-list.ts +501 -0
  115. package/src/data-structures/linked-list/skip-linked-list.ts +1 -0
  116. package/src/data-structures/matrix/index.ts +4 -0
  117. package/src/data-structures/matrix/matrix.ts +27 -0
  118. package/src/data-structures/matrix/matrix2d.ts +213 -0
  119. package/src/data-structures/matrix/navigator.ts +121 -0
  120. package/src/data-structures/matrix/vector2d.ts +316 -0
  121. package/src/data-structures/priority-queue/index.ts +3 -0
  122. package/src/data-structures/priority-queue/max-priority-queue.ts +56 -0
  123. package/src/data-structures/priority-queue/min-priority-queue.ts +57 -0
  124. package/src/data-structures/priority-queue/priority-queue.ts +359 -0
  125. package/src/data-structures/queue/deque.ts +297 -0
  126. package/src/data-structures/queue/index.ts +2 -0
  127. package/src/data-structures/queue/queue.ts +191 -0
  128. package/src/data-structures/stack/index.ts +1 -0
  129. package/src/data-structures/stack/stack.ts +98 -0
  130. package/src/data-structures/tree/index.ts +1 -0
  131. package/src/data-structures/tree/tree.ts +69 -0
  132. package/src/data-structures/trie/index.ts +1 -0
  133. package/src/data-structures/trie/trie.ts +225 -0
  134. package/src/index.ts +4 -0
  135. package/src/interfaces/abstract-binary-tree.ts +189 -0
  136. package/src/interfaces/abstract-graph.ts +31 -0
  137. package/src/interfaces/avl-tree.ts +25 -0
  138. package/src/interfaces/binary-tree.ts +6 -0
  139. package/src/interfaces/bst.ts +31 -0
  140. package/src/interfaces/directed-graph.ts +20 -0
  141. package/src/interfaces/doubly-linked-list.ts +1 -0
  142. package/src/interfaces/heap.ts +1 -0
  143. package/src/interfaces/index.ts +15 -0
  144. package/src/interfaces/navigator.ts +1 -0
  145. package/src/interfaces/priority-queue.ts +1 -0
  146. package/src/interfaces/rb-tree.ts +9 -0
  147. package/src/interfaces/segment-tree.ts +1 -0
  148. package/src/interfaces/singly-linked-list.ts +1 -0
  149. package/src/interfaces/tree-multiset.ts +7 -0
  150. package/src/interfaces/undirected-graph.ts +6 -0
  151. package/src/types/data-structures/abstract-binary-tree.ts +50 -0
  152. package/src/types/data-structures/abstract-graph.ts +11 -0
  153. package/src/types/data-structures/avl-tree.ts +5 -0
  154. package/src/types/data-structures/binary-tree.ts +5 -0
  155. package/src/types/data-structures/bst.ts +13 -0
  156. package/src/types/data-structures/directed-graph.ts +8 -0
  157. package/src/types/data-structures/doubly-linked-list.ts +1 -0
  158. package/src/types/data-structures/heap.ts +5 -0
  159. package/src/types/data-structures/index.ts +15 -0
  160. package/src/types/data-structures/map-graph.ts +1 -0
  161. package/src/types/data-structures/navigator.ts +13 -0
  162. package/src/types/data-structures/priority-queue.ts +9 -0
  163. package/src/types/data-structures/rb-tree.ts +8 -0
  164. package/src/types/data-structures/segment-tree.ts +1 -0
  165. package/src/types/data-structures/singly-linked-list.ts +1 -0
  166. package/src/types/data-structures/tree-multiset.ts +6 -0
  167. package/src/types/helpers.ts +1 -0
  168. package/src/types/index.ts +3 -0
  169. package/src/types/utils/index.ts +2 -0
  170. package/src/types/utils/utils.ts +6 -0
  171. package/src/types/utils/validate-type.ts +35 -0
  172. package/src/utils/index.ts +1 -0
  173. package/src/utils/utils.ts +79 -0
  174. package/test/integration/avl-tree.test.ts +14 -17
  175. package/test/integration/bst.test.ts +50 -41
  176. package/test/integration/heap.test.js +0 -3
  177. package/test/integration/index.html +6 -6
  178. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +14 -17
  179. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +142 -0
  180. package/test/unit/data-structures/binary-tree/bst.test.ts +50 -41
  181. package/test/unit/data-structures/binary-tree/overall.test.ts +36 -28
  182. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +43 -0
  183. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +23 -12
  184. package/test/unit/data-structures/graph/directed-graph.test.ts +27 -25
  185. package/test/unit/data-structures/graph/map-graph.test.ts +4 -5
  186. package/test/unit/data-structures/graph/overall.test.ts +10 -11
  187. package/test/unit/data-structures/graph/undirected-graph.test.ts +0 -1
  188. package/test/unit/data-structures/hash/coordinate-map.test.ts +54 -0
  189. package/test/unit/data-structures/hash/coordinate-set.test.ts +41 -0
  190. package/test/unit/data-structures/hash/hash-table.test.ts +97 -0
  191. package/test/unit/data-structures/heap/heap.test.ts +7 -8
  192. package/test/unit/data-structures/heap/max-heap.test.ts +7 -5
  193. package/test/unit/data-structures/heap/min-heap.test.ts +6 -5
  194. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +8 -9
  195. package/test/unit/data-structures/linked-list/linked-list.test.ts +2 -4
  196. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +57 -7
  197. package/test/unit/data-structures/linked-list/skip-linked-list.test.ts +3 -3
  198. package/test/unit/data-structures/matrix/matrix.test.ts +54 -0
  199. package/test/unit/data-structures/matrix/matrix2d.test.ts +138 -0
  200. package/test/unit/data-structures/matrix/navigator.test.ts +79 -0
  201. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +5 -7
  202. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +13 -13
  203. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +8 -8
  204. package/test/unit/data-structures/queue/deque.test.ts +130 -0
  205. package/test/unit/data-structures/queue/queue.test.ts +167 -4
  206. package/test/unit/data-structures/stack/stack.test.ts +67 -0
  207. package/test/unit/data-structures/tree/tree.test.ts +39 -0
  208. package/test/unit/data-structures/trie/trie.test.ts +95 -0
  209. package/test/utils/magnitude.ts +3 -3
  210. package/tsconfig.json +3 -12
  211. package/tsconfig.prod.json +25 -0
  212. package/umd/bundle.min.js +1 -1
  213. package/umd/bundle.min.js.map +1 -1
  214. package/.auto-changelog +0 -9
  215. package/.gitattributes +0 -112
  216. package/.idea/data-structure-typed.iml +0 -19
  217. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  218. package/.idea/misc.xml +0 -6
  219. package/.idea/modules.xml +0 -8
  220. package/.idea/vcs.xml +0 -6
  221. package/.prettierignore +0 -6
  222. package/webpack.config.js +0 -28
package/docs/modules.html CHANGED
@@ -49,6 +49,7 @@
49
49
  <a href="classes/DirectedVertex.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Directed<wbr/>Vertex</span></a>
50
50
  <a href="classes/DoublyLinkedList.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Doubly<wbr/>Linked<wbr/>List</span></a>
51
51
  <a href="classes/DoublyLinkedListNode.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Doubly<wbr/>Linked<wbr/>List<wbr/>Node</span></a>
52
+ <a href="classes/HashNode.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Hash<wbr/>Node</span></a>
52
53
  <a href="classes/HashTable.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Hash<wbr/>Table</span></a>
53
54
  <a href="classes/Heap.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Heap</span></a>
54
55
  <a href="classes/HeapItem.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Heap<wbr/>Item</span></a>
@@ -216,6 +217,7 @@
216
217
  <li><a href="classes/DirectedVertex.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Directed<wbr/>Vertex</span></a></li>
217
218
  <li><a href="classes/DoublyLinkedList.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Doubly<wbr/>Linked<wbr/>List</span></a></li>
218
219
  <li><a href="classes/DoublyLinkedListNode.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Doubly<wbr/>Linked<wbr/>List<wbr/>Node</span></a></li>
220
+ <li><a href="classes/HashNode.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Hash<wbr/>Node</span></a></li>
219
221
  <li><a href="classes/HashTable.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Hash<wbr/>Table</span></a></li>
220
222
  <li><a href="classes/Heap.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Heap</span></a></li>
221
223
  <li><a href="classes/HeapItem.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Heap<wbr/>Item</span></a></li>
@@ -8,21 +8,21 @@
8
8
  import type { AbstractBinaryTreeNodeNested, AbstractBinaryTreeNodeProperties, BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName, DFSOrderPattern, NodeOrPropertyName } from '../../types';
9
9
  import { AbstractBinaryTreeOptions, FamilyPosition, LoopType } from '../../types';
10
10
  import { IAbstractBinaryTree, IAbstractBinaryTreeNode } from '../../interfaces';
11
- export declare abstract class AbstractBinaryTreeNode<T = any, NEIGHBOR extends AbstractBinaryTreeNode<T, NEIGHBOR> = AbstractBinaryTreeNodeNested<T>> implements IAbstractBinaryTreeNode<T, NEIGHBOR> {
11
+ export declare abstract class AbstractBinaryTreeNode<V = any, NEIGHBOR extends AbstractBinaryTreeNode<V, NEIGHBOR> = AbstractBinaryTreeNodeNested<V>> implements IAbstractBinaryTreeNode<V, NEIGHBOR> {
12
12
  /**
13
13
  * The constructor function initializes a BinaryTreeNode object with an id and an optional value.
14
14
  * @param {BinaryTreeNodeId} id - The `id` parameter is of type `BinaryTreeNodeId` and represents the unique identifier
15
15
  * of the binary tree node. It is used to distinguish one node from another in the binary tree.
16
- * @param {T} [val] - The "val" parameter is an optional parameter of type T. It represents the value that will be
16
+ * @param {V} [val] - The "val" parameter is an optional parameter of type V. It represents the value that will be
17
17
  * stored in the binary tree node. If no value is provided, it will be set to undefined.
18
18
  */
19
- protected constructor(id: BinaryTreeNodeId, val?: T);
19
+ protected constructor(id: BinaryTreeNodeId, val?: V);
20
20
  private _id;
21
21
  get id(): BinaryTreeNodeId;
22
22
  set id(v: BinaryTreeNodeId);
23
23
  private _val;
24
- get val(): T | undefined;
25
- set val(value: T | undefined);
24
+ get val(): V | undefined;
25
+ set val(value: V | undefined);
26
26
  private _left;
27
27
  get left(): NEIGHBOR | null | undefined;
28
28
  set left(v: NEIGHBOR | null | undefined);
@@ -60,8 +60,6 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
60
60
  get visitedVal(): N['val'][];
61
61
  private _visitedNode;
62
62
  get visitedNode(): N[];
63
- private _visitedLeftSum;
64
- get visitedLeftSum(): number[];
65
63
  abstract createNode(id: BinaryTreeNodeId, val?: N['val']): N | null;
66
64
  /**
67
65
  * The `swapLocation` function swaps the location of two nodes in a binary tree.
@@ -116,16 +114,13 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
116
114
  */
117
115
  fill(idsOrNodes: (BinaryTreeNodeId | null)[] | (N | null)[], data?: N[] | Array<N['val']>): boolean;
118
116
  /**
119
- * The `remove` function removes a node from a binary search tree and returns the deleted node along with the parent node
120
- * that needs to be balanced.
117
+ * The `remove` function in TypeScript is used to delete a node from a binary search tree and returns an array of objects
118
+ * containing the deleted node and the node that needs to be balanced.
121
119
  * @param {N | BinaryTreeNodeId} nodeOrId - The `nodeOrId` parameter can be either a node object (`N`) or a binary tree
122
120
  * node ID (`BinaryTreeNodeId`).
123
- * @param {boolean} [isUpdateAllLeftSum] - The `isUpdateAllLeftSum` parameter is an optional boolean parameter that
124
- * determines whether to update the left sum of all nodes in the binary tree after removing a node. If
125
- * `isUpdateAllLeftSum` is set to `true`, the left sum of all nodes will be updated. If it
126
121
  * @returns The function `remove` returns an array of `BinaryTreeDeletedResult<N>` objects.
127
122
  */
128
- remove(nodeOrId: N | BinaryTreeNodeId, isUpdateAllLeftSum?: boolean): BinaryTreeDeletedResult<N>[];
123
+ remove(nodeOrId: N | BinaryTreeNodeId): BinaryTreeDeletedResult<N>[];
129
124
  /**
130
125
  * The function calculates the depth of a node in a binary tree.
131
126
  * @param {N | BinaryTreeNodeId | null} beginRoot - The `beginRoot` parameter can be one of the following:
@@ -476,11 +471,6 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
476
471
  * @param {N[]} value - N[] is an array of elements of type N.
477
472
  */
478
473
  protected _setVisitedNode(value: N[]): void;
479
- /**
480
- * The function sets the value of the `_visitedLeftSum` property to the provided array.
481
- * @param {number[]} value - An array of numbers that represents the visited left sum.
482
- */
483
- protected _setVisitedLeftSum(value: number[]): void;
484
474
  /**
485
475
  * The function sets the root property of an object to a given value, and if the value is not null, it also sets the
486
476
  * parent property of the value to undefined.
@@ -12,7 +12,7 @@ export class AbstractBinaryTreeNode {
12
12
  * The constructor function initializes a BinaryTreeNode object with an id and an optional value.
13
13
  * @param {BinaryTreeNodeId} id - The `id` parameter is of type `BinaryTreeNodeId` and represents the unique identifier
14
14
  * of the binary tree node. It is used to distinguish one node from another in the binary tree.
15
- * @param {T} [val] - The "val" parameter is an optional parameter of type T. It represents the value that will be
15
+ * @param {V} [val] - The "val" parameter is an optional parameter of type V. It represents the value that will be
16
16
  * stored in the binary tree node. If no value is provided, it will be set to undefined.
17
17
  */
18
18
  constructor(id, val) {
@@ -106,13 +106,13 @@ export class AbstractBinaryTree {
106
106
  * tree.
107
107
  */
108
108
  constructor(options) {
109
+ // TODO placeholder node may need redesigned
109
110
  this._root = null;
110
111
  this._size = 0;
111
112
  this._loopType = LoopType.ITERATIVE;
112
113
  this._visitedId = [];
113
114
  this._visitedVal = [];
114
115
  this._visitedNode = [];
115
- this._visitedLeftSum = [];
116
116
  if (options !== undefined) {
117
117
  const { loopType = LoopType.ITERATIVE } = options;
118
118
  this._loopType = loopType;
@@ -137,9 +137,6 @@ export class AbstractBinaryTree {
137
137
  get visitedNode() {
138
138
  return this._visitedNode;
139
139
  }
140
- get visitedLeftSum() {
141
- return this._visitedLeftSum;
142
- }
143
140
  /**
144
141
  * The `swapLocation` function swaps the location of two nodes in a binary tree.
145
142
  * @param {N} srcNode - The source node that you want to swap with the destination node.
@@ -287,20 +284,13 @@ export class AbstractBinaryTree {
287
284
  return idsOrNodes.length === this.addMany(idsOrNodes, data).length;
288
285
  }
289
286
  /**
290
- * The `remove` function removes a node from a binary search tree and returns the deleted node along with the parent node
291
- * that needs to be balanced.
287
+ * The `remove` function in TypeScript is used to delete a node from a binary search tree and returns an array of objects
288
+ * containing the deleted node and the node that needs to be balanced.
292
289
  * @param {N | BinaryTreeNodeId} nodeOrId - The `nodeOrId` parameter can be either a node object (`N`) or a binary tree
293
290
  * node ID (`BinaryTreeNodeId`).
294
- * @param {boolean} [isUpdateAllLeftSum] - The `isUpdateAllLeftSum` parameter is an optional boolean parameter that
295
- * determines whether to update the left sum of all nodes in the binary tree after removing a node. If
296
- * `isUpdateAllLeftSum` is set to `true`, the left sum of all nodes will be updated. If it
297
291
  * @returns The function `remove` returns an array of `BinaryTreeDeletedResult<N>` objects.
298
292
  */
299
- remove(nodeOrId, isUpdateAllLeftSum) {
300
- isUpdateAllLeftSum = isUpdateAllLeftSum === undefined ? true : isUpdateAllLeftSum;
301
- // TODO may implement update all left sum
302
- if (isUpdateAllLeftSum) {
303
- }
293
+ remove(nodeOrId) {
304
294
  const bstDeletedResult = [];
305
295
  if (!this.root)
306
296
  return bstDeletedResult;
@@ -1168,13 +1158,6 @@ export class AbstractBinaryTree {
1168
1158
  _setVisitedNode(value) {
1169
1159
  this._visitedNode = value;
1170
1160
  }
1171
- /**
1172
- * The function sets the value of the `_visitedLeftSum` property to the provided array.
1173
- * @param {number[]} value - An array of numbers that represents the visited left sum.
1174
- */
1175
- _setVisitedLeftSum(value) {
1176
- this._visitedLeftSum = value;
1177
- }
1178
1161
  /**
1179
1162
  * The function sets the root property of an object to a given value, and if the value is not null, it also sets the
1180
1163
  * parent property of the value to undefined.
@@ -1201,7 +1184,6 @@ export class AbstractBinaryTree {
1201
1184
  this._visitedId = [];
1202
1185
  this._visitedVal = [];
1203
1186
  this._visitedNode = [];
1204
- this._visitedLeftSum = [];
1205
1187
  }
1206
1188
  /**
1207
1189
  * The function checks if a given property of a binary tree node matches a specified value, and if so, adds the node to
@@ -8,8 +8,8 @@
8
8
  import { BST, BSTNode } from './bst';
9
9
  import type { AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeletedResult, BinaryTreeNodeId } from '../../types';
10
10
  import { IAVLTree, IAVLTreeNode } from '../../interfaces';
11
- export declare class AVLTreeNode<T = any, NEIGHBOR extends AVLTreeNode<T, NEIGHBOR> = AVLTreeNodeNested<T>> extends BSTNode<T, NEIGHBOR> implements IAVLTreeNode<T, NEIGHBOR> {
12
- constructor(id: BinaryTreeNodeId, val?: T);
11
+ export declare class AVLTreeNode<V = any, NEIGHBOR extends AVLTreeNode<V, NEIGHBOR> = AVLTreeNodeNested<V>> extends BSTNode<V, NEIGHBOR> implements IAVLTreeNode<V, NEIGHBOR> {
12
+ constructor(id: BinaryTreeNodeId, val?: V);
13
13
  }
14
14
  export declare class AVLTree<N extends AVLTreeNode<N['val'], N> = AVLTreeNode> extends BST<N> implements IAVLTree<N> {
15
15
  /**
@@ -37,16 +37,13 @@ export declare class AVLTree<N extends AVLTreeNode<N['val'], N> = AVLTreeNode> e
37
37
  */
38
38
  add(id: BinaryTreeNodeId, val?: N['val']): N | null | undefined;
39
39
  /**
40
- * The function overrides the remove method of the Binary Search Tree class, performs the removal operation, and
41
- * then balances the tree if necessary.
40
+ * The function overrides the remove method of a binary tree and performs additional operations to balance the tree after
41
+ * deletion.
42
42
  * @param {BinaryTreeNodeId} id - The `id` parameter represents the identifier of the binary tree node that needs to be
43
- * removed from the AVL tree.
44
- * @param {boolean} [isUpdateAllLeftSum] - The `isUpdateAllLeftSum` parameter is an optional boolean parameter that
45
- * determines whether the left sum of all nodes in the AVL tree should be updated after removing a node. If
46
- * `isUpdateAllLeftSum` is set to `true`, the left sum of all nodes will be recalculated.
47
- * @returns The method is returning an array of `AVLTreeDeleted<N>` objects.
43
+ * removed.
44
+ * @returns The method is returning an array of `BinaryTreeDeletedResult<N>` objects.
48
45
  */
49
- remove(id: BinaryTreeNodeId, isUpdateAllLeftSum?: boolean): BinaryTreeDeletedResult<N>[];
46
+ remove(id: BinaryTreeNodeId): BinaryTreeDeletedResult<N>[];
50
47
  /**
51
48
  * The balance factor of a given AVL tree node is calculated by subtracting the height of its left subtree from the
52
49
  * height of its right subtree.
@@ -47,17 +47,14 @@ export class AVLTree extends BST {
47
47
  return inserted;
48
48
  }
49
49
  /**
50
- * The function overrides the remove method of the Binary Search Tree class, performs the removal operation, and
51
- * then balances the tree if necessary.
50
+ * The function overrides the remove method of a binary tree and performs additional operations to balance the tree after
51
+ * deletion.
52
52
  * @param {BinaryTreeNodeId} id - The `id` parameter represents the identifier of the binary tree node that needs to be
53
- * removed from the AVL tree.
54
- * @param {boolean} [isUpdateAllLeftSum] - The `isUpdateAllLeftSum` parameter is an optional boolean parameter that
55
- * determines whether the left sum of all nodes in the AVL tree should be updated after removing a node. If
56
- * `isUpdateAllLeftSum` is set to `true`, the left sum of all nodes will be recalculated.
57
- * @returns The method is returning an array of `AVLTreeDeleted<N>` objects.
53
+ * removed.
54
+ * @returns The method is returning an array of `BinaryTreeDeletedResult<N>` objects.
58
55
  */
59
- remove(id, isUpdateAllLeftSum) {
60
- const deletedResults = super.remove(id, isUpdateAllLeftSum);
56
+ remove(id) {
57
+ const deletedResults = super.remove(id);
61
58
  for (const { needBalanced } of deletedResults) {
62
59
  if (needBalanced) {
63
60
  this._balancePath(needBalanced);
@@ -8,8 +8,8 @@
8
8
  import type { BinaryTreeNodeId, BinaryTreeNodeNested, BinaryTreeOptions } from '../../types';
9
9
  import { AbstractBinaryTree, AbstractBinaryTreeNode } from './abstract-binary-tree';
10
10
  import { IBinaryTree, IBinaryTreeNode } from '../../interfaces';
11
- export declare class BinaryTreeNode<T = any, NEIGHBOR extends BinaryTreeNode<T, NEIGHBOR> = BinaryTreeNodeNested<T>> extends AbstractBinaryTreeNode<T, NEIGHBOR> implements IBinaryTreeNode<T, NEIGHBOR> {
12
- constructor(id: BinaryTreeNodeId, val?: T);
11
+ export declare class BinaryTreeNode<V = any, NEIGHBOR extends BinaryTreeNode<V, NEIGHBOR> = BinaryTreeNodeNested<V>> extends AbstractBinaryTreeNode<V, NEIGHBOR> implements IBinaryTreeNode<V, NEIGHBOR> {
12
+ constructor(id: BinaryTreeNodeId, val?: V);
13
13
  }
14
14
  export declare class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode> extends AbstractBinaryTree<N> implements IBinaryTree<N> {
15
15
  /**
@@ -9,8 +9,8 @@ import type { BinaryTreeNodeId, BinaryTreeNodePropertyName, BSTComparator, BSTNo
9
9
  import { CP } from '../../types';
10
10
  import { BinaryTree, BinaryTreeNode } from './binary-tree';
11
11
  import { IBST, IBSTNode } from '../../interfaces';
12
- export declare class BSTNode<T = any, NEIGHBOR extends BSTNode<T, NEIGHBOR> = BSTNodeNested<T>> extends BinaryTreeNode<T, NEIGHBOR> implements IBSTNode<T, NEIGHBOR> {
13
- constructor(id: BinaryTreeNodeId, val?: T);
12
+ export declare class BSTNode<V = any, NEIGHBOR extends BSTNode<V, NEIGHBOR> = BSTNodeNested<V>> extends BinaryTreeNode<V, NEIGHBOR> implements IBSTNode<V, NEIGHBOR> {
13
+ constructor(id: BinaryTreeNodeId, val?: V);
14
14
  }
15
15
  export declare class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N> implements IBST<N> {
16
16
  /**
@@ -1,9 +1,9 @@
1
1
  import { BinaryTreeNodeId, RBColor, RBTreeNodeNested, RBTreeOptions } from '../../types';
2
- import { IRBTree, IRBTreeNode } from '../../interfaces/rb-tree';
2
+ import { IRBTree, IRBTreeNode } from '../../interfaces';
3
3
  import { BST, BSTNode } from './bst';
4
- export declare class RBTreeNode<T = any, NEIGHBOR extends RBTreeNode<T, NEIGHBOR> = RBTreeNodeNested<T>> extends BSTNode<T, NEIGHBOR> implements IRBTreeNode<T, NEIGHBOR> {
5
- constructor(id: BinaryTreeNodeId, val?: T, color?: RBColor);
4
+ export declare class RBTreeNode<V = any, NEIGHBOR extends RBTreeNode<V, NEIGHBOR> = RBTreeNodeNested<V>> extends BSTNode<V, NEIGHBOR> implements IRBTreeNode<V, NEIGHBOR> {
6
5
  private _color;
6
+ constructor(id: BinaryTreeNodeId, val?: V);
7
7
  get color(): RBColor;
8
8
  set color(value: RBColor);
9
9
  }
@@ -1,9 +1,9 @@
1
1
  import { RBColor } from '../../types';
2
2
  import { BST, BSTNode } from './bst';
3
3
  export class RBTreeNode extends BSTNode {
4
- constructor(id, val, color = RBColor.RED) {
4
+ constructor(id, val) {
5
5
  super(id, val);
6
- this._color = color;
6
+ this._color = RBColor.RED;
7
7
  }
8
8
  get color() {
9
9
  return this._color;
@@ -17,6 +17,6 @@ export class RBTree extends BST {
17
17
  super(options);
18
18
  }
19
19
  createNode(id, val) {
20
- return new RBTreeNode(id, val, RBColor.RED);
20
+ return new RBTreeNode(id, val);
21
21
  }
22
22
  }
@@ -9,18 +9,18 @@ import type { BinaryTreeNodeId, TreeMultisetNodeNested, TreeMultisetOptions } fr
9
9
  import { BinaryTreeDeletedResult, DFSOrderPattern } from '../../types';
10
10
  import { ITreeMultiset, ITreeMultisetNode } from '../../interfaces';
11
11
  import { AVLTree, AVLTreeNode } from './avl-tree';
12
- export declare class TreeMultisetNode<T = any, NEIGHBOR extends TreeMultisetNode<T, NEIGHBOR> = TreeMultisetNodeNested<T>> extends AVLTreeNode<T, NEIGHBOR> implements ITreeMultisetNode<T, NEIGHBOR> {
12
+ export declare class TreeMultisetNode<V = any, NEIGHBOR extends TreeMultisetNode<V, NEIGHBOR> = TreeMultisetNodeNested<V>> extends AVLTreeNode<V, NEIGHBOR> implements ITreeMultisetNode<V, NEIGHBOR> {
13
13
  /**
14
14
  * The constructor function initializes a BinaryTreeNode object with an id, value, and count.
15
15
  * @param {BinaryTreeNodeId} id - The `id` parameter is of type `BinaryTreeNodeId` and represents the unique identifier
16
16
  * of the binary tree node.
17
- * @param {T} [val] - The `val` parameter is an optional parameter of type `T`. It represents the value of the binary
17
+ * @param {V} [val] - The `val` parameter is an optional parameter of type `V`. It represents the value of the binary
18
18
  * tree node. If no value is provided, it will be `undefined`.
19
19
  * @param {number} [count=1] - The `count` parameter is a number that represents the number of times a particular value
20
20
  * occurs in a binary tree node. It has a default value of 1, which means that if no value is provided for the `count`
21
21
  * parameter when creating a new instance of the `BinaryTreeNode` class,
22
22
  */
23
- constructor(id: BinaryTreeNodeId, val?: T, count?: number);
23
+ constructor(id: BinaryTreeNodeId, val?: V, count?: number);
24
24
  private _count;
25
25
  get count(): number;
26
26
  set count(v: number);
@@ -5,7 +5,7 @@ export class TreeMultisetNode extends AVLTreeNode {
5
5
  * The constructor function initializes a BinaryTreeNode object with an id, value, and count.
6
6
  * @param {BinaryTreeNodeId} id - The `id` parameter is of type `BinaryTreeNodeId` and represents the unique identifier
7
7
  * of the binary tree node.
8
- * @param {T} [val] - The `val` parameter is an optional parameter of type `T`. It represents the value of the binary
8
+ * @param {V} [val] - The `val` parameter is an optional parameter of type `V`. It represents the value of the binary
9
9
  * tree node. If no value is provided, it will be `undefined`.
10
10
  * @param {number} [count=1] - The `count` parameter is a number that represents the number of times a particular value
11
11
  * occurs in a binary tree node. It has a default value of 1, which means that if no value is provided for the `count`
@@ -1,35 +1,35 @@
1
1
  import type { DijkstraResult, VertexId } from '../../types';
2
2
  import { IAbstractGraph } from '../../interfaces';
3
- export declare abstract class AbstractVertex<T = any> {
3
+ export declare abstract class AbstractVertex<V = any> {
4
4
  /**
5
5
  * The function is a protected constructor that takes an id and an optional value as parameters.
6
6
  * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex. It is
7
7
  * used to uniquely identify the vertex object.
8
- * @param {T} [val] - The parameter "val" is an optional parameter of type T. It is used to assign a value to the
8
+ * @param {V} [val] - The parameter "val" is an optional parameter of type V. It is used to assign a value to the
9
9
  * vertex. If no value is provided, it will be set to undefined.
10
10
  */
11
- protected constructor(id: VertexId, val?: T);
11
+ protected constructor(id: VertexId, val?: V);
12
12
  private _id;
13
13
  get id(): VertexId;
14
14
  set id(v: VertexId);
15
15
  private _val;
16
- get val(): T | undefined;
17
- set val(value: T | undefined);
16
+ get val(): V | undefined;
17
+ set val(value: V | undefined);
18
18
  }
19
- export declare abstract class AbstractEdge<T = any> {
19
+ export declare abstract class AbstractEdge<V = any> {
20
20
  /**
21
21
  * The above function is a protected constructor that initializes the weight, value, and hash code properties of an
22
22
  * object.
23
23
  * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the object. If
24
24
  * a value is provided, it will be assigned to the `_weight` property. If no value is provided, the default value of 1
25
25
  * will be assigned.
26
- * @param {T} [val] - The `val` parameter is of type `T`, which means it can be any type. It is an optional parameter,
26
+ * @param {V} [val] - The `val` parameter is of type `V`, which means it can be any type. It is an optional parameter,
27
27
  * meaning it can be omitted when creating an instance of the class.
28
28
  */
29
- protected constructor(weight?: number, val?: T);
29
+ protected constructor(weight?: number, val?: V);
30
30
  private _val;
31
- get val(): T | undefined;
32
- set val(value: T | undefined);
31
+ get val(): V | undefined;
32
+ set val(value: V | undefined);
33
33
  private _weight;
34
34
  get weight(): number;
35
35
  set weight(v: number);
@@ -12,7 +12,7 @@ export class AbstractVertex {
12
12
  * The function is a protected constructor that takes an id and an optional value as parameters.
13
13
  * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex. It is
14
14
  * used to uniquely identify the vertex object.
15
- * @param {T} [val] - The parameter "val" is an optional parameter of type T. It is used to assign a value to the
15
+ * @param {V} [val] - The parameter "val" is an optional parameter of type V. It is used to assign a value to the
16
16
  * vertex. If no value is provided, it will be set to undefined.
17
17
  */
18
18
  constructor(id, val) {
@@ -39,7 +39,7 @@ export class AbstractEdge {
39
39
  * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the object. If
40
40
  * a value is provided, it will be assigned to the `_weight` property. If no value is provided, the default value of 1
41
41
  * will be assigned.
42
- * @param {T} [val] - The `val` parameter is of type `T`, which means it can be any type. It is an optional parameter,
42
+ * @param {V} [val] - The `val` parameter is of type `V`, which means it can be any type. It is an optional parameter,
43
43
  * meaning it can be omitted when creating an instance of the class.
44
44
  */
45
45
  constructor(weight, val) {
@@ -1,17 +1,17 @@
1
1
  import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
2
2
  import type { VertexId } from '../../types';
3
3
  import { IDirectedGraph } from '../../interfaces';
4
- export declare class DirectedVertex<T = number> extends AbstractVertex<T> {
4
+ export declare class DirectedVertex<V = any> extends AbstractVertex<V> {
5
5
  /**
6
6
  * The constructor function initializes a vertex with an optional value.
7
7
  * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex. It is
8
8
  * used to uniquely identify the vertex within a graph or data structure.
9
- * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to initialize the value of the
9
+ * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
10
10
  * vertex. If no value is provided, the vertex will be initialized with a default value.
11
11
  */
12
- constructor(id: VertexId, val?: T);
12
+ constructor(id: VertexId, val?: V);
13
13
  }
14
- export declare class DirectedEdge<T = number> extends AbstractEdge<T> {
14
+ export declare class DirectedEdge<V = any> extends AbstractEdge<V> {
15
15
  /**
16
16
  * The constructor function initializes the source and destination vertices of an edge, along with an optional weight
17
17
  * and value.
@@ -20,10 +20,10 @@ export declare class DirectedEdge<T = number> extends AbstractEdge<T> {
20
20
  * @param {VertexId} dest - The `dest` parameter represents the destination vertex of an edge. It is of type
21
21
  * `VertexId`, which is likely a unique identifier for a vertex in a graph.
22
22
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
23
- * @param {T} [val] - The `val` parameter is an optional parameter of type `T`. It represents the value associated with
23
+ * @param {V} [val] - The `val` parameter is an optional parameter of type `V`. It represents the value associated with
24
24
  * the edge.
25
25
  */
26
- constructor(src: VertexId, dest: VertexId, weight?: number, val?: T);
26
+ constructor(src: VertexId, dest: VertexId, weight?: number, val?: V);
27
27
  private _src;
28
28
  get src(): VertexId;
29
29
  set src(v: VertexId);
@@ -12,7 +12,7 @@ export class DirectedVertex extends AbstractVertex {
12
12
  * The constructor function initializes a vertex with an optional value.
13
13
  * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex. It is
14
14
  * used to uniquely identify the vertex within a graph or data structure.
15
- * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to initialize the value of the
15
+ * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
16
16
  * vertex. If no value is provided, the vertex will be initialized with a default value.
17
17
  */
18
18
  constructor(id, val) {
@@ -28,7 +28,7 @@ export class DirectedEdge extends AbstractEdge {
28
28
  * @param {VertexId} dest - The `dest` parameter represents the destination vertex of an edge. It is of type
29
29
  * `VertexId`, which is likely a unique identifier for a vertex in a graph.
30
30
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
31
- * @param {T} [val] - The `val` parameter is an optional parameter of type `T`. It represents the value associated with
31
+ * @param {V} [val] - The `val` parameter is an optional parameter of type `V`. It represents the value associated with
32
32
  * the edge.
33
33
  */
34
34
  constructor(src, dest, weight, val) {
@@ -1,6 +1,6 @@
1
1
  import { MapGraphCoordinate, VertexId } from '../../types';
2
2
  import { DirectedEdge, DirectedGraph, DirectedVertex } from './directed-graph';
3
- export declare class MapVertex<T = any> extends DirectedVertex<T> {
3
+ export declare class MapVertex<V = any> extends DirectedVertex<V> {
4
4
  /**
5
5
  * The constructor function initializes an object with an id, latitude, longitude, and an optional value.
6
6
  * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex.
@@ -10,10 +10,10 @@ export declare class MapVertex<T = any> extends DirectedVertex<T> {
10
10
  * @param {number} long - The "long" parameter represents the longitude of a location. Longitude is a geographic
11
11
  * coordinate that specifies the east-west position of a point on the Earth's surface. It is measured in degrees, with
12
12
  * values ranging from -180 to 180.
13
- * @param {T} [val] - The "val" parameter is an optional value of type T. It is not required to be provided when
13
+ * @param {V} [val] - The "val" parameter is an optional value of type V. It is not required to be provided when
14
14
  * creating an instance of the class.
15
15
  */
16
- constructor(id: VertexId, lat: number, long: number, val?: T);
16
+ constructor(id: VertexId, lat: number, long: number, val?: V);
17
17
  private _lat;
18
18
  get lat(): number;
19
19
  set lat(value: number);
@@ -21,7 +21,7 @@ export declare class MapVertex<T = any> extends DirectedVertex<T> {
21
21
  get long(): number;
22
22
  set long(value: number);
23
23
  }
24
- export declare class MapEdge<T = any> extends DirectedEdge<T> {
24
+ export declare class MapEdge<V = any> extends DirectedEdge<V> {
25
25
  /**
26
26
  * The constructor function initializes a new instance of a class with the given source, destination, weight, and
27
27
  * value.
@@ -29,10 +29,10 @@ export declare class MapEdge<T = any> extends DirectedEdge<T> {
29
29
  * a graph.
30
30
  * @param {VertexId} dest - The `dest` parameter is the identifier of the destination vertex for an edge.
31
31
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
32
- * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to store additional
32
+ * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store additional
33
33
  * information or data associated with the edge.
34
34
  */
35
- constructor(src: VertexId, dest: VertexId, weight?: number, val?: T);
35
+ constructor(src: VertexId, dest: VertexId, weight?: number, val?: V);
36
36
  }
37
37
  export declare class MapGraph<V extends MapVertex<V['val']> = MapVertex, E extends MapEdge = MapEdge> extends DirectedGraph<V, E> {
38
38
  /**
@@ -9,7 +9,7 @@ export class MapVertex extends DirectedVertex {
9
9
  * @param {number} long - The "long" parameter represents the longitude of a location. Longitude is a geographic
10
10
  * coordinate that specifies the east-west position of a point on the Earth's surface. It is measured in degrees, with
11
11
  * values ranging from -180 to 180.
12
- * @param {T} [val] - The "val" parameter is an optional value of type T. It is not required to be provided when
12
+ * @param {V} [val] - The "val" parameter is an optional value of type V. It is not required to be provided when
13
13
  * creating an instance of the class.
14
14
  */
15
15
  constructor(id, lat, long, val) {
@@ -38,7 +38,7 @@ export class MapEdge extends DirectedEdge {
38
38
  * a graph.
39
39
  * @param {VertexId} dest - The `dest` parameter is the identifier of the destination vertex for an edge.
40
40
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
41
- * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to store additional
41
+ * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store additional
42
42
  * information or data associated with the edge.
43
43
  */
44
44
  constructor(src, dest, weight, val) {
@@ -1,17 +1,17 @@
1
1
  import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
2
2
  import type { VertexId } from '../../types';
3
3
  import { IUNDirectedGraph } from '../../interfaces';
4
- export declare class UndirectedVertex<T = number> extends AbstractVertex<T> {
4
+ export declare class UndirectedVertex<V = any> extends AbstractVertex<V> {
5
5
  /**
6
6
  * The constructor function initializes a vertex with an optional value.
7
7
  * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex. It is
8
8
  * used to uniquely identify the vertex within a graph or network.
9
- * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to initialize the value of the
9
+ * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
10
10
  * vertex. If no value is provided, the vertex will be initialized with a default value.
11
11
  */
12
- constructor(id: VertexId, val?: T);
12
+ constructor(id: VertexId, val?: V);
13
13
  }
14
- export declare class UndirectedEdge<T = number> extends AbstractEdge<T> {
14
+ export declare class UndirectedEdge<V = number> extends AbstractEdge<V> {
15
15
  /**
16
16
  * The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional
17
17
  * value.
@@ -19,10 +19,10 @@ export declare class UndirectedEdge<T = number> extends AbstractEdge<T> {
19
19
  * @param {VertexId} v2 - The parameter `v2` is a `VertexId`, which represents the identifier of the second vertex in a
20
20
  * graph edge.
21
21
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
22
- * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to store a value associated
22
+ * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store a value associated
23
23
  * with the edge.
24
24
  */
25
- constructor(v1: VertexId, v2: VertexId, weight?: number, val?: T);
25
+ constructor(v1: VertexId, v2: VertexId, weight?: number, val?: V);
26
26
  private _vertices;
27
27
  get vertices(): [VertexId, VertexId];
28
28
  set vertices(v: [VertexId, VertexId]);
@@ -12,7 +12,7 @@ export class UndirectedVertex extends AbstractVertex {
12
12
  * The constructor function initializes a vertex with an optional value.
13
13
  * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex. It is
14
14
  * used to uniquely identify the vertex within a graph or network.
15
- * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to initialize the value of the
15
+ * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
16
16
  * vertex. If no value is provided, the vertex will be initialized with a default value.
17
17
  */
18
18
  constructor(id, val) {
@@ -27,7 +27,7 @@ export class UndirectedEdge extends AbstractEdge {
27
27
  * @param {VertexId} v2 - The parameter `v2` is a `VertexId`, which represents the identifier of the second vertex in a
28
28
  * graph edge.
29
29
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
30
- * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to store a value associated
30
+ * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store a value associated
31
31
  * with the edge.
32
32
  */
33
33
  constructor(v1, v2, weight, val) {
@@ -1,2 +1,62 @@
1
- export declare class HashTable {
1
+ /**
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
7
+ */
8
+ export declare class HashNode<K, V> {
9
+ key: K;
10
+ val: V;
11
+ next: HashNode<K, V> | null;
12
+ constructor(key: K, val: V);
13
+ }
14
+ export declare class HashTable<K, V> {
15
+ get buckets(): Array<HashNode<K, V> | null>;
16
+ set buckets(value: Array<HashNode<K, V> | null>);
17
+ get size(): number;
18
+ set size(value: number);
19
+ get capacity(): number;
20
+ set capacity(value: number);
21
+ private _capacity;
22
+ private _size;
23
+ private _buckets;
24
+ /**
25
+ * The constructor initializes the capacity, size, and buckets of an object.
26
+ * @param [capacity=1000] - The `capacity` parameter represents the maximum number of elements that the data structure
27
+ * can hold. It is an optional parameter with a default value of 1000.
28
+ */
29
+ constructor(capacity?: number);
30
+ /**
31
+ * The hash function takes a key, converts it to a string, calculates the sum of the ASCII values of its characters, and
32
+ * returns the remainder when divided by the capacity of the data structure.
33
+ * @param {K} key - The `key` parameter represents the key that needs to be hashed. It is of type `K`, which means it can
34
+ * be any data type that can be converted to a string.
35
+ * @returns The hash value of the key modulo the capacity of the data structure.
36
+ */
37
+ private hash;
38
+ /**
39
+ * The put function adds a key-value pair to a hash table, handling collisions by chaining.
40
+ * @param {K} key - The key parameter represents the key of the key-value pair that you want to insert into the hash
41
+ * table. It is of type K, which can be any data type that can be used as a key, such as a string, number, or object.
42
+ * @param {V} val - The `val` parameter represents the value associated with the key in the hash table.
43
+ * @returns Nothing is being returned. The return type of the function is void, which means it does not return any value.
44
+ */
45
+ put(key: K, val: V): void;
46
+ /**
47
+ * The `get` function retrieves the value associated with a given key from a hash table.
48
+ * @param {K} key - The parameter "key" represents the key of the element that we want to retrieve from the data
49
+ * structure.
50
+ * @returns The method is returning the value associated with the given key if it exists in the hash table. If the key is
51
+ * not found, it returns `undefined`.
52
+ */
53
+ get(key: K): V | undefined;
54
+ /**
55
+ * The `remove` function removes a key-value pair from a hash table.
56
+ * @param {K} key - The `key` parameter represents the key of the key-value pair that needs to be removed from the hash
57
+ * table.
58
+ * @returns Nothing is being returned. The `remove` method has a return type of `void`, which means it does not return
59
+ * any value.
60
+ */
61
+ remove(key: K): void;
2
62
  }