data-structure-typed 1.43.0 → 1.43.3

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 (71) hide show
  1. package/.eslintrc.js +3 -1
  2. package/CHANGELOG.md +1 -1
  3. package/README.md +28 -12
  4. package/benchmark/report.html +33 -24
  5. package/benchmark/report.json +224 -125
  6. package/dist/cjs/src/data-structures/binary-tree/avl-tree.js.map +1 -1
  7. package/dist/cjs/src/data-structures/binary-tree/binary-tree.d.ts +8 -8
  8. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js +62 -62
  9. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js.map +1 -1
  10. package/dist/cjs/src/data-structures/binary-tree/bst.js.map +1 -1
  11. package/dist/cjs/src/data-structures/binary-tree/rb-tree.d.ts +4 -4
  12. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js +1 -1
  13. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js.map +1 -1
  14. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.d.ts +24 -24
  15. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js +50 -50
  16. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js.map +1 -1
  17. package/dist/cjs/src/data-structures/graph/abstract-graph.d.ts +37 -37
  18. package/dist/cjs/src/data-structures/graph/abstract-graph.js +37 -37
  19. package/dist/cjs/src/data-structures/graph/abstract-graph.js.map +1 -1
  20. package/dist/cjs/src/data-structures/graph/directed-graph.js.map +1 -1
  21. package/dist/cjs/src/data-structures/graph/map-graph.js.map +1 -1
  22. package/dist/cjs/src/data-structures/graph/undirected-graph.js.map +1 -1
  23. package/dist/cjs/src/data-structures/heap/heap.js.map +1 -1
  24. package/dist/cjs/src/interfaces/binary-tree.d.ts +1 -1
  25. package/dist/mjs/src/data-structures/binary-tree/binary-tree.d.ts +8 -8
  26. package/dist/mjs/src/data-structures/binary-tree/binary-tree.js +62 -62
  27. package/dist/mjs/src/data-structures/binary-tree/rb-tree.d.ts +4 -4
  28. package/dist/mjs/src/data-structures/binary-tree/rb-tree.js +1 -1
  29. package/dist/mjs/src/data-structures/binary-tree/tree-multimap.d.ts +24 -24
  30. package/dist/mjs/src/data-structures/binary-tree/tree-multimap.js +50 -50
  31. package/dist/mjs/src/data-structures/graph/abstract-graph.d.ts +37 -37
  32. package/dist/mjs/src/data-structures/graph/abstract-graph.js +37 -37
  33. package/dist/mjs/src/interfaces/binary-tree.d.ts +1 -1
  34. package/dist/umd/data-structure-typed.js +10497 -0
  35. package/dist/umd/data-structure-typed.min.js +1 -1
  36. package/dist/umd/data-structure-typed.min.js.map +1 -1
  37. package/package.json +3 -2
  38. package/src/data-structures/binary-tree/avl-tree.ts +2 -3
  39. package/src/data-structures/binary-tree/binary-tree.ts +85 -92
  40. package/src/data-structures/binary-tree/bst.ts +14 -22
  41. package/src/data-structures/binary-tree/rb-tree.ts +11 -20
  42. package/src/data-structures/binary-tree/tree-multimap.ts +56 -58
  43. package/src/data-structures/graph/abstract-graph.ts +6 -22
  44. package/src/data-structures/graph/directed-graph.ts +3 -9
  45. package/src/data-structures/graph/map-graph.ts +6 -6
  46. package/src/data-structures/graph/undirected-graph.ts +1 -2
  47. package/src/data-structures/heap/heap.ts +1 -6
  48. package/src/data-structures/trie/trie.ts +1 -1
  49. package/src/interfaces/binary-tree.ts +1 -1
  50. package/src/types/utils/validate-type.ts +2 -16
  51. package/test/config.ts +2 -1
  52. package/test/integration/index.html +77 -12
  53. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +17 -5
  54. package/test/performance/data-structures/hash/hash-map.test.ts +48 -0
  55. package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +16 -5
  56. package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +1 -3
  57. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +35 -0
  58. package/test/performance/data-structures/queue/deque.test.ts +20 -11
  59. package/test/performance/data-structures/queue/queue.test.ts +20 -10
  60. package/test/performance/data-structures/stack/stack.test.ts +49 -0
  61. package/test/performance/reportor.ts +4 -5
  62. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +0 -1
  63. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +83 -61
  64. package/test/unit/data-structures/binary-tree/bst.test.ts +2 -6
  65. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +34 -25
  66. package/test/unit/data-structures/graph/abstract-graph.test.ts +6 -6
  67. package/test/unit/data-structures/graph/directed-graph.test.ts +8 -28
  68. package/test/unit/data-structures/heap/heap.test.ts +1 -8
  69. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +34 -12
  70. package/test/utils/json2html.ts +2 -6
  71. package/tsup.config.js +19 -1
