data-structure-typed 2.0.0 → 2.0.1

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 (67) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/cjs/data-structures/graph/abstract-graph.js +14 -14
  3. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  4. package/dist/cjs/data-structures/hash/hash-map.d.ts +46 -0
  5. package/dist/cjs/data-structures/hash/hash-map.js +46 -0
  6. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  7. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +66 -0
  8. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +66 -0
  9. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  10. package/dist/cjs/data-structures/queue/queue.d.ts +47 -0
  11. package/dist/cjs/data-structures/queue/queue.js +47 -0
  12. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  13. package/dist/cjs/data-structures/stack/stack.d.ts +121 -0
  14. package/dist/cjs/data-structures/stack/stack.js +121 -0
  15. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  16. package/dist/esm/data-structures/graph/abstract-graph.js +14 -14
  17. package/dist/esm/data-structures/graph/abstract-graph.js.map +1 -1
  18. package/dist/esm/data-structures/hash/hash-map.d.ts +46 -0
  19. package/dist/esm/data-structures/hash/hash-map.js +46 -0
  20. package/dist/esm/data-structures/hash/hash-map.js.map +1 -1
  21. package/dist/esm/data-structures/linked-list/singly-linked-list.d.ts +66 -0
  22. package/dist/esm/data-structures/linked-list/singly-linked-list.js +66 -0
  23. package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +1 -1
  24. package/dist/esm/data-structures/queue/queue.d.ts +47 -0
  25. package/dist/esm/data-structures/queue/queue.js +47 -0
  26. package/dist/esm/data-structures/queue/queue.js.map +1 -1
  27. package/dist/esm/data-structures/stack/stack.d.ts +121 -0
  28. package/dist/esm/data-structures/stack/stack.js +121 -0
  29. package/dist/esm/data-structures/stack/stack.js.map +1 -1
  30. package/dist/individuals/binary-tree/avl-tree-counter.mjs +4701 -0
  31. package/dist/individuals/binary-tree/avl-tree-multi-map.mjs +4514 -0
  32. package/dist/individuals/binary-tree/avl-tree.mjs +4321 -0
  33. package/dist/individuals/binary-tree/binary-tree.mjs +3097 -0
  34. package/dist/individuals/binary-tree/bst.mjs +3858 -0
  35. package/dist/individuals/binary-tree/red-black-tree.mjs +4391 -0
  36. package/dist/individuals/binary-tree/tree-counter.mjs +4806 -0
  37. package/dist/individuals/binary-tree/tree-multi-map.mjs +4582 -0
  38. package/dist/individuals/graph/directed-graph.mjs +2910 -0
  39. package/dist/individuals/graph/undirected-graph.mjs +2745 -0
  40. package/dist/individuals/hash/hash-map.mjs +1040 -0
  41. package/dist/individuals/heap/heap.mjs +909 -0
  42. package/dist/individuals/heap/max-heap.mjs +671 -0
  43. package/dist/individuals/heap/min-heap.mjs +659 -0
  44. package/dist/individuals/linked-list/doubly-linked-list.mjs +1495 -0
  45. package/dist/individuals/linked-list/singly-linked-list.mjs +1479 -0
  46. package/dist/individuals/priority-queue/max-priority-queue.mjs +768 -0
  47. package/dist/individuals/priority-queue/min-priority-queue.mjs +757 -0
  48. package/dist/individuals/priority-queue/priority-queue.mjs +670 -0
  49. package/dist/individuals/queue/deque.mjs +1262 -0
  50. package/dist/individuals/queue/queue.mjs +1865 -0
  51. package/dist/individuals/stack/stack.mjs +415 -0
  52. package/dist/individuals/trie/trie.mjs +687 -0
  53. package/dist/umd/data-structure-typed.js +14 -14
  54. package/dist/umd/data-structure-typed.min.js +2 -2
  55. package/dist/umd/data-structure-typed.min.js.map +1 -1
  56. package/package.json +2 -2
  57. package/src/data-structures/graph/abstract-graph.ts +14 -14
  58. package/src/data-structures/hash/hash-map.ts +46 -0
  59. package/src/data-structures/linked-list/singly-linked-list.ts +66 -0
  60. package/src/data-structures/queue/queue.ts +47 -0
  61. package/src/data-structures/stack/stack.ts +121 -0
  62. package/test/unit/data-structures/graph/directed-graph.test.ts +37 -37
  63. package/test/unit/data-structures/graph/undirected-graph.test.ts +2 -2
  64. package/test/unit/data-structures/hash/hash-map.test.ts +135 -0
  65. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +72 -1
  66. package/test/unit/data-structures/queue/queue.test.ts +214 -0
  67. package/test/unit/data-structures/stack/stack.test.ts +165 -0
