linked-list-typed 1.38.2 → 1.38.4
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/.dependency-cruiser.js +422 -422
- package/.eslintrc.js +59 -59
- package/.prettierrc.js +14 -14
- package/README.md +15 -3
- package/coverage/clover.xml +11 -7
- package/coverage/coverage-final.json +165 -1
- package/coverage/coverage-summary.json +59 -2
- package/coverage/lcov-report/base.css +278 -99
- package/coverage/lcov-report/index.html +69 -65
- package/coverage/lcov-report/index.ts.html +39 -36
- package/coverage/lcov-report/sorter.js +15 -5
- package/dist/data-structures/binary-tree/binary-tree.d.ts +9 -9
- package/dist/data-structures/binary-tree/bst.d.ts +4 -4
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/types/helpers.d.ts +1 -1
- package/jest.config.js +6 -6
- package/package.json +4 -1
- package/src/data-structures/binary-tree/avl-tree.ts +1 -1
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +1 -1
- package/src/data-structures/binary-tree/binary-tree.ts +21 -21
- package/src/data-structures/binary-tree/bst.ts +7 -7
- package/src/data-structures/binary-tree/tree-multiset.ts +2 -1
- package/src/data-structures/graph/abstract-graph.ts +11 -10
- package/src/data-structures/graph/directed-graph.ts +2 -1
- package/src/data-structures/graph/undirected-graph.ts +5 -4
- package/src/data-structures/hash/hash-map.ts +1 -1
- package/src/data-structures/hash/tree-map.ts +1 -2
- package/src/data-structures/hash/tree-set.ts +1 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
- package/src/data-structures/matrix/matrix.ts +1 -1
- package/src/data-structures/matrix/vector2d.ts +1 -2
- package/src/data-structures/queue/deque.ts +4 -5
- package/src/data-structures/queue/queue.ts +1 -1
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/matrix/navigator.ts +1 -1
- package/src/types/helpers.ts +1 -1
- package/src/types/utils/utils.ts +1 -1
- package/src/types/utils/validate-type.ts +2 -2
- package/tsconfig.json +1 -2
|
@@ -105,7 +105,8 @@ export abstract class AbstractEdge<V = any> {
|
|
|
105
105
|
export abstract class AbstractGraph<
|
|
106
106
|
V extends AbstractVertex<any> = AbstractVertex<any>,
|
|
107
107
|
E extends AbstractEdge<any> = AbstractEdge<any>
|
|
108
|
-
> implements IGraph<V, E>
|
|
108
|
+
> implements IGraph<V, E>
|
|
109
|
+
{
|
|
109
110
|
private _vertices: Map<VertexKey, V> = new Map<VertexKey, V>();
|
|
110
111
|
|
|
111
112
|
get vertices(): Map<VertexKey, V> {
|
|
@@ -553,14 +554,14 @@ export abstract class AbstractGraph<
|
|
|
553
554
|
}
|
|
554
555
|
|
|
555
556
|
getMinDist &&
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
557
|
+
distMap.forEach((d, v) => {
|
|
558
|
+
if (v !== srcVertex) {
|
|
559
|
+
if (d < minDist) {
|
|
560
|
+
minDist = d;
|
|
561
|
+
if (genPaths) minDest = v;
|
|
562
|
+
}
|
|
561
563
|
}
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
+
});
|
|
564
565
|
|
|
565
566
|
genPaths && getPaths(minDest);
|
|
566
567
|
|
|
@@ -622,7 +623,7 @@ export abstract class AbstractGraph<
|
|
|
622
623
|
if (vertexOrKey instanceof AbstractVertex) distMap.set(vertexOrKey, Infinity);
|
|
623
624
|
}
|
|
624
625
|
|
|
625
|
-
const heap = new PriorityQueue<{
|
|
626
|
+
const heap = new PriorityQueue<{key: number; val: V}>((a, b) => a.key - b.key);
|
|
626
627
|
heap.add({key: 0, val: srcVertex});
|
|
627
628
|
|
|
628
629
|
distMap.set(srcVertex, 0);
|
|
@@ -851,7 +852,7 @@ export abstract class AbstractGraph<
|
|
|
851
852
|
* `predecessor` property is a 2D array of vertices (or `null`) representing the predecessor vertices in the shortest
|
|
852
853
|
* path between vertices in the
|
|
853
854
|
*/
|
|
854
|
-
floyd(): {
|
|
855
|
+
floyd(): {costs: number[][]; predecessor: (V | null)[][]} {
|
|
855
856
|
const idAndVertices = [...this._vertices];
|
|
856
857
|
const n = idAndVertices.length;
|
|
857
858
|
|
|
@@ -64,7 +64,8 @@ export class DirectedEdge<V = any> extends AbstractEdge<V> {
|
|
|
64
64
|
|
|
65
65
|
export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E extends DirectedEdge<any> = DirectedEdge>
|
|
66
66
|
extends AbstractGraph<V, E>
|
|
67
|
-
implements IGraph<V, E>
|
|
67
|
+
implements IGraph<V, E>
|
|
68
|
+
{
|
|
68
69
|
/**
|
|
69
70
|
* The constructor function initializes an instance of a class.
|
|
70
71
|
*/
|
|
@@ -51,11 +51,12 @@ export class UndirectedEdge<V = number> extends AbstractEdge<V> {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export class UndirectedGraph<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
>
|
|
54
|
+
V extends UndirectedVertex<any> = UndirectedVertex,
|
|
55
|
+
E extends UndirectedEdge<any> = UndirectedEdge
|
|
56
|
+
>
|
|
57
57
|
extends AbstractGraph<V, E>
|
|
58
|
-
implements IGraph<V, E>
|
|
58
|
+
implements IGraph<V, E>
|
|
59
|
+
{
|
|
59
60
|
/**
|
|
60
61
|
* The constructor initializes a new Map object to store edges.
|
|
61
62
|
*/
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export class TreeMap {
|
|
2
|
-
}
|
|
1
|
+
export class TreeMap {}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export class TreeSet {
|
|
2
|
-
}
|
|
1
|
+
export class TreeSet {}
|
|
@@ -14,7 +14,7 @@ export class MatrixNTI2D<V = any> {
|
|
|
14
14
|
* given initial value or 0 if not provided.
|
|
15
15
|
* @param options - An object containing the following properties:
|
|
16
16
|
*/
|
|
17
|
-
constructor(options: {
|
|
17
|
+
constructor(options: {row: number; col: number; initialVal?: V}) {
|
|
18
18
|
const {row, col, initialVal} = options;
|
|
19
19
|
this._matrix = new Array(row).fill(undefined).map(() => new Array(col).fill(initialVal || 0));
|
|
20
20
|
}
|
|
@@ -9,8 +9,7 @@ import {DoublyLinkedList} from '../linked-list';
|
|
|
9
9
|
|
|
10
10
|
// O(n) time complexity of obtaining the value
|
|
11
11
|
// O(1) time complexity of adding at the beginning and the end
|
|
12
|
-
export class Deque<E = any> extends DoublyLinkedList<E> {
|
|
13
|
-
}
|
|
12
|
+
export class Deque<E = any> extends DoublyLinkedList<E> {}
|
|
14
13
|
|
|
15
14
|
// O(1) time complexity of obtaining the value
|
|
16
15
|
// O(n) time complexity of adding at the beginning and the end
|
|
@@ -20,9 +19,9 @@ export class ObjectDeque<E = number> {
|
|
|
20
19
|
if (capacity !== undefined) this._capacity = capacity;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
private _nodes: {
|
|
22
|
+
private _nodes: {[key: number]: E} = {};
|
|
24
23
|
|
|
25
|
-
get nodes(): {
|
|
24
|
+
get nodes(): {[p: number]: E} {
|
|
26
25
|
return this._nodes;
|
|
27
26
|
}
|
|
28
27
|
|
|
@@ -157,7 +156,7 @@ export class ObjectDeque<E = number> {
|
|
|
157
156
|
return this._size <= 0;
|
|
158
157
|
}
|
|
159
158
|
|
|
160
|
-
protected _seNodes(value: {
|
|
159
|
+
protected _seNodes(value: {[p: number]: E}) {
|
|
161
160
|
this._nodes = value;
|
|
162
161
|
}
|
|
163
162
|
|
|
@@ -24,7 +24,7 @@ export enum FamilyPosition {
|
|
|
24
24
|
|
|
25
25
|
export type BinaryTreeNodeKey = number;
|
|
26
26
|
|
|
27
|
-
export type BFSCallback<N> = (node: N, level?: number) =>
|
|
27
|
+
export type BFSCallback<N, D = any> = (node: N, level?: number) => D;
|
|
28
28
|
|
|
29
29
|
export type BFSCallbackReturn<N> = ReturnType<BFSCallback<N>>;
|
|
30
30
|
|
package/src/types/helpers.ts
CHANGED
|
@@ -2,7 +2,7 @@ export type Comparator<T> = (a: T, b: T) => number;
|
|
|
2
2
|
|
|
3
3
|
export type DFSOrderPattern = 'pre' | 'in' | 'post';
|
|
4
4
|
|
|
5
|
-
export type MapCallback<N> = (node: N) =>
|
|
5
|
+
export type MapCallback<N, D = any> = (node: N) => D;
|
|
6
6
|
|
|
7
7
|
export type MapCallbackReturn<N> = ReturnType<MapCallback<N>>;
|
|
8
8
|
|
package/src/types/utils/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type ToThunkFn = () => ReturnType<TrlFn>;
|
|
2
|
-
export type Thunk = () => ReturnType<ToThunkFn> & {
|
|
2
|
+
export type Thunk = () => ReturnType<ToThunkFn> & {__THUNK__: symbol};
|
|
3
3
|
export type TrlFn = (...args: any[]) => any;
|
|
4
4
|
export type TrlAsyncFn = (...args: any[]) => any;
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type KeyValueObject = {
|
|
1
|
+
export type KeyValueObject = {[key: string]: any};
|
|
2
2
|
|
|
3
|
-
export type KeyValueObjectWithKey = {
|
|
3
|
+
export type KeyValueObjectWithKey = {[key: string]: any; key: string | number | symbol};
|
|
4
4
|
|
|
5
5
|
export type NonNumberNonObjectButDefined = string | boolean | symbol | null;
|
|
6
6
|
|