@@ -417,24 +417,24 @@ class AbstractGraph {
417
417
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
418
418
  */
419
419
  /**
420
- * Time Complexity: O(V^2 + E) - Quadratic time in the worst case (no heap optimization).
421
- * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
422
- *
423
- * The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in
424
- * a graph without using a heap data structure.
425
- * @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
426
- * vertex object or a vertex ID.
427
- * @param {VO | VertexKey | null} [dest] - The `dest` parameter in the `dijkstraWithoutHeap` function is an optional
428
- * parameter that specifies the destination vertex for the Dijkstra algorithm. It can be either a vertex object or its
429
- * identifier. If no destination is provided, the value is set to `null`.
430
- * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
431
- * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
432
- * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
433
- * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
434
- * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
435
- * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
436
- * @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.
437
- */
420
+ * Time Complexity: O(V^2 + E) - Quadratic time in the worst case (no heap optimization).
421
+ * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
422
+ *
423
+ * The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in
424
+ * a graph without using a heap data structure.
425
+ * @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
426
+ * vertex object or a vertex ID.
427
+ * @param {VO | VertexKey | null} [dest] - The `dest` parameter in the `dijkstraWithoutHeap` function is an optional
428
+ * parameter that specifies the destination vertex for the Dijkstra algorithm. It can be either a vertex object or its
429
+ * identifier. If no destination is provided, the value is set to `null`.
430
+ * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
431
+ * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
432
+ * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
433
+ * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
434
+ * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
435
+ * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
436
+ * @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.
437
+ */
438
438
  dijkstraWithoutHeap(src, dest, getMinDist, genPaths) {
439
439
  if (getMinDist === undefined)
440
440
  getMinDist = false;
@@ -551,25 +551,25 @@ class AbstractGraph {
551
551
  * Space Complexity: O(V + E) - Depends on the implementation (using a binary heap).
552
552
  */
553
553
  /**
554
- * Time Complexity: O((V + E) * log(V)) - Depends on the implementation (using a binary heap).
555
- * Space Complexity: O(V + E) - Depends on the implementation (using a binary heap).
556
- *
557
- * Dijkstra's algorithm is used to find the shortest paths from a source node to all other nodes in a graph. Its basic idea is to repeatedly choose the node closest to the source node and update the distances of other nodes using this node as an intermediary. Dijkstra's algorithm requires that the edge weights in the graph are non-negative.
558
- * The `dijkstra` function implements Dijkstra's algorithm to find the shortest path between a source vertex and an
559
- * optional destination vertex, and optionally returns the minimum distance, the paths, and other information.
560
- * @param {VO | VertexKey} src - The `src` parameter represents the source vertex from which the Dijkstra algorithm will
561
- * start. It can be either a vertex object or a vertex ID.
562
- * @param {VO | VertexKey | null} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
563
- * vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
564
- * will calculate the shortest paths to all other vertices from the source vertex.
565
- * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
566
- * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
567
- * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
568
- * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
569
- * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
570
- * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
571
- * @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.
572
- */
554
+ * Time Complexity: O((V + E) * log(V)) - Depends on the implementation (using a binary heap).
555
+ * Space Complexity: O(V + E) - Depends on the implementation (using a binary heap).
556
+ *
557
+ * Dijkstra's algorithm is used to find the shortest paths from a source node to all other nodes in a graph. Its basic idea is to repeatedly choose the node closest to the source node and update the distances of other nodes using this node as an intermediary. Dijkstra's algorithm requires that the edge weights in the graph are non-negative.
558
+ * The `dijkstra` function implements Dijkstra's algorithm to find the shortest path between a source vertex and an
559
+ * optional destination vertex, and optionally returns the minimum distance, the paths, and other information.
560
+ * @param {VO | VertexKey} src - The `src` parameter represents the source vertex from which the Dijkstra algorithm will
561
+ * start. It can be either a vertex object or a vertex ID.
562
+ * @param {VO | VertexKey | null} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
563
+ * vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
564
+ * will calculate the shortest paths to all other vertices from the source vertex.
565
+ * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
566
+ * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
567
+ * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
568
+ * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
569
+ * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
570
+ * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
571
+ * @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.
572
+ */
573
573
  dijkstra(src, dest, getMinDist, genPaths) {
574
574
  if (getMinDist === undefined)
575
575
  getMinDist = false;
@@ -1,5 +1,5 @@
1
1
  import { BinaryTreeNode } from '../data-structures';
2
- import { BiTreeDeleteResult, BinaryTreeNodeNested, BTNCallback, BTNKey } from '../types';
2
+ import { BinaryTreeNodeNested, BiTreeDeleteResult, BTNCallback, BTNKey } from '../types';
3
3
  export interface IBinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNodeNested<V>> {
4
4
  createNode(key: BTNKey, value?: N['value']): N;
5
5
  add(keyOrNode: BTNKey | N | null, value?: N['value']): N | null | undefined;