@@ -6256,7 +6256,7 @@ var dataStructureTyped = (() => {
6256
6256
  if (isWeight === void 0) isWeight = false;
6257
6257
  if (isWeight) {
6258
6258
  const allPaths = this.getAllPathsBetween(v1, v2);
6259
- let min = Infinity;
6259
+ let min = Number.MAX_SAFE_INTEGER;
6260
6260
  for (const path of allPaths) {
6261
6261
  min = Math.min(this.getPathSumWeight(path), min);
6262
6262
  }
@@ -6317,7 +6317,7 @@ var dataStructureTyped = (() => {
6317
6317
  if (isWeight) {
6318
6318
  if (isDFS) {
6319
6319
  const allPaths = this.getAllPathsBetween(v1, v2, 1e4);
6320
- let min = Infinity;
6320
+ let min = Number.MAX_SAFE_INTEGER;
6321
6321
  let minIndex = -1;
6322
6322
  let index = 0;
6323
6323
  for (const path of allPaths) {
@@ -6377,7 +6377,7 @@ var dataStructureTyped = (() => {
6377
6377
  * @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.
6378
6378
  */
6379
6379
  dijkstraWithoutHeap(src, dest = void 0, getMinDist = false, genPaths = false) {
6380
- let minDist = Infinity;
6380
+ let minDist = Number.MAX_SAFE_INTEGER;
6381
6381
  let minDest = void 0;
6382
6382
  let minPath = [];
6383
6383
  const paths = [];
@@ -6392,12 +6392,12 @@ var dataStructureTyped = (() => {
6392
6392
  }
6393
6393
  for (const vertex of vertexMap) {
6394
6394
  const vertexOrKey = vertex[1];
6395
- if (vertexOrKey instanceof AbstractVertex) distMap.set(vertexOrKey, Infinity);
6395
+ if (vertexOrKey instanceof AbstractVertex) distMap.set(vertexOrKey, Number.MAX_SAFE_INTEGER);
6396
6396
  }
6397
6397
  distMap.set(srcVertex, 0);
6398
6398
  preMap.set(srcVertex, void 0);
6399
6399
  const getMinOfNoSeen = () => {
6400
- let min = Infinity;
6400
+ let min = Number.MAX_SAFE_INTEGER;
6401
6401
  let minV = void 0;
6402
6402
  for (const [key, value] of distMap) {
6403
6403
  if (!seen.has(key)) {
@@ -6431,7 +6431,7 @@ var dataStructureTyped = (() => {
6431
6431
  seen.add(cur);
6432
6432
  if (destVertex && destVertex === cur) {
6433
6433
  if (getMinDist) {
6434
- minDist = distMap.get(destVertex) || Infinity;
6434
+ minDist = distMap.get(destVertex) || Number.MAX_SAFE_INTEGER;
6435
6435
  }
6436
6436
  if (genPaths) {
6437
6437
  getPaths(destVertex);
@@ -6490,7 +6490,7 @@ var dataStructureTyped = (() => {
6490
6490
  */
6491
6491
  dijkstra(src, dest = void 0, getMinDist = false, genPaths = false) {
6492
6492
  var _a;
6493
- let minDist = Infinity;
6493
+ let minDist = Number.MAX_SAFE_INTEGER;
6494
6494
  let minDest = void 0;
6495
6495
  let minPath = [];
6496
6496
  const paths = [];
@@ -6503,7 +6503,7 @@ var dataStructureTyped = (() => {
6503
6503
  if (!srcVertex) return void 0;
6504
6504
  for (const vertex of vertexMap) {
6505
6505
  const vertexOrKey = vertex[1];
6506
- if (vertexOrKey instanceof AbstractVertex) distMap.set(vertexOrKey, Infinity);
6506
+ if (vertexOrKey instanceof AbstractVertex) distMap.set(vertexOrKey, Number.MAX_SAFE_INTEGER);
6507
6507
  }
6508
6508
  const heap = new Heap([], { comparator: (a, b) => a.key - b.key });
6509
6509
  heap.add({ key: 0, value: srcVertex });
@@ -6534,7 +6534,7 @@ var dataStructureTyped = (() => {
6534
6534
  seen.add(cur);
6535
6535
  if (destVertex && destVertex === cur) {
6536
6536
  if (getMinDist) {
6537
- minDist = distMap.get(destVertex) || Infinity;
6537
+ minDist = distMap.get(destVertex) || Number.MAX_SAFE_INTEGER;
6538
6538
  }
6539
6539
  if (genPaths) {
6540
6540
  getPaths(destVertex);
@@ -6600,7 +6600,7 @@ var dataStructureTyped = (() => {
6600
6600
  const paths = [];
6601
6601
  const distMap = /* @__PURE__ */ new Map();
6602
6602
  const preMap = /* @__PURE__ */ new Map();
6603
- let min = Infinity;
6603
+ let min = Number.MAX_SAFE_INTEGER;
6604
6604
  let minPath = [];
6605
6605
  let hasNegativeCycle;
6606
6606
  if (scanNegativeCycle) hasNegativeCycle = false;
@@ -6610,7 +6610,7 @@ var dataStructureTyped = (() => {
6610
6610
  const edgeMap = this.edgeSet();
6611
6611
  const numOfEdges = edgeMap.length;
6612
6612
  this._vertexMap.forEach((vertex) => {
6613
- distMap.set(vertex, Infinity);
6613
+ distMap.set(vertex, Number.MAX_SAFE_INTEGER);
6614
6614
  });
6615
6615
  distMap.set(srcVertex, 0);
6616
6616
  for (let i = 1; i < numOfVertices; ++i) {
@@ -6622,7 +6622,7 @@ var dataStructureTyped = (() => {
6622
6622
  const sWeight = distMap.get(s);
6623
6623
  const dWeight = distMap.get(d);
6624
6624
  if (sWeight !== void 0 && dWeight !== void 0) {
6625
- if (distMap.get(s) !== Infinity && sWeight + weight < dWeight) {
6625
+ if (distMap.get(s) !== Number.MAX_SAFE_INTEGER && sWeight + weight < dWeight) {
6626
6626
  distMap.set(d, sWeight + weight);
6627
6627
  if (genPath) preMap.set(d, s);
6628
6628
  }
@@ -6664,7 +6664,7 @@ var dataStructureTyped = (() => {
6664
6664
  const weight = edgeMap[j].weight;
6665
6665
  const sWeight = distMap.get(s);
6666
6666
  if (sWeight) {
6667
- if (sWeight !== Infinity && sWeight + weight < sWeight) hasNegativeCycle = true;
6667
+ if (sWeight !== Number.MAX_SAFE_INTEGER && sWeight + weight < sWeight) hasNegativeCycle = true;
6668
6668
  }
6669
6669
  }
6670
6670
  }
@@ -6712,7 +6712,7 @@ var dataStructureTyped = (() => {
6712
6712
  }
6713
6713
  for (let i = 0; i < n; i++) {
6714
6714
  for (let j = 0; j < n; j++) {
6715
- costs[i][j] = ((_a = this.getEdge(idAndVertices[i][1], idAndVertices[j][1])) == null ? void 0 : _a.weight) || Infinity;
6715
+ costs[i][j] = ((_a = this.getEdge(idAndVertices[i][1], idAndVertices[j][1])) == null ? void 0 : _a.weight) || Number.MAX_SAFE_INTEGER;
6716
6716
  }
6717
6717
  }
6718
6718
  for (let k = 0; k < n; k++) {