data-structure-typed 1.48.4 → 1.48.6

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 (97) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +109 -59
  3. package/README_zh-CN.md +1028 -0
  4. package/benchmark/report.html +16 -16
  5. package/benchmark/report.json +204 -174
  6. package/dist/cjs/data-structures/base/iterable-base.d.ts +6 -6
  7. package/dist/cjs/data-structures/base/iterable-base.js +3 -3
  8. package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
  9. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +5 -3
  10. package/dist/cjs/data-structures/binary-tree/avl-tree.js +6 -4
  11. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  12. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +24 -22
  13. package/dist/cjs/data-structures/binary-tree/binary-tree.js +35 -22
  14. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  15. package/dist/cjs/data-structures/binary-tree/bst.d.ts +30 -22
  16. package/dist/cjs/data-structures/binary-tree/bst.js +38 -26
  17. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  18. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +19 -13
  19. package/dist/cjs/data-structures/binary-tree/rb-tree.js +20 -14
  20. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  21. package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +21 -14
  22. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +25 -18
  23. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  24. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +52 -52
  25. package/dist/cjs/data-structures/graph/abstract-graph.js +78 -78
  26. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  27. package/dist/cjs/data-structures/graph/directed-graph.d.ts +47 -47
  28. package/dist/cjs/data-structures/graph/directed-graph.js +56 -56
  29. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  30. package/dist/cjs/data-structures/graph/map-graph.d.ts +5 -5
  31. package/dist/cjs/data-structures/graph/map-graph.js +8 -8
  32. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  33. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +29 -29
  34. package/dist/cjs/data-structures/graph/undirected-graph.js +57 -57
  35. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  36. package/dist/cjs/data-structures/hash/hash-map.d.ts +8 -8
  37. package/dist/cjs/data-structures/hash/hash-map.js +2 -2
  38. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  39. package/dist/cjs/interfaces/binary-tree.d.ts +2 -2
  40. package/dist/cjs/types/data-structures/base/base.d.ts +3 -3
  41. package/dist/mjs/data-structures/base/iterable-base.d.ts +6 -6
  42. package/dist/mjs/data-structures/base/iterable-base.js +1 -1
  43. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +5 -3
  44. package/dist/mjs/data-structures/binary-tree/avl-tree.js +6 -4
  45. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +24 -22
  46. package/dist/mjs/data-structures/binary-tree/binary-tree.js +36 -23
  47. package/dist/mjs/data-structures/binary-tree/bst.d.ts +30 -22
  48. package/dist/mjs/data-structures/binary-tree/bst.js +38 -26
  49. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +19 -13
  50. package/dist/mjs/data-structures/binary-tree/rb-tree.js +20 -14
  51. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +21 -14
  52. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +25 -18
  53. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +52 -52
  54. package/dist/mjs/data-structures/graph/abstract-graph.js +79 -79
  55. package/dist/mjs/data-structures/graph/directed-graph.d.ts +47 -47
  56. package/dist/mjs/data-structures/graph/directed-graph.js +56 -56
  57. package/dist/mjs/data-structures/graph/map-graph.d.ts +5 -5
  58. package/dist/mjs/data-structures/graph/map-graph.js +8 -8
  59. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +29 -29
  60. package/dist/mjs/data-structures/graph/undirected-graph.js +59 -59
  61. package/dist/mjs/data-structures/hash/hash-map.d.ts +8 -8
  62. package/dist/mjs/data-structures/hash/hash-map.js +3 -3
  63. package/dist/mjs/interfaces/binary-tree.d.ts +2 -2
  64. package/dist/mjs/types/data-structures/base/base.d.ts +3 -3
  65. package/dist/umd/data-structure-typed.js +336 -295
  66. package/dist/umd/data-structure-typed.min.js +2 -2
  67. package/dist/umd/data-structure-typed.min.js.map +1 -1
  68. package/package.json +2 -2
  69. package/src/data-structures/base/iterable-base.ts +6 -6
  70. package/src/data-structures/binary-tree/avl-tree.ts +7 -4
  71. package/src/data-structures/binary-tree/binary-tree.ts +47 -27
  72. package/src/data-structures/binary-tree/bst.ts +52 -32
  73. package/src/data-structures/binary-tree/rb-tree.ts +20 -14
  74. package/src/data-structures/binary-tree/tree-multimap.ts +26 -18
  75. package/src/data-structures/graph/abstract-graph.ts +82 -82
  76. package/src/data-structures/graph/directed-graph.ts +56 -56
  77. package/src/data-structures/graph/map-graph.ts +8 -8
  78. package/src/data-structures/graph/undirected-graph.ts +59 -59
  79. package/src/data-structures/hash/hash-map.ts +8 -8
  80. package/src/interfaces/binary-tree.ts +2 -2
  81. package/src/types/data-structures/base/base.ts +3 -3
  82. package/test/integration/bst.test.ts +1 -1
  83. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +1 -1
  84. package/test/performance/data-structures/hash/hash-map.test.ts +8 -8
  85. package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +2 -2
  86. package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +12 -1
  87. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +1 -1
  88. package/test/performance/data-structures/queue/deque.test.ts +27 -15
  89. package/test/performance/data-structures/queue/queue.test.ts +27 -4
  90. package/test/performance/data-structures/stack/stack.test.ts +2 -2
  91. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +1 -1
  92. package/test/unit/data-structures/binary-tree/bst.test.ts +29 -29
  93. package/test/unit/data-structures/binary-tree/overall.test.ts +1 -1
  94. package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +3 -3
  95. package/test/unit/data-structures/graph/directed-graph.test.ts +15 -15
  96. package/test/unit/data-structures/graph/map-graph.test.ts +3 -3
  97. package/test/unit/data-structures/graph/undirected-graph.test.ts +12 -12
