data-structure-typed 2.5.3 → 2.6.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/.github/workflows/ci.yml +7 -2
- package/.github/workflows/release-package.yml +9 -2
- package/.husky/pre-commit +3 -0
- package/CHANGELOG.md +1 -1
- package/MIGRATION.md +48 -0
- package/README.md +20 -2
- package/README_CN.md +20 -2
- package/SPECIFICATION.md +24 -0
- package/SPECIFICATION.zh-CN.md +24 -0
- package/dist/cjs/binary-tree.cjs +1897 -19
- package/dist/cjs/graph.cjs +174 -0
- package/dist/cjs/hash.cjs +33 -0
- package/dist/cjs/heap.cjs +71 -0
- package/dist/cjs/index.cjs +2383 -3
- package/dist/cjs/linked-list.cjs +224 -2
- package/dist/cjs/matrix.cjs +24 -0
- package/dist/cjs/priority-queue.cjs +71 -0
- package/dist/cjs/queue.cjs +221 -1
- package/dist/cjs/stack.cjs +59 -0
- package/dist/cjs/trie.cjs +62 -0
- package/dist/cjs-legacy/binary-tree.cjs +1897 -19
- package/dist/cjs-legacy/graph.cjs +174 -0
- package/dist/cjs-legacy/hash.cjs +33 -0
- package/dist/cjs-legacy/heap.cjs +71 -0
- package/dist/cjs-legacy/index.cjs +2383 -3
- package/dist/cjs-legacy/linked-list.cjs +224 -2
- package/dist/cjs-legacy/matrix.cjs +24 -0
- package/dist/cjs-legacy/priority-queue.cjs +71 -0
- package/dist/cjs-legacy/queue.cjs +221 -1
- package/dist/cjs-legacy/stack.cjs +59 -0
- package/dist/cjs-legacy/trie.cjs +62 -0
- package/dist/esm/binary-tree.mjs +1897 -19
- package/dist/esm/graph.mjs +174 -0
- package/dist/esm/hash.mjs +33 -0
- package/dist/esm/heap.mjs +71 -0
- package/dist/esm/index.mjs +2383 -3
- package/dist/esm/linked-list.mjs +224 -2
- package/dist/esm/matrix.mjs +24 -0
- package/dist/esm/priority-queue.mjs +71 -0
- package/dist/esm/queue.mjs +221 -1
- package/dist/esm/stack.mjs +59 -0
- package/dist/esm/trie.mjs +62 -0
- package/dist/esm-legacy/binary-tree.mjs +1897 -19
- package/dist/esm-legacy/graph.mjs +174 -0
- package/dist/esm-legacy/hash.mjs +33 -0
- package/dist/esm-legacy/heap.mjs +71 -0
- package/dist/esm-legacy/index.mjs +2383 -3
- package/dist/esm-legacy/linked-list.mjs +224 -2
- package/dist/esm-legacy/matrix.mjs +24 -0
- package/dist/esm-legacy/priority-queue.mjs +71 -0
- package/dist/esm-legacy/queue.mjs +221 -1
- package/dist/esm-legacy/stack.mjs +59 -0
- package/dist/esm-legacy/trie.mjs +62 -0
- package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
- package/dist/types/data-structures/base/linear-base.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +75 -0
- package/dist/types/data-structures/binary-tree/bst.d.ts +72 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +375 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +389 -0
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +330 -0
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +438 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
- package/dist/types/data-structures/heap/heap.d.ts +42 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
- package/dist/types/data-structures/queue/deque.d.ts +90 -1
- package/dist/types/data-structures/queue/queue.d.ts +36 -0
- package/dist/types/data-structures/stack/stack.d.ts +30 -0
- package/dist/types/data-structures/trie/trie.d.ts +36 -0
- package/dist/umd/data-structure-typed.js +2383 -3
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +108 -108
- package/docs-site-docusaurus/docs/api/classes/BST.md +101 -101
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +66 -66
- package/docs-site-docusaurus/docs/api/classes/Deque.md +235 -51
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +21 -21
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +231 -67
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +14 -14
- package/docs-site-docusaurus/docs/api/classes/Heap.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +83 -13
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +124 -20
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +140 -32
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +30 -26
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +159 -51
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +20 -20
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/Queue.md +142 -34
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +117 -117
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +158 -50
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +21 -21
- package/docs-site-docusaurus/docs/api/classes/Stack.md +108 -26
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +33 -33
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +75 -39
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +301 -39
- package/docs-site-docusaurus/docs/api/classes/Trie.md +110 -28
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +20 -20
- package/jest.integration.config.js +1 -2
- package/package.json +51 -50
- package/src/common/error.ts +15 -32
- package/src/common/index.ts +0 -3
- package/src/data-structures/base/iterable-element-base.ts +32 -3
- package/src/data-structures/base/linear-base.ts +13 -36
- package/src/data-structures/binary-tree/avl-tree.ts +31 -493
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -530
- package/src/data-structures/binary-tree/binary-tree.ts +326 -1236
- package/src/data-structures/binary-tree/bst.ts +158 -1010
- package/src/data-structures/binary-tree/red-black-tree.ts +451 -1233
- package/src/data-structures/binary-tree/segment-tree.ts +73 -333
- package/src/data-structures/binary-tree/tree-map.ts +462 -4749
- package/src/data-structures/binary-tree/tree-multi-map.ts +310 -4530
- package/src/data-structures/binary-tree/tree-multi-set.ts +300 -3652
- package/src/data-structures/binary-tree/tree-set.ts +437 -4443
- package/src/data-structures/graph/abstract-graph.ts +98 -167
- package/src/data-structures/graph/directed-graph.ts +137 -532
- package/src/data-structures/graph/map-graph.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +132 -484
- package/src/data-structures/hash/hash-map.ts +154 -549
- package/src/data-structures/heap/heap.ts +200 -753
- package/src/data-structures/linked-list/doubly-linked-list.ts +153 -809
- package/src/data-structures/linked-list/singly-linked-list.ts +122 -749
- package/src/data-structures/linked-list/skip-linked-list.ts +211 -864
- package/src/data-structures/matrix/matrix.ts +179 -494
- package/src/data-structures/matrix/navigator.ts +0 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
- package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
- package/src/data-structures/priority-queue/priority-queue.ts +1 -2
- package/src/data-structures/queue/deque.ts +241 -807
- package/src/data-structures/queue/queue.ts +102 -589
- package/src/data-structures/stack/stack.ts +76 -475
- package/src/data-structures/trie/trie.ts +98 -592
- package/src/types/common.ts +0 -10
- package/src/types/data-structures/binary-tree/bst.ts +0 -7
- package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
- package/src/types/data-structures/graph/abstract-graph.ts +0 -2
- package/src/types/data-structures/hash/hash-map.ts +0 -3
- package/src/types/data-structures/hash/index.ts +0 -1
- package/src/types/data-structures/matrix/navigator.ts +0 -2
- package/src/types/utils/utils.ts +0 -7
- package/src/types/utils/validate-type.ts +0 -7
- package/src/utils/number.ts +0 -2
- package/src/utils/utils.ts +0 -5
|
@@ -495,7 +495,7 @@ Time O(V * E), Space O(V + E)
|
|
|
495
495
|
clear(): void;
|
|
496
496
|
```
|
|
497
497
|
|
|
498
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
498
|
+
Defined in: [data-structures/graph/directed-graph.ts:968](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L968)
|
|
499
499
|
|
|
500
500
|
Remove all vertices and edges.
|
|
501
501
|
|
|
@@ -525,7 +525,7 @@ IGraph.clear
|
|
|
525
525
|
clone(): this;
|
|
526
526
|
```
|
|
527
527
|
|
|
528
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
528
|
+
Defined in: [data-structures/graph/directed-graph.ts:979](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L979)
|
|
529
529
|
|
|
530
530
|
Deep clone as the same concrete class.
|
|
531
531
|
|
|
@@ -665,7 +665,7 @@ IGraph.createVertex
|
|
|
665
665
|
degreeOf(vertexOrKey): number;
|
|
666
666
|
```
|
|
667
667
|
|
|
668
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
668
|
+
Defined in: [data-structures/graph/directed-graph.ts:641](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L641)
|
|
669
669
|
|
|
670
670
|
Degree (in + out) of a vertex.
|
|
671
671
|
|
|
@@ -705,7 +705,7 @@ IGraph.degreeOf
|
|
|
705
705
|
deleteEdge(edgeOrSrcVertexKey, destVertexKey?): EO | undefined;
|
|
706
706
|
```
|
|
707
707
|
|
|
708
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
708
|
+
Defined in: [data-structures/graph/directed-graph.ts:387](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L387)
|
|
709
709
|
|
|
710
710
|
Delete an edge by instance or by `(srcKey, destKey)`.
|
|
711
711
|
|
|
@@ -782,7 +782,7 @@ IGraph.deleteEdge
|
|
|
782
782
|
deleteEdgeSrcToDest(srcOrKey, destOrKey): EO | undefined;
|
|
783
783
|
```
|
|
784
784
|
|
|
785
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
785
|
+
Defined in: [data-structures/graph/directed-graph.ts:293](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L293)
|
|
786
786
|
|
|
787
787
|
Delete edge `src -> dest` if present.
|
|
788
788
|
|
|
@@ -818,7 +818,7 @@ Time O(1) avg, Space O(1)
|
|
|
818
818
|
deleteVertex(vertexOrKey): boolean;
|
|
819
819
|
```
|
|
820
820
|
|
|
821
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
821
|
+
Defined in: [data-structures/graph/directed-graph.ts:468](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L468)
|
|
822
822
|
|
|
823
823
|
Remove a vertex
|
|
824
824
|
|
|
@@ -921,7 +921,7 @@ Time O(V^2 + E), Space O(V + E)
|
|
|
921
921
|
edgeSet(): EO[];
|
|
922
922
|
```
|
|
923
923
|
|
|
924
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
924
|
+
Defined in: [data-structures/graph/directed-graph.ts:860](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L860)
|
|
925
925
|
|
|
926
926
|
Get all edges
|
|
927
927
|
|
|
@@ -960,7 +960,7 @@ IGraph.edgeSet
|
|
|
960
960
|
edgesOf(vertexOrKey): EO[];
|
|
961
961
|
```
|
|
962
962
|
|
|
963
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
963
|
+
Defined in: [data-structures/graph/directed-graph.ts:671](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L671)
|
|
964
964
|
|
|
965
965
|
All incident edges of a vertex.
|
|
966
966
|
|
|
@@ -1380,7 +1380,7 @@ Time exponential in worst-case, Space O(V + E)
|
|
|
1380
1380
|
getDestinations(vertex): VO[];
|
|
1381
1381
|
```
|
|
1382
1382
|
|
|
1383
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
1383
|
+
Defined in: [data-structures/graph/directed-graph.ts:689](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L689)
|
|
1384
1384
|
|
|
1385
1385
|
Direct children reachable by one outgoing edge.
|
|
1386
1386
|
|
|
@@ -1410,7 +1410,7 @@ Time O(deg_out), Space O(deg_out)
|
|
|
1410
1410
|
getDFNMap(): Map<VO, number>;
|
|
1411
1411
|
```
|
|
1412
1412
|
|
|
1413
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
1413
|
+
Defined in: [data-structures/graph/directed-graph.ts:1096](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L1096)
|
|
1414
1414
|
|
|
1415
1415
|
DFN index map computed by `tarjan()`.
|
|
1416
1416
|
|
|
@@ -1432,7 +1432,7 @@ Time O(V), Space O(V)
|
|
|
1432
1432
|
getEdge(srcOrKey, destOrKey): EO | undefined;
|
|
1433
1433
|
```
|
|
1434
1434
|
|
|
1435
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
1435
|
+
Defined in: [data-structures/graph/directed-graph.ts:268](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L268)
|
|
1436
1436
|
|
|
1437
1437
|
Get the unique edge from `src` to `dest`, if present.
|
|
1438
1438
|
|
|
@@ -1492,7 +1492,7 @@ IGraph.getEdge
|
|
|
1492
1492
|
getEndsOfEdge(edge): [VO, VO] | undefined;
|
|
1493
1493
|
```
|
|
1494
1494
|
|
|
1495
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
1495
|
+
Defined in: [data-structures/graph/directed-graph.ts:943](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L943)
|
|
1496
1496
|
|
|
1497
1497
|
Resolve an edge's `[src, dest]` endpoints to vertex instances.
|
|
1498
1498
|
|
|
@@ -1532,7 +1532,7 @@ IGraph.getEndsOfEdge
|
|
|
1532
1532
|
getLowMap(): Map<VO, number>;
|
|
1533
1533
|
```
|
|
1534
1534
|
|
|
1535
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
1535
|
+
Defined in: [data-structures/graph/directed-graph.ts:1105](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L1105)
|
|
1536
1536
|
|
|
1537
1537
|
LOW link map computed by `tarjan()`.
|
|
1538
1538
|
|
|
@@ -1659,7 +1659,7 @@ Time O((V + E) log V) weighted / O(V + E) unweighted, Space O(V + E)
|
|
|
1659
1659
|
getNeighbors(vertexOrKey): VO[];
|
|
1660
1660
|
```
|
|
1661
1661
|
|
|
1662
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
1662
|
+
Defined in: [data-structures/graph/directed-graph.ts:921](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L921)
|
|
1663
1663
|
|
|
1664
1664
|
Get outgoing neighbors
|
|
1665
1665
|
|
|
@@ -1741,7 +1741,7 @@ Time O(L), Space O(1) where L is path length
|
|
|
1741
1741
|
getSCCs(): Map<number, VO[]>;
|
|
1742
1742
|
```
|
|
1743
1743
|
|
|
1744
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
1744
|
+
Defined in: [data-structures/graph/directed-graph.ts:1164](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L1164)
|
|
1745
1745
|
|
|
1746
1746
|
Strongly connected components computed by `tarjan()`.
|
|
1747
1747
|
|
|
@@ -1968,7 +1968,7 @@ IGraph.hasVertex
|
|
|
1968
1968
|
incomingEdgesOf(vertexOrKey): EO[];
|
|
1969
1969
|
```
|
|
1970
1970
|
|
|
1971
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
1971
|
+
Defined in: [data-structures/graph/directed-graph.ts:565](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L565)
|
|
1972
1972
|
|
|
1973
1973
|
Incoming edges of a vertex.
|
|
1974
1974
|
|
|
@@ -2013,7 +2013,7 @@ Time O(deg_in), Space O(deg_in)
|
|
|
2013
2013
|
isEmpty(): boolean;
|
|
2014
2014
|
```
|
|
2015
2015
|
|
|
2016
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
2016
|
+
Defined in: [data-structures/graph/directed-graph.ts:960](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L960)
|
|
2017
2017
|
|
|
2018
2018
|
Whether the graph has no vertices and no edges.
|
|
2019
2019
|
|
|
@@ -2143,7 +2143,7 @@ Time O(n), Space O(n)
|
|
|
2143
2143
|
outgoingEdgesOf(vertexOrKey): EO[];
|
|
2144
2144
|
```
|
|
2145
2145
|
|
|
2146
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
2146
|
+
Defined in: [data-structures/graph/directed-graph.ts:627](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L627)
|
|
2147
2147
|
|
|
2148
2148
|
Outgoing edges of a vertex.
|
|
2149
2149
|
|
|
@@ -2387,7 +2387,7 @@ Time O(n), Space O(1)
|
|
|
2387
2387
|
tarjan(): object;
|
|
2388
2388
|
```
|
|
2389
2389
|
|
|
2390
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
2390
|
+
Defined in: [data-structures/graph/directed-graph.ts:1040](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L1040)
|
|
2391
2391
|
|
|
2392
2392
|
Tarjan's algorithm for strongly connected components.
|
|
2393
2393
|
|
|
@@ -2512,7 +2512,7 @@ DOT format string.
|
|
|
2512
2512
|
topologicalSort(propertyName?): (VertexKey | VO)[] | undefined;
|
|
2513
2513
|
```
|
|
2514
2514
|
|
|
2515
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
2515
|
+
Defined in: [data-structures/graph/directed-graph.ts:774](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L774)
|
|
2516
2516
|
|
|
2517
2517
|
Topological sort if DAG; returns `undefined` if a cycle exists.
|
|
2518
2518
|
|
|
@@ -2742,7 +2742,7 @@ Override in subclasses (e.g., '--' for undirected, '->' for directed).
|
|
|
2742
2742
|
protected _addEdge(edge): boolean;
|
|
2743
2743
|
```
|
|
2744
2744
|
|
|
2745
|
-
Defined in: [data-structures/graph/directed-graph.ts:
|
|
2745
|
+
Defined in: [data-structures/graph/directed-graph.ts:1174](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L1174)
|
|
2746
2746
|
|
|
2747
2747
|
Internal hook to attach a directed edge into adjacency maps.
|
|
2748
2748
|
|