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.
- package/CHANGELOG.md +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.js +14 -14
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +46 -0
- package/dist/cjs/data-structures/hash/hash-map.js +46 -0
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +66 -0
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +66 -0
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +47 -0
- package/dist/cjs/data-structures/queue/queue.js +47 -0
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/stack/stack.d.ts +121 -0
- package/dist/cjs/data-structures/stack/stack.js +121 -0
- package/dist/cjs/data-structures/stack/stack.js.map +1 -1
- package/dist/esm/data-structures/graph/abstract-graph.js +14 -14
- package/dist/esm/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/esm/data-structures/hash/hash-map.d.ts +46 -0
- package/dist/esm/data-structures/hash/hash-map.js +46 -0
- package/dist/esm/data-structures/hash/hash-map.js.map +1 -1
- package/dist/esm/data-structures/linked-list/singly-linked-list.d.ts +66 -0
- package/dist/esm/data-structures/linked-list/singly-linked-list.js +66 -0
- package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/esm/data-structures/queue/queue.d.ts +47 -0
- package/dist/esm/data-structures/queue/queue.js +47 -0
- package/dist/esm/data-structures/queue/queue.js.map +1 -1
- package/dist/esm/data-structures/stack/stack.d.ts +121 -0
- package/dist/esm/data-structures/stack/stack.js +121 -0
- package/dist/esm/data-structures/stack/stack.js.map +1 -1
- package/dist/individuals/binary-tree/avl-tree-counter.mjs +4701 -0
- package/dist/individuals/binary-tree/avl-tree-multi-map.mjs +4514 -0
- package/dist/individuals/binary-tree/avl-tree.mjs +4321 -0
- package/dist/individuals/binary-tree/binary-tree.mjs +3097 -0
- package/dist/individuals/binary-tree/bst.mjs +3858 -0
- package/dist/individuals/binary-tree/red-black-tree.mjs +4391 -0
- package/dist/individuals/binary-tree/tree-counter.mjs +4806 -0
- package/dist/individuals/binary-tree/tree-multi-map.mjs +4582 -0
- package/dist/individuals/graph/directed-graph.mjs +2910 -0
- package/dist/individuals/graph/undirected-graph.mjs +2745 -0
- package/dist/individuals/hash/hash-map.mjs +1040 -0
- package/dist/individuals/heap/heap.mjs +909 -0
- package/dist/individuals/heap/max-heap.mjs +671 -0
- package/dist/individuals/heap/min-heap.mjs +659 -0
- package/dist/individuals/linked-list/doubly-linked-list.mjs +1495 -0
- package/dist/individuals/linked-list/singly-linked-list.mjs +1479 -0
- package/dist/individuals/priority-queue/max-priority-queue.mjs +768 -0
- package/dist/individuals/priority-queue/min-priority-queue.mjs +757 -0
- package/dist/individuals/priority-queue/priority-queue.mjs +670 -0
- package/dist/individuals/queue/deque.mjs +1262 -0
- package/dist/individuals/queue/queue.mjs +1865 -0
- package/dist/individuals/stack/stack.mjs +415 -0
- package/dist/individuals/trie/trie.mjs +687 -0
- package/dist/umd/data-structure-typed.js +14 -14
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/graph/abstract-graph.ts +14 -14
- package/src/data-structures/hash/hash-map.ts +46 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +66 -0
- package/src/data-structures/queue/queue.ts +47 -0
- package/src/data-structures/stack/stack.ts +121 -0
- package/test/unit/data-structures/graph/directed-graph.test.ts +37 -37
- package/test/unit/data-structures/graph/undirected-graph.test.ts +2 -2
- package/test/unit/data-structures/hash/hash-map.test.ts +135 -0
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +72 -1
- package/test/unit/data-structures/queue/queue.test.ts +214 -0
- 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 =
|
|
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 =
|
|
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 =
|
|
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,
|
|
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 =
|
|
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) ||
|
|
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 =
|
|
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,
|
|
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) ||
|
|
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 =
|
|
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,
|
|
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) !==
|
|
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 !==
|
|
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) ||
|
|
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++) {
|