@@ -128,7 +128,7 @@ var dataStructureTyped = (() => {
128
128
  HashTableNode: () => HashTableNode,
129
129
  Heap: () => Heap,
130
130
  IterableElementBase: () => IterableElementBase,
131
- IterablePairBase: () => IterablePairBase,
131
+ IterableEntryBase: () => IterableEntryBase,
132
132
  IterationType: () => IterationType,
133
133
  LinkedHashMap: () => LinkedHashMap,
134
134
  LinkedListQueue: () => LinkedListQueue,
@@ -520,7 +520,7 @@ var dataStructureTyped = (() => {
520
520
  var calcMinUnitsRequired = (totalQuantity, unitSize) => Math.floor((totalQuantity + unitSize - 1) / unitSize);
521
521
 
522
522
  // src/data-structures/base/iterable-base.ts
523
- var IterablePairBase = class {
523
+ var IterableEntryBase = class {
524
524
  /**
525
525
  * Time Complexity: O(n)
526
526
  * Space Complexity: O(1)
@@ -829,7 +829,7 @@ var dataStructureTyped = (() => {
829
829
  };
830
830
 
831
831
  // src/data-structures/hash/hash-map.ts
832
- var HashMap = class _HashMap extends IterablePairBase {
832
+ var HashMap = class _HashMap extends IterableEntryBase {
833
833
  /**
834
834
  * The constructor function initializes a new instance of a class with optional elements and options.
835
835
  * @param elements - The `elements` parameter is an iterable containing key-value pairs `[K, V]`. It
@@ -1041,7 +1041,7 @@ var dataStructureTyped = (() => {
1041
1041
  return strKey;
1042
1042
  }
1043
1043
  };
1044
- var LinkedHashMap = class _LinkedHashMap extends IterablePairBase {
1044
+ var LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
1045
1045
  constructor(elements, options = {
1046
1046
  hashFn: (key) => String(key),
1047
1047
  objHashFn: (key) => key
@@ -5420,13 +5420,13 @@ var dataStructureTyped = (() => {
5420
5420
  * 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.
5421
5421
  */
5422
5422
  };
5423
- var AbstractGraph = class extends IterablePairBase {
5423
+ var AbstractGraph = class extends IterableEntryBase {
5424
5424
  constructor() {
5425
5425
  super();
5426
- __publicField(this, "_vertices", /* @__PURE__ */ new Map());
5426
+ __publicField(this, "_vertexMap", /* @__PURE__ */ new Map());
5427
5427
  }
5428
- get vertices() {
5429
- return this._vertices;
5428
+ get vertexMap() {
5429
+ return this._vertexMap;
5430
5430
  }
5431
5431
  /**
5432
5432
  * Time Complexity: O(1) - Constant time for Map lookup.
@@ -5438,12 +5438,12 @@ var dataStructureTyped = (() => {
5438
5438
  *
5439
5439
  * The function "getVertex" returns the vertex with the specified ID or undefined if it doesn't exist.
5440
5440
  * @param {VertexKey} vertexKey - The `vertexKey` parameter is the identifier of the vertex that you want to retrieve from
5441
- * the `_vertices` map.
5442
- * @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertices`
5441
+ * the `_vertexMap` map.
5442
+ * @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertexMap`
5443
5443
  * map. If the vertex does not exist, it returns `undefined`.
5444
5444
  */
5445
5445
  getVertex(vertexKey) {
5446
- return this._vertices.get(vertexKey) || void 0;
5446
+ return this._vertexMap.get(vertexKey) || void 0;
5447
5447
  }
5448
5448
  /**
5449
5449
  * Time Complexity: O(1) - Constant time for Map lookup.
@@ -5459,7 +5459,7 @@ var dataStructureTyped = (() => {
5459
5459
  * @returns a boolean value.
5460
5460
  */
5461
5461
  hasVertex(vertexOrKey) {
5462
- return this._vertices.has(this._getVertexKey(vertexOrKey));
5462
+ return this._vertexMap.has(this._getVertexKey(vertexOrKey));
5463
5463
  }
5464
5464
  /**
5465
5465
  * Time Complexity: O(1) - Constant time for Map operations.
@@ -5492,25 +5492,25 @@ var dataStructureTyped = (() => {
5492
5492
  */
5493
5493
  deleteVertex(vertexOrKey) {
5494
5494
  const vertexKey = this._getVertexKey(vertexOrKey);
5495
- return this._vertices.delete(vertexKey);
5495
+ return this._vertexMap.delete(vertexKey);
5496
5496
  }
5497
5497
  /**
5498
- * Time Complexity: O(K), where K is the number of vertices to be removed.
5498
+ * Time Complexity: O(K), where K is the number of vertexMap to be removed.
5499
5499
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
5500
5500
  */
5501
5501
  /**
5502
- * Time Complexity: O(K), where K is the number of vertices to be removed.
5502
+ * Time Complexity: O(K), where K is the number of vertexMap to be removed.
5503
5503
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
5504
5504
  *
5505
- * The function removes all vertices from a graph and returns a boolean indicating if any vertices were removed.
5506
- * @param {VO[] | VertexKey[]} vertices - The `vertices` parameter can be either an array of vertices (`VO[]`) or an array
5505
+ * The function removes all vertexMap from a graph and returns a boolean indicating if any vertexMap were removed.
5506
+ * @param {VO[] | VertexKey[]} vertexMap - The `vertexMap` parameter can be either an array of vertexMap (`VO[]`) or an array
5507
5507
  * of vertex IDs (`VertexKey[]`).
5508
- * @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertices
5508
+ * @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertexMap
5509
5509
  * were removed.
5510
5510
  */
5511
- removeManyVertices(vertices) {
5511
+ removeManyVertices(vertexMap) {
5512
5512
  const removed = [];
5513
- for (const v of vertices) {
5513
+ for (const v of vertexMap) {
5514
5514
  removed.push(this.deleteVertex(v));
5515
5515
  }
5516
5516
  return removed.length > 0;
@@ -5523,7 +5523,7 @@ var dataStructureTyped = (() => {
5523
5523
  * Time Complexity: O(1) - Depends on the implementation in the concrete class.
5524
5524
  * Space Complexity: O(1) - Depends on the implementation in the concrete class.
5525
5525
  *
5526
- * The function checks if there is an edge between two vertices and returns a boolean value indicating the result.
5526
+ * The function checks if there is an edge between two vertexMap and returns a boolean value indicating the result.
5527
5527
  * @param {VertexKey | VO} v1 - The parameter v1 can be either a VertexKey or a VO. A VertexKey represents the unique
5528
5528
  * identifier of a vertex in a graph, while VO represents the type of the vertex object itself.
5529
5529
  * @param {VertexKey | VO} v2 - The parameter `v2` represents the second vertex in the edge. It can be either a
@@ -5564,14 +5564,14 @@ var dataStructureTyped = (() => {
5564
5564
  * Time Complexity: O(1) - Constant time for Map and Edge operations.
5565
5565
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
5566
5566
  *
5567
- * The function sets the weight of an edge between two vertices in a graph.
5567
+ * The function sets the weight of an edge between two vertexMap in a graph.
5568
5568
  * @param {VertexKey | VO} srcOrKey - The `srcOrKey` parameter can be either a `VertexKey` or a `VO` object. It represents
5569
5569
  * the source vertex of the edge.
5570
5570
  * @param {VertexKey | VO} destOrKey - The `destOrKey` parameter represents the destination vertex of the edge. It can be
5571
5571
  * either a `VertexKey` or a vertex object `VO`.
5572
5572
  * @param {number} weight - The weight parameter represents the weight of the edge between the source vertex (srcOrKey)
5573
5573
  * and the destination vertex (destOrKey).
5574
- * @returns a boolean value. If the edge exists between the source and destination vertices, the function will update
5574
+ * @returns a boolean value. If the edge exists between the source and destination vertexMap, the function will update
5575
5575
  * the weight of the edge and return true. If the edge does not exist, the function will return false.
5576
5576
  */
5577
5577
  setEdgeWeight(srcOrKey, destOrKey, weight) {
@@ -5591,12 +5591,12 @@ var dataStructureTyped = (() => {
5591
5591
  * Time Complexity: O(P), where P is the number of paths found (in the worst case, exploring all paths).
5592
5592
  * Space Complexity: O(P) - Linear space, where P is the number of paths found.
5593
5593
  *
5594
- * The function `getAllPathsBetween` finds all paths between two vertices in a graph using depth-first search.
5594
+ * The function `getAllPathsBetween` finds all paths between two vertexMap in a graph using depth-first search.
5595
5595
  * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
5596
5596
  * It is the starting vertex for finding paths.
5597
5597
  * @param {VO | VertexKey} v2 - The parameter `v2` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
5598
5598
  * @param limit - The count of limitation of result array.
5599
- * @returns The function `getAllPathsBetween` returns an array of arrays of vertices (`VO[][]`).
5599
+ * @returns The function `getAllPathsBetween` returns an array of arrays of vertexMap (`VO[][]`).
5600
5600
  */
5601
5601
  getAllPathsBetween(v1, v2, limit = 1e3) {
5602
5602
  const paths = [];
@@ -5633,8 +5633,8 @@ var dataStructureTyped = (() => {
5633
5633
  * Space Complexity: O(1) - Constant space.
5634
5634
  *
5635
5635
  * The function calculates the sum of weights along a given path.
5636
- * @param {VO[]} path - An array of vertices (VO) representing a path in a graph.
5637
- * @returns The function `getPathSumWeight` returns the sum of the weights of the edges in the given path.
5636
+ * @param {VO[]} path - An array of vertexMap (VO) representing a path in a graph.
5637
+ * @returns The function `getPathSumWeight` returns the sum of the weights of the edgeMap in the given path.
5638
5638
  */
5639
5639
  getPathSumWeight(path) {
5640
5640
  var _a;
@@ -5652,17 +5652,17 @@ var dataStructureTyped = (() => {
5652
5652
  * Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
5653
5653
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
5654
5654
  *
5655
- * The function `getMinCostBetween` calculates the minimum cost between two vertices in a graph, either based on edge
5655
+ * The function `getMinCostBetween` calculates the minimum cost between two vertexMap in a graph, either based on edge
5656
5656
  * weights or using a breadth-first search algorithm.
5657
5657
  * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex or its ID.
5658
5658
  * @param {VO | VertexKey} v2 - The parameter `v2` represents the destination vertex or its ID. It is the vertex to which
5659
5659
  * you want to find the minimum cost or weight from the source vertex `v1`.
5660
- * @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edges have weights.
5660
+ * @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edgeMap have weights.
5661
5661
  * If isWeight is set to true, the function will calculate the minimum cost between v1 and v2 based on the weights of
5662
- * the edges. If isWeight is set to false or not provided, the function will calculate the
5663
- * @returns The function `getMinCostBetween` returns a number representing the minimum cost between two vertices (`v1`
5662
+ * the edgeMap. If isWeight is set to false or not provided, the function will calculate the
5663
+ * @returns The function `getMinCostBetween` returns a number representing the minimum cost between two vertexMap (`v1`
5664
5664
  * and `v2`). If the `isWeight` parameter is `true`, it calculates the minimum weight among all paths between the
5665
- * vertices. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
5665
+ * vertexMap. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
5666
5666
  * minimum number of
5667
5667
  */
5668
5668
  getMinCostBetween(v1, v2, isWeight) {
@@ -5714,20 +5714,20 @@ var dataStructureTyped = (() => {
5714
5714
  * Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
5715
5715
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
5716
5716
  *
5717
- * The function `getMinPathBetween` returns the minimum path between two vertices in a graph, either based on weight or
5717
+ * The function `getMinPathBetween` returns the minimum path between two vertexMap in a graph, either based on weight or
5718
5718
  * using a breadth-first search algorithm.
5719
5719
  * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex of the path. It can be either a vertex
5720
5720
  * object (`VO`) or a vertex ID (`VertexKey`).
5721
5721
  * @param {VO | VertexKey} v2 - VO | VertexKey - The second vertex or vertex ID between which we want to find the minimum
5722
5722
  * path.
5723
- * @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edges in finding the
5723
+ * @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edgeMap in finding the
5724
5724
  * minimum path. If set to true, the function will use Dijkstra's algorithm to find the minimum weighted path. If set
5725
5725
  * to false, the function will use breadth-first search (BFS) to find the minimum path.
5726
5726
  * @param isDFS - If set to true, it enforces the use of getAllPathsBetween to first obtain all possible paths,
5727
5727
  * followed by iterative computation of the shortest path. This approach may result in exponential time complexity,
5728
5728
  * so the default method is to use the Dijkstra algorithm to obtain the shortest weighted path.
5729
- * @returns The function `getMinPathBetween` returns an array of vertices (`VO[]`) representing the minimum path between
5730
- * two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `undefined`.
5729
+ * @returns The function `getMinPathBetween` returns an array of vertexMap (`VO[]`) representing the minimum path between
5730
+ * two vertexMap (`v1` and `v2`). If there is no path between the vertexMap, it returns `undefined`.
5731
5731
  */
5732
5732
  getMinPathBetween(v1, v2, isWeight, isDFS = false) {
5733
5733
  var _a, _b;
@@ -5789,7 +5789,7 @@ var dataStructureTyped = (() => {
5789
5789
  * Time Complexity: O(V^2 + E) - Quadratic time in the worst case (no heap optimization).
5790
5790
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
5791
5791
  *
5792
- * The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in
5792
+ * The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertexMap in
5793
5793
  * a graph without using a heap data structure.
5794
5794
  * @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
5795
5795
  * vertex object or a vertex ID.
@@ -5801,7 +5801,7 @@ var dataStructureTyped = (() => {
5801
5801
  * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
5802
5802
  * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
5803
5803
  * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
5804
- * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
5804
+ * shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
5805
5805
  * @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.
5806
5806
  */
5807
5807
  dijkstraWithoutHeap(src, dest, getMinDist, genPaths) {
@@ -5815,7 +5815,7 @@ var dataStructureTyped = (() => {
5815
5815
  let minDest = void 0;
5816
5816
  let minPath = [];
5817
5817
  const paths = [];
5818
- const vertices = this._vertices;
5818
+ const vertexMap = this._vertexMap;
5819
5819
  const distMap = /* @__PURE__ */ new Map();
5820
5820
  const seen = /* @__PURE__ */ new Set();
5821
5821
  const preMap = /* @__PURE__ */ new Map();
@@ -5824,7 +5824,7 @@ var dataStructureTyped = (() => {
5824
5824
  if (!srcVertex) {
5825
5825
  return void 0;
5826
5826
  }
5827
- for (const vertex of vertices) {
5827
+ for (const vertex of vertexMap) {
5828
5828
  const vertexOrKey = vertex[1];
5829
5829
  if (vertexOrKey instanceof AbstractVertex)
5830
5830
  distMap.set(vertexOrKey, Infinity);
@@ -5845,7 +5845,7 @@ var dataStructureTyped = (() => {
5845
5845
  return minV;
5846
5846
  };
5847
5847
  const getPaths = (minV) => {
5848
- for (const vertex of vertices) {
5848
+ for (const vertex of vertexMap) {
5849
5849
  const vertexOrKey = vertex[1];
5850
5850
  if (vertexOrKey instanceof AbstractVertex) {
5851
5851
  const path = [vertexOrKey];
@@ -5861,7 +5861,7 @@ var dataStructureTyped = (() => {
5861
5861
  }
5862
5862
  }
5863
5863
  };
5864
- for (let i = 1; i < vertices.size; i++) {
5864
+ for (let i = 1; i < vertexMap.size; i++) {
5865
5865
  const cur = getMinOfNoSeen();
5866
5866
  if (cur) {
5867
5867
  seen.add(cur);
@@ -5908,7 +5908,7 @@ var dataStructureTyped = (() => {
5908
5908
  * Dijkstra algorithm time: O(logVE) space: O(VO + EO)
5909
5909
  *
5910
5910
  * Dijkstra's algorithm only solves the single-source shortest path problem, while the Bellman-Ford algorithm and Floyd-Warshall algorithm can address shortest paths between all pairs of nodes.
5911
- * Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edges.
5911
+ * Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edgeMap.
5912
5912
  * The time complexity of Dijkstra's algorithm and the Bellman-Ford algorithm depends on the size of the graph, while the time complexity of the Floyd-Warshall algorithm is O(VO^3), where VO is the number of nodes. For dense graphs, Floyd-Warshall might become slower.
5913
5913
  *
5914
5914
  * /
@@ -5928,13 +5928,13 @@ var dataStructureTyped = (() => {
5928
5928
  * start. It can be either a vertex object or a vertex ID.
5929
5929
  * @param {VO | VertexKey | undefined} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
5930
5930
  * vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
5931
- * will calculate the shortest paths to all other vertices from the source vertex.
5931
+ * will calculate the shortest paths to all other vertexMap from the source vertex.
5932
5932
  * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
5933
5933
  * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
5934
5934
  * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
5935
5935
  * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
5936
5936
  * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
5937
- * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
5937
+ * shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
5938
5938
  * @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.
5939
5939
  */
5940
5940
  dijkstra(src, dest, getMinDist, genPaths) {
@@ -5949,7 +5949,7 @@ var dataStructureTyped = (() => {
5949
5949
  let minDest = void 0;
5950
5950
  let minPath = [];
5951
5951
  const paths = [];
5952
- const vertices = this._vertices;
5952
+ const vertexMap = this._vertexMap;
5953
5953
  const distMap = /* @__PURE__ */ new Map();
5954
5954
  const seen = /* @__PURE__ */ new Set();
5955
5955
  const preMap = /* @__PURE__ */ new Map();
@@ -5957,7 +5957,7 @@ var dataStructureTyped = (() => {
5957
5957
  const destVertex = dest ? this._getVertex(dest) : void 0;
5958
5958
  if (!srcVertex)
5959
5959
  return void 0;
5960
- for (const vertex of vertices) {
5960
+ for (const vertex of vertexMap) {
5961
5961
  const vertexOrKey = vertex[1];
5962
5962
  if (vertexOrKey instanceof AbstractVertex)
5963
5963
  distMap.set(vertexOrKey, Infinity);
@@ -5967,7 +5967,7 @@ var dataStructureTyped = (() => {
5967
5967
  distMap.set(srcVertex, 0);
5968
5968
  preMap.set(srcVertex, void 0);
5969
5969
  const getPaths = (minV) => {
5970
- for (const vertex of vertices) {
5970
+ for (const vertex of vertexMap) {
5971
5971
  const vertexOrKey = vertex[1];
5972
5972
  if (vertexOrKey instanceof AbstractVertex) {
5973
5973
  const path = [vertexOrKey];
@@ -6045,16 +6045,16 @@ var dataStructureTyped = (() => {
6045
6045
  * Space Complexity: O(V + E) - Depends on the implementation (Bellman-Ford algorithm).
6046
6046
  *
6047
6047
  * one to rest pairs
6048
- * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
6048
+ * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edgeMap for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edgeMap, the Bellman-Ford algorithm is more flexible in some scenarios.
6049
6049
  * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
6050
- * all other vertices in a graph, and optionally detects negative cycles and generates the minimum path.
6050
+ * all other vertexMap in a graph, and optionally detects negative cycles and generates the minimum path.
6051
6051
  * @param {VO | VertexKey} src - The `src` parameter is the source vertex from which the Bellman-Ford algorithm will
6052
6052
  * start calculating the shortest paths. It can be either a vertex object or a vertex ID.
6053
6053
  * @param {boolean} [scanNegativeCycle] - A boolean flag indicating whether to scan for negative cycles in the graph.
6054
6054
  * @param {boolean} [getMin] - The `getMin` parameter is a boolean flag that determines whether the algorithm should
6055
- * calculate the minimum distance from the source vertex to all other vertices in the graph. If `getMin` is set to
6055
+ * calculate the minimum distance from the source vertex to all other vertexMap in the graph. If `getMin` is set to
6056
6056
  * `true`, the algorithm will find the minimum distance and update the `min` variable with the minimum
6057
- * @param {boolean} [genPath] - A boolean flag indicating whether to generate paths for all vertices from the source
6057
+ * @param {boolean} [genPath] - A boolean flag indicating whether to generate paths for all vertexMap from the source
6058
6058
  * vertex.
6059
6059
  * @returns The function `bellmanFord` returns an object with the following properties:
6060
6060
  */
@@ -6074,20 +6074,20 @@ var dataStructureTyped = (() => {
6074
6074
  hasNegativeCycle = false;
6075
6075
  if (!srcVertex)
6076
6076
  return { hasNegativeCycle, distMap, preMap, paths, min, minPath };
6077
- const vertices = this._vertices;
6078
- const numOfVertices = vertices.size;
6079
- const edges = this.edgeSet();
6080
- const numOfEdges = edges.length;
6081
- this._vertices.forEach((vertex) => {
6077
+ const vertexMap = this._vertexMap;
6078
+ const numOfVertices = vertexMap.size;
6079
+ const edgeMap = this.edgeSet();
6080
+ const numOfEdges = edgeMap.length;
6081
+ this._vertexMap.forEach((vertex) => {
6082
6082
  distMap.set(vertex, Infinity);
6083
6083
  });
6084
6084
  distMap.set(srcVertex, 0);
6085
6085
  for (let i = 1; i < numOfVertices; ++i) {
6086
6086
  for (let j = 0; j < numOfEdges; ++j) {
6087
- const ends = this.getEndsOfEdge(edges[j]);
6087
+ const ends = this.getEndsOfEdge(edgeMap[j]);
6088
6088
  if (ends) {
6089
6089
  const [s, d] = ends;
6090
- const weight = edges[j].weight;
6090
+ const weight = edgeMap[j].weight;
6091
6091
  const sWeight = distMap.get(s);
6092
6092
  const dWeight = distMap.get(d);
6093
6093
  if (sWeight !== void 0 && dWeight !== void 0) {
@@ -6112,7 +6112,7 @@ var dataStructureTyped = (() => {
6112
6112
  });
6113
6113
  }
6114
6114
  if (genPath) {
6115
- for (const vertex of vertices) {
6115
+ for (const vertex of vertexMap) {
6116
6116
  const vertexOrKey = vertex[1];
6117
6117
  if (vertexOrKey instanceof AbstractVertex) {
6118
6118
  const path = [vertexOrKey];
@@ -6129,10 +6129,10 @@ var dataStructureTyped = (() => {
6129
6129
  }
6130
6130
  }
6131
6131
  for (let j = 0; j < numOfEdges; ++j) {
6132
- const ends = this.getEndsOfEdge(edges[j]);
6132
+ const ends = this.getEndsOfEdge(edgeMap[j]);
6133
6133
  if (ends) {
6134
6134
  const [s] = ends;
6135
- const weight = edges[j].weight;
6135
+ const weight = edgeMap[j].weight;
6136
6136
  const sWeight = distMap.get(s);
6137
6137
  if (sWeight) {
6138
6138
  if (sWeight !== Infinity && sWeight + weight < sWeight)
@@ -6153,7 +6153,7 @@ var dataStructureTyped = (() => {
6153
6153
  /**
6154
6154
  * BellmanFord time:O(VE) space:O(VO)
6155
6155
  * one to rest pairs
6156
- * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
6156
+ * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edgeMap for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edgeMap, the Bellman-Ford algorithm is more flexible in some scenarios.
6157
6157
  * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
6158
6158
  */
6159
6159
  /**
@@ -6161,7 +6161,7 @@ var dataStructureTyped = (() => {
6161
6161
  * Space Complexity: O(V^2) - Quadratic space (Floyd-Warshall algorithm).
6162
6162
  * Not support graph with negative weight cycle
6163
6163
  * all pairs
6164
- * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
6164
+ * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edgeMap, and it can simultaneously compute shortest paths between any two nodes.
6165
6165
  * /
6166
6166
 
6167
6167
  /**
@@ -6170,17 +6170,17 @@ var dataStructureTyped = (() => {
6170
6170
  *
6171
6171
  * Not support graph with negative weight cycle
6172
6172
  * all pairs
6173
- * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
6174
- * The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertices in a
6173
+ * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edgeMap, and it can simultaneously compute shortest paths between any two nodes.
6174
+ * The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertexMap in a
6175
6175
  * graph.
6176
6176
  * @returns The function `floydWarshall()` returns an object with two properties: `costs` and `predecessor`. The `costs`
6177
- * property is a 2D array of numbers representing the shortest path costs between vertices in a graph. The
6178
- * `predecessor` property is a 2D array of vertices (or `undefined`) representing the predecessor vertices in the shortest
6179
- * path between vertices in the
6177
+ * property is a 2D array of numbers representing the shortest path costs between vertexMap in a graph. The
6178
+ * `predecessor` property is a 2D array of vertexMap (or `undefined`) representing the predecessor vertexMap in the shortest
6179
+ * path between vertexMap in the
6180
6180
  */
6181
6181
  floydWarshall() {
6182
6182
  var _a;
6183
- const idAndVertices = [...this._vertices];
6183
+ const idAndVertices = [...this._vertexMap];
6184
6184
  const n = idAndVertices.length;
6185
6185
  const costs = [];
6186
6186
  const predecessor = [];
@@ -6213,7 +6213,7 @@ var dataStructureTyped = (() => {
6213
6213
  * Space Complexity: O(V) - Linear space (Tarjan's algorithm).
6214
6214
  * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
6215
6215
  * Tarjan can find cycles in directed or undirected graph
6216
- * Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
6216
+ * Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
6217
6217
  * Tarjan solve the bi-connected components of undirected graphs;
6218
6218
  * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
6219
6219
  * /
@@ -6224,22 +6224,22 @@ var dataStructureTyped = (() => {
6224
6224
  *
6225
6225
  * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
6226
6226
  * Tarjan can find cycles in directed or undirected graph
6227
- * Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
6227
+ * Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
6228
6228
  * Tarjan solve the bi-connected components of undirected graphs;
6229
6229
  * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
6230
6230
  * The `tarjan` function is used to perform various graph analysis tasks such as finding articulation points, bridges,
6231
6231
  * strongly connected components (SCCs), and cycles in a graph.
6232
6232
  * @param {boolean} [needCutVertexes] - A boolean value indicating whether or not to calculate and return the
6233
- * articulation points in the graph. Articulation points are the vertices in a graph whose removal would increase the
6233
+ * articulation points in the graph. Articulation points are the vertexMap in a graph whose removal would increase the
6234
6234
  * number of connected components in the graph.
6235
6235
  * @param {boolean} [needBridges] - A boolean flag indicating whether the algorithm should find and return the bridges
6236
- * (edges whose removal would increase the number of connected components in the graph).
6236
+ * (edgeMap whose removal would increase the number of connected components in the graph).
6237
6237
  * @param {boolean} [needSCCs] - A boolean value indicating whether the Strongly Connected Components (SCCs) of the
6238
6238
  * graph are needed. If set to true, the function will calculate and return the SCCs of the graph. If set to false, the
6239
6239
  * SCCs will not be calculated or returned.
6240
6240
  * @param {boolean} [needCycles] - A boolean flag indicating whether the algorithm should find cycles in the graph. If
6241
6241
  * set to true, the algorithm will return a map of cycles, where the keys are the low values of the SCCs and the values
6242
- * are arrays of vertices that form cycles within the SCCs.
6242
+ * are arrays of vertexMap that form cycles within the SCCs.
6243
6243
  * @returns The function `tarjan` returns an object with the following properties:
6244
6244
  */
6245
6245
  tarjan(needCutVertexes = false, needBridges = false, needSCCs = true, needCycles = false) {
@@ -6254,12 +6254,12 @@ var dataStructureTyped = (() => {
6254
6254
  needCycles = defaultConfig;
6255
6255
  const dfnMap = /* @__PURE__ */ new Map();
6256
6256
  const lowMap = /* @__PURE__ */ new Map();
6257
- const vertices = this._vertices;
6258
- vertices.forEach((v) => {
6257
+ const vertexMap = this._vertexMap;
6258
+ vertexMap.forEach((v) => {
6259
6259
  dfnMap.set(v, -1);
6260
6260
  lowMap.set(v, Infinity);
6261
6261
  });
6262
- const [root] = vertices.values();
6262
+ const [root] = vertexMap.values();
6263
6263
  const cutVertexes = [];
6264
6264
  const bridges = [];
6265
6265
  let dfn = 0;
@@ -6441,7 +6441,7 @@ var dataStructureTyped = (() => {
6441
6441
  return mapped;
6442
6442
  }
6443
6443
  *_getIterator() {
6444
- for (const vertex of this._vertices.values()) {
6444
+ for (const vertex of this._vertexMap.values()) {
6445
6445
  yield [vertex.key, vertex.value];
6446
6446
  }
6447
6447
  }
@@ -6449,12 +6449,12 @@ var dataStructureTyped = (() => {
6449
6449
  if (this.hasVertex(newVertex)) {
6450
6450
  return false;
6451
6451
  }
6452
- this._vertices.set(newVertex.key, newVertex);
6452
+ this._vertexMap.set(newVertex.key, newVertex);
6453
6453
  return true;
6454
6454
  }
6455
6455
  _getVertex(vertexOrKey) {
6456
6456
  const vertexKey = this._getVertexKey(vertexOrKey);
6457
- return this._vertices.get(vertexKey) || void 0;
6457
+ return this._vertexMap.get(vertexKey) || void 0;
6458
6458
  }
6459
6459
  _getVertexKey(vertexOrKey) {
6460
6460
  return vertexOrKey instanceof AbstractVertex ? vertexOrKey.key : vertexOrKey;
@@ -6476,7 +6476,7 @@ var dataStructureTyped = (() => {
6476
6476
  };
6477
6477
  var DirectedEdge = class extends AbstractEdge {
6478
6478
  /**
6479
- * The constructor function initializes the source and destination vertices of an edge, along with an optional weight
6479
+ * The constructor function initializes the source and destination vertexMap of an edge, along with an optional weight
6480
6480
  * and value.
6481
6481
  * @param {VertexKey} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
6482
6482
  * a graph.
@@ -6516,7 +6516,7 @@ var dataStructureTyped = (() => {
6516
6516
  /**
6517
6517
  * The function creates a new vertex with an optional value and returns it.
6518
6518
  * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
6519
- * could be a number or a string depending on how you want to identify your vertices.
6519
+ * could be a number or a string depending on how you want to identify your vertexMap.
6520
6520
  * @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,
6521
6521
  * it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be
6522
6522
  * assigned the same value as the 'key' parameter
@@ -6530,7 +6530,7 @@ var dataStructureTyped = (() => {
6530
6530
  * 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.
6531
6531
  */
6532
6532
  /**
6533
- * The function creates a directed edge between two vertices with an optional weight and value.
6533
+ * The function creates a directed edge between two vertexMap with an optional weight and value.
6534
6534
  * @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
6535
6535
  * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge.
6536
6536
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge. If no
@@ -6543,43 +6543,43 @@ var dataStructureTyped = (() => {
6543
6543
  return new DirectedEdge(src, dest, weight != null ? weight : 1, value);
6544
6544
  }
6545
6545
  /**
6546
- * Time Complexity: O(|V|) where |V| is the number of vertices
6546
+ * Time Complexity: O(|V|) where |V| is the number of vertexMap
6547
6547
  * Space Complexity: O(1)
6548
6548
  */
6549
6549
  /**
6550
- * Time Complexity: O(|V|) where |V| is the number of vertices
6550
+ * Time Complexity: O(|V|) where |V| is the number of vertexMap
6551
6551
  * Space Complexity: O(1)
6552
6552
  *
6553
- * The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
6553
+ * The `getEdge` function retrieves an edge between two vertexMap based on their source and destination IDs.
6554
6554
  * @param {VO | VertexKey | undefined} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
6555
6555
  * @param {VO | VertexKey | undefined} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
6556
6556
  * destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `undefined` if the
6557
6557
  * destination is not specified.
6558
- * @returns the first edge found between the source and destination vertices, or undefined if no such edge is found.
6558
+ * @returns the first edge found between the source and destination vertexMap, or undefined if no such edge is found.
6559
6559
  */
6560
6560
  getEdge(srcOrKey, destOrKey) {
6561
- let edges = [];
6561
+ let edgeMap = [];
6562
6562
  if (srcOrKey !== void 0 && destOrKey !== void 0) {
6563
6563
  const src = this._getVertex(srcOrKey);
6564
6564
  const dest = this._getVertex(destOrKey);
6565
6565
  if (src && dest) {
6566
6566
  const srcOutEdges = this._outEdgeMap.get(src);
6567
6567
  if (srcOutEdges) {
6568
- edges = srcOutEdges.filter((edge) => edge.dest === dest.key);
6568
+ edgeMap = srcOutEdges.filter((edge) => edge.dest === dest.key);
6569
6569
  }
6570
6570
  }
6571
6571
  }
6572
- return edges[0] || void 0;
6572
+ return edgeMap[0] || void 0;
6573
6573
  }
6574
6574
  /**
6575
- * Time Complexity: O(|E|) where |E| is the number of edges
6575
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6576
6576
  * Space Complexity: O(1)
6577
6577
  */
6578
6578
  /**
6579
- * Time Complexity: O(|E|) where |E| is the number of edges
6579
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6580
6580
  * Space Complexity: O(1)
6581
6581
  *
6582
- * The function removes an edge between two vertices in a graph and returns the removed edge.
6582
+ * The function removes an edge between two vertexMap in a graph and returns the removed edge.
6583
6583
  * @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
6584
6584
  * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
6585
6585
  * @returns the removed edge (EO) if it exists, or undefined if either the source or destination vertex does not exist.
@@ -6602,11 +6602,11 @@ var dataStructureTyped = (() => {
6602
6602
  return removed;
6603
6603
  }
6604
6604
  /**
6605
- * Time Complexity: O(E) where E is the number of edges
6605
+ * Time Complexity: O(E) where E is the number of edgeMap
6606
6606
  * Space Complexity: O(1)
6607
6607
  */
6608
6608
  /**
6609
- * Time Complexity: O(E) where E is the number of edges
6609
+ * Time Complexity: O(E) where E is the number of edgeMap
6610
6610
  * Space Complexity: O(1)
6611
6611
  *
6612
6612
  * The `deleteEdge` function removes an edge from a graph and returns the removed edge.
@@ -6671,22 +6671,22 @@ var dataStructureTyped = (() => {
6671
6671
  this._outEdgeMap.delete(vertex);
6672
6672
  this._inEdgeMap.delete(vertex);
6673
6673
  }
6674
- return this._vertices.delete(vertexKey);
6674
+ return this._vertexMap.delete(vertexKey);
6675
6675
  }
6676
6676
  /**
6677
- * Time Complexity: O(|E|) where |E| is the number of edges
6677
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6678
6678
  * Space Complexity: O(1)
6679
6679
  */
6680
6680
  /**
6681
- * Time Complexity: O(|E|) where |E| is the number of edges
6681
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6682
6682
  * Space Complexity: O(1)
6683
6683
  *
6684
- * The function removes edges between two vertices and returns the removed edges.
6684
+ * The function removes edgeMap between two vertexMap and returns the removed edgeMap.
6685
6685
  * @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
6686
6686
  * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
6687
6687
  * @param {VertexKey | VO} v2 - The parameter `v2` represents either a `VertexKey` or a `VO` object. It is used to specify
6688
6688
  * the second vertex in the edge that needs to be removed.
6689
- * @returns an array of removed edges (EO[]).
6689
+ * @returns an array of removed edgeMap (EO[]).
6690
6690
  */
6691
6691
  deleteEdgesBetween(v1, v2) {
6692
6692
  const removed = [];
@@ -6706,10 +6706,10 @@ var dataStructureTyped = (() => {
6706
6706
  * Time Complexity: O(1)
6707
6707
  * Space Complexity: O(1)
6708
6708
  *
6709
- * The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
6709
+ * The function `incomingEdgesOf` returns an array of incoming edgeMap for a given vertex or vertex ID.
6710
6710
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
6711
6711
  * (`VertexKey`).
6712
- * @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
6712
+ * @returns The method `incomingEdgesOf` returns an array of edgeMap (`EO[]`).
6713
6713
  */
6714
6714
  incomingEdgesOf(vertexOrKey) {
6715
6715
  const target = this._getVertex(vertexOrKey);
@@ -6726,10 +6726,10 @@ var dataStructureTyped = (() => {
6726
6726
  * Time Complexity: O(1)
6727
6727
  * Space Complexity: O(1)
6728
6728
  *
6729
- * The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
6729
+ * The function `outgoingEdgesOf` returns an array of outgoing edgeMap from a given vertex or vertex ID.
6730
6730
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
6731
6731
  * (`VertexKey`).
6732
- * @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
6732
+ * @returns The method `outgoingEdgesOf` returns an array of edgeMap (`EO[]`).
6733
6733
  */
6734
6734
  outgoingEdgesOf(vertexOrKey) {
6735
6735
  const target = this._getVertex(vertexOrKey);
@@ -6761,9 +6761,9 @@ var dataStructureTyped = (() => {
6761
6761
  * Time Complexity: O(1)
6762
6762
  * Space Complexity: O(1)
6763
6763
  *
6764
- * The function "inDegreeOf" returns the number of incoming edges for a given vertex.
6764
+ * The function "inDegreeOf" returns the number of incoming edgeMap for a given vertex.
6765
6765
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
6766
- * @returns The number of incoming edges of the specified vertex or vertex ID.
6766
+ * @returns The number of incoming edgeMap of the specified vertex or vertex ID.
6767
6767
  */
6768
6768
  inDegreeOf(vertexOrKey) {
6769
6769
  return this.incomingEdgesOf(vertexOrKey).length;
@@ -6776,9 +6776,9 @@ var dataStructureTyped = (() => {
6776
6776
  * Time Complexity: O(1)
6777
6777
  * Space Complexity: O(1)
6778
6778
  *
6779
- * The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
6779
+ * The function `outDegreeOf` returns the number of outgoing edgeMap from a given vertex.
6780
6780
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
6781
- * @returns The number of outgoing edges from the specified vertex or vertex ID.
6781
+ * @returns The number of outgoing edgeMap from the specified vertex or vertex ID.
6782
6782
  */
6783
6783
  outDegreeOf(vertexOrKey) {
6784
6784
  return this.outgoingEdgesOf(vertexOrKey).length;
@@ -6791,9 +6791,9 @@ var dataStructureTyped = (() => {
6791
6791
  * Time Complexity: O(1)
6792
6792
  * Space Complexity: O(1)
6793
6793
  *
6794
- * The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
6794
+ * The function "edgesOf" returns an array of both outgoing and incoming edgeMap of a given vertex or vertex ID.
6795
6795
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
6796
- * @returns The function `edgesOf` returns an array of edges.
6796
+ * @returns The function `edgesOf` returns an array of edgeMap.
6797
6797
  */
6798
6798
  edgesOf(vertexOrKey) {
6799
6799
  return [...this.outgoingEdgesOf(vertexOrKey), ...this.incomingEdgesOf(vertexOrKey)];
@@ -6829,17 +6829,17 @@ var dataStructureTyped = (() => {
6829
6829
  return this._getVertex(e.dest);
6830
6830
  }
6831
6831
  /**
6832
- * Time Complexity: O(|E|) where |E| is the number of edges
6832
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6833
6833
  * Space Complexity: O(1)
6834
6834
  */
6835
6835
  /**
6836
- * Time Complexity: O(|E|) where |E| is the number of edges
6836
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6837
6837
  * Space Complexity: O(1)
6838
6838
  *
6839
- * The function `getDestinations` returns an array of destination vertices connected to a given vertex.
6839
+ * The function `getDestinations` returns an array of destination vertexMap connected to a given vertex.
6840
6840
  * @param {VO | VertexKey | undefined} vertex - The `vertex` parameter represents the starting vertex from which we want to
6841
6841
  * find the destinations. It can be either a `VO` object, a `VertexKey` value, or `undefined`.
6842
- * @returns an array of vertices (VO[]).
6842
+ * @returns an array of vertexMap (VO[]).
6843
6843
  */
6844
6844
  getDestinations(vertex) {
6845
6845
  if (vertex === void 0) {
@@ -6856,24 +6856,24 @@ var dataStructureTyped = (() => {
6856
6856
  return destinations;
6857
6857
  }
6858
6858
  /**
6859
- * Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
6859
+ * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
6860
6860
  * Space Complexity: O(|V|)
6861
6861
  */
6862
6862
  /**
6863
- * Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
6863
+ * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
6864
6864
  * Space Complexity: O(|V|)
6865
6865
  *
6866
- * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
6866
+ * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertexMap or vertex IDs
6867
6867
  * in the sorted order, or undefined if the graph contains a cycle.
6868
6868
  * @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
6869
- * property to use for sorting the vertices. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
6870
- * specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
6871
- * @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
6869
+ * property to use for sorting the vertexMap. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
6870
+ * specified, the vertexMap themselves will be used for sorting. If 'key' is specified, the ids of
6871
+ * @returns an array of vertexMap or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
6872
6872
  */
6873
6873
  topologicalSort(propertyName) {
6874
6874
  propertyName = propertyName != null ? propertyName : "key";
6875
6875
  const statusMap = /* @__PURE__ */ new Map();
6876
- for (const entry of this.vertices) {
6876
+ for (const entry of this.vertexMap) {
6877
6877
  statusMap.set(entry[1], 0);
6878
6878
  }
6879
6879
  let sorted = [];
@@ -6892,7 +6892,7 @@ var dataStructureTyped = (() => {
6892
6892
  statusMap.set(cur, 2);
6893
6893
  sorted.push(cur);
6894
6894
  };
6895
- for (const entry of this.vertices) {
6895
+ for (const entry of this.vertexMap) {
6896
6896
  if (statusMap.get(entry[1]) === 0) {
6897
6897
  dfs(entry[1]);
6898
6898
  }
@@ -6904,35 +6904,35 @@ var dataStructureTyped = (() => {
6904
6904
  return sorted.reverse();
6905
6905
  }
6906
6906
  /**
6907
- * Time Complexity: O(|E|) where |E| is the number of edges
6907
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6908
6908
  * Space Complexity: O(|E|)
6909
6909
  */
6910
6910
  /**
6911
- * Time Complexity: O(|E|) where |E| is the number of edges
6911
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6912
6912
  * Space Complexity: O(|E|)
6913
6913
  *
6914
- * The `edgeSet` function returns an array of all the edges in the graph.
6915
- * @returns The `edgeSet()` method returns an array of edges (`EO[]`).
6914
+ * The `edgeSet` function returns an array of all the edgeMap in the graph.
6915
+ * @returns The `edgeSet()` method returns an array of edgeMap (`EO[]`).
6916
6916
  */
6917
6917
  edgeSet() {
6918
- let edges = [];
6918
+ let edgeMap = [];
6919
6919
  this._outEdgeMap.forEach((outEdges) => {
6920
- edges = [...edges, ...outEdges];
6920
+ edgeMap = [...edgeMap, ...outEdges];
6921
6921
  });
6922
- return edges;
6922
+ return edgeMap;
6923
6923
  }
6924
6924
  /**
6925
- * Time Complexity: O(|E|) where |E| is the number of edges
6925
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6926
6926
  * Space Complexity: O(1)
6927
6927
  */
6928
6928
  /**
6929
- * Time Complexity: O(|E|) where |E| is the number of edges
6929
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6930
6930
  * Space Complexity: O(1)
6931
6931
  *
6932
- * The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
6932
+ * The function `getNeighbors` returns an array of neighboring vertexMap of a given vertex or vertex ID in a graph.
6933
6933
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
6934
6934
  * (`VertexKey`).
6935
- * @returns an array of vertices (VO[]).
6935
+ * @returns an array of vertexMap (VO[]).
6936
6936
  */
6937
6937
  getNeighbors(vertexOrKey) {
6938
6938
  const neighbors = [];
@@ -6956,10 +6956,10 @@ var dataStructureTyped = (() => {
6956
6956
  * Time Complexity: O(1)
6957
6957
  * Space Complexity: O(1)
6958
6958
  *
6959
- * The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
6959
+ * The function "getEndsOfEdge" returns the source and destination vertexMap of an edge if it exists in the graph,
6960
6960
  * otherwise it returns undefined.
6961
6961
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
6962
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
6962
+ * @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
6963
6963
  * graph. If the edge does not exist, it returns `undefined`.
6964
6964
  */
6965
6965
  getEndsOfEdge(edge) {
@@ -6982,7 +6982,7 @@ var dataStructureTyped = (() => {
6982
6982
  * Time Complexity: O(1)
6983
6983
  * Space Complexity: O(1)
6984
6984
  *
6985
- * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
6985
+ * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
6986
6986
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
6987
6987
  * needs to be added to the graph.
6988
6988
  * @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
@@ -7040,21 +7040,21 @@ var dataStructureTyped = (() => {
7040
7040
  */
7041
7041
  constructor(v1, v2, weight, value) {
7042
7042
  super(weight, value);
7043
- __publicField(this, "vertices");
7044
- this.vertices = [v1, v2];
7043
+ __publicField(this, "vertexMap");
7044
+ this.vertexMap = [v1, v2];
7045
7045
  }
7046
7046
  };
7047
7047
  var UndirectedGraph = class extends AbstractGraph {
7048
7048
  /**
7049
- * The constructor initializes a new Map object to store edges.
7049
+ * The constructor initializes a new Map object to store edgeMap.
7050
7050
  */
7051
7051
  constructor() {
7052
7052
  super();
7053
- __publicField(this, "_edges");
7054
- this._edges = /* @__PURE__ */ new Map();
7053
+ __publicField(this, "_edgeMap");
7054
+ this._edgeMap = /* @__PURE__ */ new Map();
7055
7055
  }
7056
- get edges() {
7057
- return this._edges;
7056
+ get edgeMap() {
7057
+ return this._edgeMap;
7058
7058
  }
7059
7059
  /**
7060
7060
  * The function creates a new vertex with an optional value and returns it.
@@ -7069,7 +7069,7 @@ var dataStructureTyped = (() => {
7069
7069
  return new UndirectedVertex(key, value != null ? value : key);
7070
7070
  }
7071
7071
  /**
7072
- * The function creates an undirected edge between two vertices with an optional weight and value.
7072
+ * The function creates an undirected edge between two vertexMap with an optional weight and value.
7073
7073
  * @param {VertexKey} v1 - The parameter `v1` represents the first vertex of the edge.
7074
7074
  * @param {VertexKey} v2 - The parameter `v2` represents the second vertex of the edge.
7075
7075
  * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. If
@@ -7082,14 +7082,14 @@ var dataStructureTyped = (() => {
7082
7082
  return new UndirectedEdge(v1, v2, weight != null ? weight : 1, value);
7083
7083
  }
7084
7084
  /**
7085
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
7085
+ * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7086
7086
  * Space Complexity: O(1)
7087
7087
  */
7088
7088
  /**
7089
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
7089
+ * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7090
7090
  * Space Complexity: O(1)
7091
7091
  *
7092
- * The function `getEdge` returns the first edge that connects two vertices, or undefined if no such edge exists.
7092
+ * The function `getEdge` returns the first edge that connects two vertexMap, or undefined if no such edge exists.
7093
7093
  * @param {VO | VertexKey | undefined} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
7094
7094
  * object), `undefined`, or `VertexKey` (a string or number representing the ID of a vertex).
7095
7095
  * @param {VO | VertexKey | undefined} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
@@ -7098,29 +7098,29 @@ var dataStructureTyped = (() => {
7098
7098
  */
7099
7099
  getEdge(v1, v2) {
7100
7100
  var _a;
7101
- let edges = [];
7101
+ let edgeMap = [];
7102
7102
  if (v1 !== void 0 && v2 !== void 0) {
7103
7103
  const vertex1 = this._getVertex(v1);
7104
7104
  const vertex2 = this._getVertex(v2);
7105
7105
  if (vertex1 && vertex2) {
7106
- edges = (_a = this._edges.get(vertex1)) == null ? void 0 : _a.filter((e) => e.vertices.includes(vertex2.key));
7106
+ edgeMap = (_a = this._edgeMap.get(vertex1)) == null ? void 0 : _a.filter((e) => e.vertexMap.includes(vertex2.key));
7107
7107
  }
7108
7108
  }
7109
- return edges ? edges[0] || void 0 : void 0;
7109
+ return edgeMap ? edgeMap[0] || void 0 : void 0;
7110
7110
  }
7111
7111
  /**
7112
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
7112
+ * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7113
7113
  * Space Complexity: O(1)
7114
7114
  */
7115
7115
  /**
7116
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
7116
+ * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7117
7117
  * Space Complexity: O(1)
7118
7118
  *
7119
- * The function removes an edge between two vertices in a graph and returns the removed edge.
7119
+ * The function removes an edge between two vertexMap in a graph and returns the removed edge.
7120
7120
  * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
7121
7121
  * @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
7122
7122
  * (VertexKey). It represents the second vertex of the edge that needs to be removed.
7123
- * @returns the removed edge (EO) if it exists, or undefined if either of the vertices (VO) does not exist.
7123
+ * @returns the removed edge (EO) if it exists, or undefined if either of the vertexMap (VO) does not exist.
7124
7124
  */
7125
7125
  deleteEdgeBetween(v1, v2) {
7126
7126
  const vertex1 = this._getVertex(v1);
@@ -7128,26 +7128,26 @@ var dataStructureTyped = (() => {
7128
7128
  if (!vertex1 || !vertex2) {
7129
7129
  return void 0;
7130
7130
  }
7131
- const v1Edges = this._edges.get(vertex1);
7131
+ const v1Edges = this._edgeMap.get(vertex1);
7132
7132
  let removed = void 0;
7133
7133
  if (v1Edges) {
7134
- removed = arrayRemove(v1Edges, (e) => e.vertices.includes(vertex2.key))[0] || void 0;
7134
+ removed = arrayRemove(v1Edges, (e) => e.vertexMap.includes(vertex2.key))[0] || void 0;
7135
7135
  }
7136
- const v2Edges = this._edges.get(vertex2);
7136
+ const v2Edges = this._edgeMap.get(vertex2);
7137
7137
  if (v2Edges) {
7138
- arrayRemove(v2Edges, (e) => e.vertices.includes(vertex1.key));
7138
+ arrayRemove(v2Edges, (e) => e.vertexMap.includes(vertex1.key));
7139
7139
  }
7140
7140
  return removed;
7141
7141
  }
7142
7142
  /**
7143
- * Time Complexity: O(E), where E is the number of edges incident to the given vertex.
7143
+ * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
7144
7144
  * Space Complexity: O(1)
7145
7145
  */
7146
7146
  /**
7147
- * Time Complexity: O(E), where E is the number of edges incident to the given vertex.
7147
+ * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
7148
7148
  * Space Complexity: O(1)
7149
7149
  *
7150
- * The function `deleteEdge` deletes an edge between two vertices in a graph.
7150
+ * The function `deleteEdge` deletes an edge between two vertexMap in a graph.
7151
7151
  * @param {EO | VertexKey} edgeOrOneSideVertexKey - The parameter `edgeOrOneSideVertexKey` can be
7152
7152
  * either an edge object or a vertex key.
7153
7153
  * @param {VertexKey} [otherSideVertexKey] - The parameter `otherSideVertexKey` is an optional
@@ -7166,8 +7166,8 @@ var dataStructureTyped = (() => {
7166
7166
  return;
7167
7167
  }
7168
7168
  } else {
7169
- oneSide = this._getVertex(edgeOrOneSideVertexKey.vertices[0]);
7170
- otherSide = this._getVertex(edgeOrOneSideVertexKey.vertices[1]);
7169
+ oneSide = this._getVertex(edgeOrOneSideVertexKey.vertexMap[0]);
7170
+ otherSide = this._getVertex(edgeOrOneSideVertexKey.vertexMap[1]);
7171
7171
  }
7172
7172
  if (oneSide && otherSide) {
7173
7173
  return this.deleteEdgeBetween(oneSide, otherSide);
@@ -7201,17 +7201,17 @@ var dataStructureTyped = (() => {
7201
7201
  const neighbors = this.getNeighbors(vertexOrKey);
7202
7202
  if (vertex) {
7203
7203
  neighbors.forEach((neighbor) => {
7204
- const neighborEdges = this._edges.get(neighbor);
7204
+ const neighborEdges = this._edgeMap.get(neighbor);
7205
7205
  if (neighborEdges) {
7206
7206
  const restEdges = neighborEdges.filter((edge) => {
7207
- return !edge.vertices.includes(vertexKey);
7207
+ return !edge.vertexMap.includes(vertexKey);
7208
7208
  });
7209
- this._edges.set(neighbor, restEdges);
7209
+ this._edgeMap.set(neighbor, restEdges);
7210
7210
  }
7211
7211
  });
7212
- this._edges.delete(vertex);
7212
+ this._edgeMap.delete(vertex);
7213
7213
  }
7214
- return this._vertices.delete(vertexKey);
7214
+ return this._vertexMap.delete(vertexKey);
7215
7215
  }
7216
7216
  /**
7217
7217
  * Time Complexity: O(1)
@@ -7221,17 +7221,17 @@ var dataStructureTyped = (() => {
7221
7221
  * Time Complexity: O(1)
7222
7222
  * Space Complexity: O(1)
7223
7223
  *
7224
- * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
7224
+ * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edgeMap connected to that
7225
7225
  * vertex.
7226
7226
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
7227
7227
  * @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
7228
- * edges connected to that vertex.
7228
+ * edgeMap connected to that vertex.
7229
7229
  */
7230
7230
  degreeOf(vertexOrKey) {
7231
7231
  var _a;
7232
7232
  const vertex = this._getVertex(vertexOrKey);
7233
7233
  if (vertex) {
7234
- return ((_a = this._edges.get(vertex)) == null ? void 0 : _a.length) || 0;
7234
+ return ((_a = this._edgeMap.get(vertex)) == null ? void 0 : _a.length) || 0;
7235
7235
  } else {
7236
7236
  return 0;
7237
7237
  }
@@ -7244,51 +7244,51 @@ var dataStructureTyped = (() => {
7244
7244
  * Time Complexity: O(1)
7245
7245
  * Space Complexity: O(1)
7246
7246
  *
7247
- * The function returns the edges of a given vertex or vertex ID.
7247
+ * The function returns the edgeMap of a given vertex or vertex ID.
7248
7248
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`. A `VertexKey` is a
7249
7249
  * unique identifier for a vertex in a graph, while `VO` represents the type of the vertex.
7250
- * @returns an array of edges.
7250
+ * @returns an array of edgeMap.
7251
7251
  */
7252
7252
  edgesOf(vertexOrKey) {
7253
7253
  const vertex = this._getVertex(vertexOrKey);
7254
7254
  if (vertex) {
7255
- return this._edges.get(vertex) || [];
7255
+ return this._edgeMap.get(vertex) || [];
7256
7256
  } else {
7257
7257
  return [];
7258
7258
  }
7259
7259
  }
7260
7260
  /**
7261
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
7261
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7262
7262
  * Space Complexity: O(|E|)
7263
7263
  */
7264
7264
  /**
7265
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
7265
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7266
7266
  * Space Complexity: O(|E|)
7267
7267
  *
7268
- * The function "edgeSet" returns an array of unique edges from a set of edges.
7268
+ * The function "edgeSet" returns an array of unique edgeMap from a set of edgeMap.
7269
7269
  * @returns The method `edgeSet()` returns an array of type `EO[]`.
7270
7270
  */
7271
7271
  edgeSet() {
7272
7272
  const edgeSet = /* @__PURE__ */ new Set();
7273
- this._edges.forEach((edges) => {
7274
- edges.forEach((edge) => {
7273
+ this._edgeMap.forEach((edgeMap) => {
7274
+ edgeMap.forEach((edge) => {
7275
7275
  edgeSet.add(edge);
7276
7276
  });
7277
7277
  });
7278
7278
  return [...edgeSet];
7279
7279
  }
7280
7280
  /**
7281
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
7281
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7282
7282
  * Space Complexity: O(|E|)
7283
7283
  */
7284
7284
  /**
7285
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
7285
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7286
7286
  * Space Complexity: O(|E|)
7287
7287
  *
7288
- * The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
7288
+ * The function "getNeighbors" returns an array of neighboring vertexMap for a given vertex or vertex ID.
7289
7289
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
7290
7290
  * (`VertexKey`).
7291
- * @returns an array of vertices (VO[]).
7291
+ * @returns an array of vertexMap (VO[]).
7292
7292
  */
7293
7293
  getNeighbors(vertexOrKey) {
7294
7294
  const neighbors = [];
@@ -7296,7 +7296,7 @@ var dataStructureTyped = (() => {
7296
7296
  if (vertex) {
7297
7297
  const neighborEdges = this.edgesOf(vertex);
7298
7298
  for (const edge of neighborEdges) {
7299
- const neighbor = this._getVertex(edge.vertices.filter((e) => e !== vertex.key)[0]);
7299
+ const neighbor = this._getVertex(edge.vertexMap.filter((e) => e !== vertex.key)[0]);
7300
7300
  if (neighbor) {
7301
7301
  neighbors.push(neighbor);
7302
7302
  }
@@ -7312,18 +7312,18 @@ var dataStructureTyped = (() => {
7312
7312
  * Time Complexity: O(1)
7313
7313
  * Space Complexity: O(1)
7314
7314
  *
7315
- * The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
7315
+ * The function "getEndsOfEdge" returns the vertexMap at the ends of an edge if the edge exists in the graph, otherwise
7316
7316
  * it returns undefined.
7317
7317
  * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
7318
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
7318
+ * @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
7319
7319
  * graph. If the edge does not exist, it returns `undefined`.
7320
7320
  */
7321
7321
  getEndsOfEdge(edge) {
7322
- if (!this.hasEdge(edge.vertices[0], edge.vertices[1])) {
7322
+ if (!this.hasEdge(edge.vertexMap[0], edge.vertexMap[1])) {
7323
7323
  return void 0;
7324
7324
  }
7325
- const v1 = this._getVertex(edge.vertices[0]);
7326
- const v2 = this._getVertex(edge.vertices[1]);
7325
+ const v1 = this._getVertex(edge.vertexMap[0]);
7326
+ const v2 = this._getVertex(edge.vertexMap[1]);
7327
7327
  if (v1 && v2) {
7328
7328
  return [v1, v2];
7329
7329
  } else {
@@ -7338,21 +7338,21 @@ var dataStructureTyped = (() => {
7338
7338
  * Time Complexity: O(1)
7339
7339
  * Space Complexity: O(1)
7340
7340
  *
7341
- * The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
7341
+ * The function adds an edge to the graph by updating the adjacency list with the vertexMap of the edge.
7342
7342
  * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
7343
7343
  * @returns a boolean value.
7344
7344
  */
7345
7345
  _addEdgeOnly(edge) {
7346
- for (const end of edge.vertices) {
7346
+ for (const end of edge.vertexMap) {
7347
7347
  const endVertex = this._getVertex(end);
7348
7348
  if (endVertex === void 0)
7349
7349
  return false;
7350
7350
  if (endVertex) {
7351
- const edges = this._edges.get(endVertex);
7352
- if (edges) {
7353
- edges.push(edge);
7351
+ const edgeMap = this._edgeMap.get(endVertex);
7352
+ if (edgeMap) {
7353
+ edgeMap.push(edge);
7354
7354
  } else {
7355
- this._edges.set(endVertex, [edge]);
7355
+ this._edgeMap.set(endVertex, [edge]);
7356
7356
  }
7357
7357
  }
7358
7358
  }
@@ -7399,23 +7399,23 @@ var dataStructureTyped = (() => {
7399
7399
  };
7400
7400
  var MapGraph = class extends DirectedGraph {
7401
7401
  /**
7402
- * The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
7403
- * @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
7402
+ * The constructor function initializes the originCoord and bottomRight properties of a MapGraphCoordinate object.
7403
+ * @param {MapGraphCoordinate} originCoord - The `originCoord` parameter is a `MapGraphCoordinate` object that represents the
7404
7404
  * starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map
7405
7405
  * graph.
7406
7406
  * @param {MapGraphCoordinate} [bottomRight] - The `bottomRight` parameter is an optional parameter of type
7407
7407
  * `MapGraphCoordinate`. It represents the bottom right coordinate of a map graph. If this parameter is not provided,
7408
7408
  * it will default to `undefined`.
7409
7409
  */
7410
- constructor(origin, bottomRight) {
7410
+ constructor(originCoord, bottomRight) {
7411
7411
  super();
7412
- __publicField(this, "_origin", [0, 0]);
7412
+ __publicField(this, "_originCoord", [0, 0]);
7413
7413
  __publicField(this, "_bottomRight");
7414
- this._origin = origin;
7414
+ this._originCoord = originCoord;
7415
7415
  this._bottomRight = bottomRight;
7416
7416
  }
7417
- get origin() {
7418
- return this._origin;
7417
+ get originCoord() {
7418
+ return this._originCoord;
7419
7419
  }
7420
7420
  get bottomRight() {
7421
7421
  return this._bottomRight;
@@ -7431,7 +7431,7 @@ var dataStructureTyped = (() => {
7431
7431
  * @param {number} long - The `long` parameter represents the longitude coordinate of the vertex.
7432
7432
  * @returns The method is returning a new instance of the `MapVertex` class, casted as type `VO`.
7433
7433
  */
7434
- createVertex(key, value, lat = this.origin[0], long = this.origin[1]) {
7434
+ createVertex(key, value, lat = this.originCoord[0], long = this.originCoord[1]) {
7435
7435
  return new MapVertex(key, value, lat, long);
7436
7436
  }
7437
7437
  /**
@@ -7534,7 +7534,7 @@ var dataStructureTyped = (() => {
7534
7534
  return "MAL_NODE" /* MAL_NODE */;
7535
7535
  }
7536
7536
  };
7537
- var BinaryTree = class _BinaryTree extends IterablePairBase {
7537
+ var BinaryTree = class _BinaryTree extends IterableEntryBase {
7538
7538
  /**
7539
7539
  * The constructor function initializes a binary tree object with optional elements and options.
7540
7540
  * @param [elements] - An optional iterable of BTNodeExemplar objects. These objects represent the
@@ -7601,31 +7601,32 @@ var dataStructureTyped = (() => {
7601
7601
  return exemplar instanceof BinaryTreeNode;
7602
7602
  }
7603
7603
  /**
7604
- * The function `exemplarToNode` converts an exemplar of a binary tree node into an actual node
7605
- * object.
7606
- * @param exemplar - BTNodeExemplar<K, V,N> - A generic type representing the exemplar parameter of the
7607
- * function. It can be any type.
7608
- * @returns a value of type `N` (which represents a node), or `null`, or `undefined`.
7604
+ * The function `exemplarToNode` converts an exemplar object into a node object.
7605
+ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
7606
+ * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
7607
+ * `exemplarToNode` function. It represents the value associated with the exemplar node. If no value
7608
+ * is provided, it will be `undefined`.
7609
+ * @returns a value of type N (node), or null, or undefined.
7609
7610
  */
7610
- exemplarToNode(exemplar) {
7611
+ exemplarToNode(exemplar, value) {
7611
7612
  if (exemplar === void 0)
7612
7613
  return;
7613
7614
  let node;
7614
7615
  if (exemplar === null) {
7615
7616
  node = null;
7616
7617
  } else if (this.isEntry(exemplar)) {
7617
- const [key, value] = exemplar;
7618
+ const [key, value2] = exemplar;
7618
7619
  if (key === void 0) {
7619
7620
  return;
7620
7621
  } else if (key === null) {
7621
7622
  node = null;
7622
7623
  } else {
7623
- node = this.createNode(key, value);
7624
+ node = this.createNode(key, value2);
7624
7625
  }
7625
7626
  } else if (this.isNode(exemplar)) {
7626
7627
  node = exemplar;
7627
7628
  } else if (this.isNotNodeInstance(exemplar)) {
7628
- node = this.createNode(exemplar);
7629
+ node = this.createNode(exemplar, value);
7629
7630
  } else {
7630
7631
  return;
7631
7632
  }
@@ -7648,13 +7649,15 @@ var dataStructureTyped = (() => {
7648
7649
  * Time Complexity O(log n) - O(n)
7649
7650
  * Space Complexity O(1)
7650
7651
  *
7651
- * The `add` function adds a new node to a binary tree, either by key or by providing a node object.
7652
- * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be one of the following:
7653
- * @returns The function `add` returns the inserted node (`N`), `null`, or `undefined`.
7652
+ * The `add` function adds a new node to a binary tree, either by creating a new node or replacing an
7653
+ * existing node with the same key.
7654
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
7655
+ * @param {V} [value] - The value to be inserted into the binary tree.
7656
+ * @returns The function `add` returns either a node (`N`), `null`, or `undefined`.
7654
7657
  */
7655
- add(keyOrNodeOrEntry) {
7658
+ add(keyOrNodeOrEntry, value) {
7656
7659
  let inserted;
7657
- const newNode = this.exemplarToNode(keyOrNodeOrEntry);
7660
+ const newNode = this.exemplarToNode(keyOrNodeOrEntry, value);
7658
7661
  if (newNode === void 0)
7659
7662
  return;
7660
7663
  const _bfs = (root, newNode2) => {
@@ -7696,17 +7699,27 @@ var dataStructureTyped = (() => {
7696
7699
  * Time Complexity: O(k log n) - O(k * n)
7697
7700
  * Space Complexity: O(1)
7698
7701
  *
7699
- * The function `addMany` takes in an iterable of `BTNodeExemplar` objects, adds each object to the
7700
- * current instance, and returns an array of the inserted nodes.
7701
- * @param nodes - The `nodes` parameter is an iterable (such as an array or a set) of
7702
- * `BTNodeExemplar<K, V,N>` objects.
7703
- * @returns The function `addMany` returns an array of values, where each value is either of type
7704
- * `N`, `null`, or `undefined`.
7702
+ * The `addMany` function takes in a collection of nodes and an optional collection of values, and
7703
+ * adds each node with its corresponding value to the data structure.
7704
+ * @param nodes - An iterable collection of BTNodeExemplar objects.
7705
+ * @param [values] - An optional iterable of values that will be assigned to each node being added.
7706
+ * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
7705
7707
  */
7706
- addMany(nodes) {
7708
+ addMany(nodes, values) {
7707
7709
  const inserted = [];
7710
+ let valuesIterator;
7711
+ if (values) {
7712
+ valuesIterator = values[Symbol.iterator]();
7713
+ }
7708
7714
  for (const kne of nodes) {
7709
- inserted.push(this.add(kne));
7715
+ let value = void 0;
7716
+ if (valuesIterator) {
7717
+ const valueResult = valuesIterator.next();
7718
+ if (!valueResult.done) {
7719
+ value = valueResult.value;
7720
+ }
7721
+ }
7722
+ inserted.push(this.add(kne, value));
7710
7723
  }
7711
7724
  return inserted;
7712
7725
  }
@@ -9199,26 +9212,28 @@ var dataStructureTyped = (() => {
9199
9212
  return exemplar instanceof BSTNode;
9200
9213
  }
9201
9214
  /**
9202
- * The function `exemplarToNode` takes an exemplar and returns a corresponding node if the exemplar
9203
- * is valid, otherwise it returns undefined.
9204
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
9205
- * @returns a variable `node` which is of type `N` or `undefined`.
9215
+ * The function `exemplarToNode` takes an exemplar and returns a node if the exemplar is valid,
9216
+ * otherwise it returns undefined.
9217
+ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
9218
+ * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
9219
+ * `exemplarToNode` function. It represents the value associated with the exemplar node.
9220
+ * @returns a node of type N or undefined.
9206
9221
  */
9207
- exemplarToNode(exemplar) {
9222
+ exemplarToNode(exemplar, value) {
9208
9223
  let node;
9209
9224
  if (exemplar === null || exemplar === void 0) {
9210
9225
  return;
9211
9226
  } else if (this.isNode(exemplar)) {
9212
9227
  node = exemplar;
9213
9228
  } else if (this.isEntry(exemplar)) {
9214
- const [key, value] = exemplar;
9229
+ const [key, value2] = exemplar;
9215
9230
  if (key === void 0 || key === null) {
9216
9231
  return;
9217
9232
  } else {
9218
- node = this.createNode(key, value);
9233
+ node = this.createNode(key, value2);
9219
9234
  }
9220
9235
  } else if (this.isNotNodeInstance(exemplar)) {
9221
- node = this.createNode(exemplar);
9236
+ node = this.createNode(exemplar, value);
9222
9237
  } else {
9223
9238
  return;
9224
9239
  }
@@ -9232,14 +9247,16 @@ var dataStructureTyped = (() => {
9232
9247
  * Time Complexity: O(log n) - Average case for a balanced tree. In the worst case (unbalanced tree), it can be O(n).
9233
9248
  * Space Complexity: O(1) - Constant space is used.
9234
9249
  *
9235
- * The `add` function adds a new node to a binary search tree, either by key or by providing a node
9236
- * object.
9237
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
9238
- * @returns The method returns either the newly added node (`newNode`) or `undefined` if the input
9239
- * (`keyOrNodeOrEntry`) is null, undefined, or does not match any of the expected types.
9250
+ * The `add` function adds a new node to a binary tree, updating the value if the key already exists
9251
+ * or inserting a new node if the key is unique.
9252
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values:
9253
+ * @param {V} [value] - The `value` parameter represents the value associated with the key that is
9254
+ * being added to the binary tree.
9255
+ * @returns The method `add` returns either the newly added node (`newNode`) or `undefined` if the
9256
+ * node was not added.
9240
9257
  */
9241
- add(keyOrNodeOrEntry) {
9242
- const newNode = this.exemplarToNode(keyOrNodeOrEntry);
9258
+ add(keyOrNodeOrEntry, value) {
9259
+ const newNode = this.exemplarToNode(keyOrNodeOrEntry, value);
9243
9260
  if (newNode === void 0)
9244
9261
  return;
9245
9262
  if (this.root === void 0) {
@@ -9280,23 +9297,32 @@ var dataStructureTyped = (() => {
9280
9297
  * Time Complexity: O(k log n) - Adding each element individually in a balanced tree.
9281
9298
  * Space Complexity: O(k) - Additional space is required for the sorted array.
9282
9299
  *
9283
- * The `addMany` function in TypeScript adds multiple nodes to a binary tree, either in a balanced or
9284
- * unbalanced manner, and returns an array of the inserted nodes.
9285
- * @param keysOrNodesOrEntries - An iterable containing keys, nodes, or entries to be added to the
9286
- * binary tree.
9287
- * @param [isBalanceAdd=true] - A boolean flag indicating whether the tree should be balanced after
9288
- * adding the nodes. The default value is true.
9300
+ * The `addMany` function in TypeScript adds multiple keys or nodes to a binary tree, optionally
9301
+ * balancing the tree after each addition.
9302
+ * @param keysOrNodesOrEntries - An iterable containing the keys, nodes, or entries to be added to
9303
+ * the binary tree.
9304
+ * @param [values] - An optional iterable of values to be associated with the keys or nodes being
9305
+ * added. If provided, the values will be assigned to the corresponding keys or nodes in the same
9306
+ * order. If not provided, undefined will be assigned as the value for each key or node.
9307
+ * @param [isBalanceAdd=true] - A boolean flag indicating whether the add operation should be
9308
+ * balanced or not. If set to true, the add operation will be balanced using a binary search tree
9309
+ * algorithm. If set to false, the add operation will not be balanced and the elements will be added
9310
+ * in the order they appear in the input.
9289
9311
  * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
9290
- * type of iteration to use when adding multiple keys or nodes to the binary tree. It has a default
9291
- * value of `this.iterationType`, which means it will use the iteration type specified by the binary
9292
- * tree instance.
9293
- * @returns The `addMany` function returns an array of `N` or `undefined` values.
9312
+ * type of iteration to use when adding multiple keys or nodes. It has a default value of
9313
+ * `this.iterationType`, which suggests that it is a property of the current object.
9314
+ * @returns The function `addMany` returns an array of nodes (`N`) or `undefined` values.
9294
9315
  */
9295
- addMany(keysOrNodesOrEntries, isBalanceAdd = true, iterationType = this.iterationType) {
9316
+ addMany(keysOrNodesOrEntries, values, isBalanceAdd = true, iterationType = this.iterationType) {
9296
9317
  const inserted = [];
9318
+ let valuesIterator;
9319
+ if (values) {
9320
+ valuesIterator = values[Symbol.iterator]();
9321
+ }
9297
9322
  if (!isBalanceAdd) {
9298
9323
  for (const kve of keysOrNodesOrEntries) {
9299
- const nn = this.add(kve);
9324
+ const value = valuesIterator == null ? void 0 : valuesIterator.next().value;
9325
+ const nn = this.add(kve, value);
9300
9326
  inserted.push(nn);
9301
9327
  }
9302
9328
  return inserted;
@@ -10217,14 +10243,16 @@ var dataStructureTyped = (() => {
10217
10243
  *
10218
10244
  * The function overrides the add method of a binary tree node and balances the tree after inserting
10219
10245
  * a new node.
10220
- * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be either a key, a node, or an
10246
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
10221
10247
  * entry.
10222
- * @returns The method is returning either the inserted node or `undefined`.
10248
+ * @param {V} [value] - The `value` parameter represents the value associated with the key that is
10249
+ * being added to the binary tree.
10250
+ * @returns The method is returning either the inserted node or undefined.
10223
10251
  */
10224
- add(keyOrNodeOrEntry) {
10252
+ add(keyOrNodeOrEntry, value) {
10225
10253
  if (keyOrNodeOrEntry === null)
10226
10254
  return void 0;
10227
- const inserted = super.add(keyOrNodeOrEntry);
10255
+ const inserted = super.add(keyOrNodeOrEntry, value);
10228
10256
  if (inserted)
10229
10257
  this._balancePath(inserted);
10230
10258
  return inserted;
@@ -10637,28 +10665,28 @@ var dataStructureTyped = (() => {
10637
10665
  return exemplar instanceof RedBlackTreeNode;
10638
10666
  }
10639
10667
  /**
10640
- * The function `exemplarToNode` takes an exemplar and returns a node if the exemplar is valid,
10641
- * otherwise it returns undefined.
10642
- * @param exemplar - BTNodeExemplar<K, V, N> - A generic type representing an exemplar of a binary tree
10643
- * node. It can be either a node itself, an entry (key-value pair), a node key, or any other value
10644
- * that is not a valid exemplar.
10645
- * @returns a variable `node` which is of type `N | undefined`.
10668
+ * The function `exemplarToNode` takes an exemplar and converts it into a node object if possible.
10669
+ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
10670
+ * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
10671
+ * `exemplarToNode` function. It represents the value associated with the exemplar node. If a value
10672
+ * is provided, it will be used when creating the new node. If no value is provided, the new node
10673
+ * @returns a node of type N or undefined.
10646
10674
  */
10647
- exemplarToNode(exemplar) {
10675
+ exemplarToNode(exemplar, value) {
10648
10676
  let node;
10649
10677
  if (exemplar === null || exemplar === void 0) {
10650
10678
  return;
10651
10679
  } else if (this.isNode(exemplar)) {
10652
10680
  node = exemplar;
10653
10681
  } else if (this.isEntry(exemplar)) {
10654
- const [key, value] = exemplar;
10682
+ const [key, value2] = exemplar;
10655
10683
  if (key === void 0 || key === null) {
10656
10684
  return;
10657
10685
  } else {
10658
- node = this.createNode(key, value, 1 /* RED */);
10686
+ node = this.createNode(key, value2, 1 /* RED */);
10659
10687
  }
10660
10688
  } else if (this.isNotNodeInstance(exemplar)) {
10661
- node = this.createNode(exemplar, void 0, 1 /* RED */);
10689
+ node = this.createNode(exemplar, value, 1 /* RED */);
10662
10690
  } else {
10663
10691
  return;
10664
10692
  }
@@ -10669,13 +10697,19 @@ var dataStructureTyped = (() => {
10669
10697
  * Space Complexity: O(1)
10670
10698
  */
10671
10699
  /**
10672
- * The function adds a node to a Red-Black Tree data structure.
10673
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
10674
- * @returns The method `add` returns either an instance of `N` (the node that was added) or
10675
- * `undefined`.
10700
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
10701
+ * Space Complexity: O(1)
10702
+ *
10703
+ * The `add` function adds a new node to a binary search tree and performs necessary rotations and
10704
+ * color changes to maintain the red-black tree properties.
10705
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
10706
+ * entry.
10707
+ * @param {V} [value] - The `value` parameter represents the value associated with the key that is
10708
+ * being added to the binary search tree.
10709
+ * @returns The method `add` returns either the newly added node (`N`) or `undefined`.
10676
10710
  */
10677
- add(keyOrNodeOrEntry) {
10678
- const newNode = this.exemplarToNode(keyOrNodeOrEntry);
10711
+ add(keyOrNodeOrEntry, value) {
10712
+ const newNode = this.exemplarToNode(keyOrNodeOrEntry, value);
10679
10713
  if (newNode === void 0)
10680
10714
  return;
10681
10715
  newNode.left = this.Sentinel;
@@ -11176,27 +11210,30 @@ var dataStructureTyped = (() => {
11176
11210
  }
11177
11211
  /**
11178
11212
  * The function `exemplarToNode` converts an exemplar object into a node object.
11179
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where `V` represents
11180
- * the value type and `N` represents the node type.
11213
+ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, which means it
11214
+ * can be one of the following:
11215
+ * @param {V} [value] - The `value` parameter is an optional argument that represents the value
11216
+ * associated with the node. It is of type `V`, which can be any data type. If no value is provided,
11217
+ * it defaults to `undefined`.
11181
11218
  * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
11182
- * times the node should be created. If not provided, it defaults to 1.
11183
- * @returns a value of type `N` (the generic type parameter) or `undefined`.
11219
+ * times the value should be added to the node. If not provided, it defaults to 1.
11220
+ * @returns a node of type `N` or `undefined`.
11184
11221
  */
11185
- exemplarToNode(exemplar, count = 1) {
11222
+ exemplarToNode(exemplar, value, count = 1) {
11186
11223
  let node;
11187
11224
  if (exemplar === void 0 || exemplar === null) {
11188
11225
  return;
11189
11226
  } else if (this.isNode(exemplar)) {
11190
11227
  node = exemplar;
11191
11228
  } else if (this.isEntry(exemplar)) {
11192
- const [key, value] = exemplar;
11229
+ const [key, value2] = exemplar;
11193
11230
  if (key === void 0 || key === null) {
11194
11231
  return;
11195
11232
  } else {
11196
- node = this.createNode(key, value, count);
11233
+ node = this.createNode(key, value2, count);
11197
11234
  }
11198
11235
  } else if (this.isNotNodeInstance(exemplar)) {
11199
- node = this.createNode(exemplar, void 0, count);
11236
+ node = this.createNode(exemplar, value, count);
11200
11237
  } else {
11201
11238
  return;
11202
11239
  }
@@ -11210,16 +11247,20 @@ var dataStructureTyped = (() => {
11210
11247
  * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.
11211
11248
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
11212
11249
  *
11213
- * The `add` function overrides the base class `add` function to add a new node to the tree multimap
11214
- * and update the count.
11215
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
11216
- * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
11217
- * times the key or node or entry should be added to the multimap. If not provided, the default value
11218
- * is 1.
11219
- * @returns either a node (`N`) or `undefined`.
11220
- */
11221
- add(keyOrNodeOrEntry, count = 1) {
11222
- const newNode = this.exemplarToNode(keyOrNodeOrEntry, count);
11250
+ * The function overrides the add method of a binary tree node and adds a new node to the tree.
11251
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
11252
+ * entry. It represents the key, node, or entry that you want to add to the binary tree.
11253
+ * @param {V} [value] - The `value` parameter represents the value associated with the key in the
11254
+ * binary tree node. It is an optional parameter, meaning it can be omitted when calling the `add`
11255
+ * method.
11256
+ * @param [count=1] - The `count` parameter represents the number of times the key-value pair should
11257
+ * be added to the binary tree. By default, it is set to 1, meaning that the key-value pair will be
11258
+ * added once. However, you can specify a different value for `count` if you want to add
11259
+ * @returns The method is returning either the newly inserted node or `undefined` if the insertion
11260
+ * was not successful.
11261
+ */
11262
+ add(keyOrNodeOrEntry, value, count = 1) {
11263
+ const newNode = this.exemplarToNode(keyOrNodeOrEntry, value, count);
11223
11264
  if (newNode === void 0)
11224
11265
  return;
11225
11266
  const orgNodeCount = (newNode == null ? void 0 : newNode.count) || 0;
@@ -11272,7 +11313,7 @@ var dataStructureTyped = (() => {
11272
11313
  return;
11273
11314
  const m = l + Math.floor((r - l) / 2);
11274
11315
  const midNode = sorted[m];
11275
- this.add([midNode.key, midNode.value], midNode.count);
11316
+ this.add(midNode.key, midNode.value, midNode.count);
11276
11317
  buildBalanceBST(l, m - 1);
11277
11318
  buildBalanceBST(m + 1, r);
11278
11319
  };
@@ -11287,7 +11328,7 @@ var dataStructureTyped = (() => {
11287
11328
  if (l <= r) {
11288
11329
  const m = l + Math.floor((r - l) / 2);
11289
11330
  const midNode = sorted[m];
11290
- this.add([midNode.key, midNode.value], midNode.count);
11331
+ this.add(midNode.key, midNode.value, midNode.count);
11291
11332
  stack.push([m + 1, r]);
11292
11333
  stack.push([l, m - 1]);
11293
11334
  }
@@ -11395,7 +11436,7 @@ var dataStructureTyped = (() => {
11395
11436
  */
11396
11437
  clone() {
11397
11438
  const cloned = this.createTree();
11398
- this.bfs((node) => cloned.add([node.key, node.value], node.count));
11439
+ this.bfs((node) => cloned.add(node.key, node.value, node.count));
11399
11440
  return cloned;
11400
11441
  }
11401
11442
  /**