data-structure-typed 1.12.21 → 1.15.0
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/README.md +278 -179
- package/dist/data-structures/binary-tree/binary-tree.d.ts +46 -1
- package/dist/data-structures/binary-tree/binary-tree.js +67 -0
- package/dist/data-structures/binary-tree/segment-tree.d.ts +29 -0
- package/dist/data-structures/binary-tree/segment-tree.js +45 -0
- package/dist/data-structures/graph/abstract-graph.d.ts +40 -5
- package/dist/data-structures/graph/abstract-graph.js +47 -7
- package/dist/data-structures/graph/directed-graph.d.ts +8 -0
- package/dist/data-structures/graph/directed-graph.js +14 -2
- package/dist/data-structures/graph/undirected-graph.d.ts +10 -0
- package/dist/data-structures/graph/undirected-graph.js +23 -1
- package/dist/data-structures/hash/coordinate-map.d.ts +7 -1
- package/dist/data-structures/hash/coordinate-map.js +16 -0
- package/dist/data-structures/hash/coordinate-set.d.ts +7 -1
- package/dist/data-structures/hash/coordinate-set.js +16 -0
- package/dist/data-structures/heap/heap.d.ts +16 -0
- package/dist/data-structures/heap/heap.js +38 -0
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +30 -7
- package/dist/data-structures/linked-list/doubly-linked-list.js +71 -4
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +262 -328
- package/dist/data-structures/linked-list/singly-linked-list.js +258 -273
- package/dist/data-structures/priority-queue/priority-queue.d.ts +7 -1
- package/dist/data-structures/priority-queue/priority-queue.js +18 -2
- package/dist/data-structures/queue/deque.d.ts +18 -7
- package/dist/data-structures/queue/deque.js +50 -3
- package/dist/data-structures/types/abstract-graph.d.ts +2 -2
- package/package.json +2 -2
- package/src/data-structures/binary-tree/aa-tree.ts +1 -1
- package/src/data-structures/binary-tree/binary-tree.ts +84 -14
- package/src/data-structures/binary-tree/segment-tree.ts +45 -13
- package/src/data-structures/graph/abstract-graph.ts +58 -15
- package/src/data-structures/graph/directed-graph.ts +14 -5
- package/src/data-structures/graph/undirected-graph.ts +23 -6
- package/src/data-structures/hash/coordinate-map.ts +13 -1
- package/src/data-structures/hash/coordinate-set.ts +13 -1
- package/src/data-structures/heap/heap.ts +31 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +68 -11
- package/src/data-structures/linked-list/singly-linked-list.ts +312 -334
- package/src/data-structures/priority-queue/priority-queue.ts +15 -2
- package/src/data-structures/queue/deque.ts +38 -8
- package/src/data-structures/types/abstract-graph.ts +3 -3
- package/tests/unit/data-structures/graph/directed-graph.test.ts +431 -8
|
@@ -99,6 +99,12 @@ var UndirectedEdge = /** @class */ (function (_super) {
|
|
|
99
99
|
enumerable: false,
|
|
100
100
|
configurable: true
|
|
101
101
|
});
|
|
102
|
+
/**
|
|
103
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
104
|
+
*/
|
|
105
|
+
UndirectedEdge.prototype.getVertices = function () {
|
|
106
|
+
return this._vertices;
|
|
107
|
+
};
|
|
102
108
|
return UndirectedEdge;
|
|
103
109
|
}(abstract_graph_1.AbstractEdge));
|
|
104
110
|
exports.UndirectedEdge = UndirectedEdge;
|
|
@@ -109,6 +115,22 @@ var UndirectedGraph = /** @class */ (function (_super) {
|
|
|
109
115
|
_this._edges = new Map();
|
|
110
116
|
return _this;
|
|
111
117
|
}
|
|
118
|
+
Object.defineProperty(UndirectedGraph.prototype, "edges", {
|
|
119
|
+
get: function () {
|
|
120
|
+
return this._edges;
|
|
121
|
+
},
|
|
122
|
+
set: function (v) {
|
|
123
|
+
this._edges = v;
|
|
124
|
+
},
|
|
125
|
+
enumerable: false,
|
|
126
|
+
configurable: true
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
130
|
+
*/
|
|
131
|
+
UndirectedGraph.prototype.getEdges = function () {
|
|
132
|
+
return this._edges;
|
|
133
|
+
};
|
|
112
134
|
/**
|
|
113
135
|
* The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
|
|
114
136
|
* @param {V | null | VertexId} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID
|
|
@@ -293,7 +315,7 @@ var UndirectedGraph = /** @class */ (function (_super) {
|
|
|
293
315
|
* `null`.
|
|
294
316
|
*/
|
|
295
317
|
UndirectedGraph.prototype.getEndsOfEdge = function (edge) {
|
|
296
|
-
if (!this.
|
|
318
|
+
if (!this.hasEdge(edge.vertices[0], edge.vertices[1])) {
|
|
297
319
|
return null;
|
|
298
320
|
}
|
|
299
321
|
var v1 = this.getVertex(edge.vertices[0]);
|
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
export declare class CoordinateMap<V> extends Map<any, V> {
|
|
9
|
-
|
|
9
|
+
protected _joint: string;
|
|
10
|
+
get joint(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
13
|
+
*/
|
|
14
|
+
getJoint(): string;
|
|
15
|
+
protected set joint(v: string);
|
|
10
16
|
constructor(joint?: string);
|
|
11
17
|
/**
|
|
12
18
|
* The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
|
|
@@ -32,6 +32,22 @@ var CoordinateMap = /** @class */ (function (_super) {
|
|
|
32
32
|
_this._joint = joint;
|
|
33
33
|
return _this;
|
|
34
34
|
}
|
|
35
|
+
Object.defineProperty(CoordinateMap.prototype, "joint", {
|
|
36
|
+
get: function () {
|
|
37
|
+
return this._joint;
|
|
38
|
+
},
|
|
39
|
+
set: function (v) {
|
|
40
|
+
this._joint = v;
|
|
41
|
+
},
|
|
42
|
+
enumerable: false,
|
|
43
|
+
configurable: true
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
47
|
+
*/
|
|
48
|
+
CoordinateMap.prototype.getJoint = function () {
|
|
49
|
+
return this._joint;
|
|
50
|
+
};
|
|
35
51
|
/**
|
|
36
52
|
* The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
|
|
37
53
|
* key array with a specified delimiter.
|
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
export declare class CoordinateSet extends Set {
|
|
9
|
-
|
|
9
|
+
protected _joint: string;
|
|
10
|
+
get joint(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
13
|
+
*/
|
|
14
|
+
getJoint(): string;
|
|
15
|
+
protected set joint(v: string);
|
|
10
16
|
constructor(joint?: string);
|
|
11
17
|
/**
|
|
12
18
|
* The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
|
|
@@ -32,6 +32,22 @@ var CoordinateSet = /** @class */ (function (_super) {
|
|
|
32
32
|
_this._joint = joint;
|
|
33
33
|
return _this;
|
|
34
34
|
}
|
|
35
|
+
Object.defineProperty(CoordinateSet.prototype, "joint", {
|
|
36
|
+
get: function () {
|
|
37
|
+
return this._joint;
|
|
38
|
+
},
|
|
39
|
+
set: function (v) {
|
|
40
|
+
this._joint = v;
|
|
41
|
+
},
|
|
42
|
+
enumerable: false,
|
|
43
|
+
configurable: true
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
47
|
+
*/
|
|
48
|
+
CoordinateSet.prototype.getJoint = function () {
|
|
49
|
+
return this._joint;
|
|
50
|
+
};
|
|
35
51
|
/**
|
|
36
52
|
* The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
|
|
37
53
|
* joining its elements with a specified separator.
|
|
@@ -9,7 +9,19 @@ import { PriorityQueue } from '../priority-queue';
|
|
|
9
9
|
import type { HeapItem, HeapOptions } from '../types';
|
|
10
10
|
export declare abstract class Heap<T> {
|
|
11
11
|
protected abstract _pq: PriorityQueue<HeapItem<T>>;
|
|
12
|
+
get pq(): PriorityQueue<HeapItem<T>>;
|
|
13
|
+
/**
|
|
14
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
15
|
+
*/
|
|
16
|
+
getPq(): PriorityQueue<HeapItem<T>>;
|
|
17
|
+
protected set pq(v: PriorityQueue<HeapItem<T>>);
|
|
12
18
|
protected _priorityCb: (element: T) => number;
|
|
19
|
+
get priorityCb(): (element: T) => number;
|
|
20
|
+
/**
|
|
21
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
22
|
+
*/
|
|
23
|
+
getPriorityCb(): (element: T) => number;
|
|
24
|
+
protected set priorityCb(v: (element: T) => number);
|
|
13
25
|
/**
|
|
14
26
|
* The function is a constructor for a class that initializes a priority callback function based on the
|
|
15
27
|
* options provided.
|
|
@@ -21,6 +33,10 @@ export declare abstract class Heap<T> {
|
|
|
21
33
|
* @returns The size of the priority queue.
|
|
22
34
|
*/
|
|
23
35
|
get size(): number;
|
|
36
|
+
/**
|
|
37
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
38
|
+
*/
|
|
39
|
+
getSize(): number;
|
|
24
40
|
/**
|
|
25
41
|
* The function checks if a priority queue is empty.
|
|
26
42
|
* @returns {boolean} A boolean value indicating whether the size of the priority queue is less than 1.
|
|
@@ -19,6 +19,38 @@ var Heap = /** @class */ (function () {
|
|
|
19
19
|
this._priorityCb = function (el) { return +el; };
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
Object.defineProperty(Heap.prototype, "pq", {
|
|
23
|
+
get: function () {
|
|
24
|
+
return this._pq;
|
|
25
|
+
},
|
|
26
|
+
set: function (v) {
|
|
27
|
+
this._pq = v;
|
|
28
|
+
},
|
|
29
|
+
enumerable: false,
|
|
30
|
+
configurable: true
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
34
|
+
*/
|
|
35
|
+
Heap.prototype.getPq = function () {
|
|
36
|
+
return this._pq;
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(Heap.prototype, "priorityCb", {
|
|
39
|
+
get: function () {
|
|
40
|
+
return this._priorityCb;
|
|
41
|
+
},
|
|
42
|
+
set: function (v) {
|
|
43
|
+
this._priorityCb = v;
|
|
44
|
+
},
|
|
45
|
+
enumerable: false,
|
|
46
|
+
configurable: true
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
50
|
+
*/
|
|
51
|
+
Heap.prototype.getPriorityCb = function () {
|
|
52
|
+
return this._priorityCb;
|
|
53
|
+
};
|
|
22
54
|
Object.defineProperty(Heap.prototype, "size", {
|
|
23
55
|
/**
|
|
24
56
|
* The function returns the size of a priority queue.
|
|
@@ -30,6 +62,12 @@ var Heap = /** @class */ (function () {
|
|
|
30
62
|
enumerable: false,
|
|
31
63
|
configurable: true
|
|
32
64
|
});
|
|
65
|
+
/**
|
|
66
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
67
|
+
*/
|
|
68
|
+
Heap.prototype.getSize = function () {
|
|
69
|
+
return this._pq.size;
|
|
70
|
+
};
|
|
33
71
|
/**
|
|
34
72
|
* The function checks if a priority queue is empty.
|
|
35
73
|
* @returns {boolean} A boolean value indicating whether the size of the priority queue is less than 1.
|
|
@@ -1,15 +1,38 @@
|
|
|
1
1
|
export declare class DoublyLinkedListNode<T> {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
protected _val: T;
|
|
3
|
+
get val(): T;
|
|
4
|
+
set val(v: T);
|
|
5
|
+
protected _next: DoublyLinkedListNode<T> | null;
|
|
6
|
+
get next(): DoublyLinkedListNode<T> | null;
|
|
7
|
+
set next(v: DoublyLinkedListNode<T> | null);
|
|
8
|
+
protected _prev: DoublyLinkedListNode<T> | null;
|
|
9
|
+
get prev(): DoublyLinkedListNode<T> | null;
|
|
10
|
+
set prev(v: DoublyLinkedListNode<T> | null);
|
|
5
11
|
constructor(nodeValue: T);
|
|
6
12
|
}
|
|
7
13
|
export declare class DoublyLinkedList<T> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
protected _first: DoublyLinkedListNode<T> | null;
|
|
15
|
+
get first(): DoublyLinkedListNode<T> | null;
|
|
16
|
+
/**
|
|
17
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
18
|
+
*/
|
|
19
|
+
getFirst(): DoublyLinkedListNode<T> | null;
|
|
20
|
+
protected set first(v: DoublyLinkedListNode<T> | null);
|
|
21
|
+
protected _last: DoublyLinkedListNode<T> | null;
|
|
22
|
+
get last(): DoublyLinkedListNode<T> | null;
|
|
23
|
+
/**
|
|
24
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
25
|
+
*/
|
|
26
|
+
getLast(): DoublyLinkedListNode<T> | null;
|
|
27
|
+
protected set last(v: DoublyLinkedListNode<T> | null);
|
|
28
|
+
protected _size: number;
|
|
11
29
|
get size(): number;
|
|
12
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
32
|
+
*/
|
|
33
|
+
getSize(): number;
|
|
34
|
+
protected set size(v: number);
|
|
35
|
+
constructor();
|
|
13
36
|
/**
|
|
14
37
|
* The function adds a new node with a given value to the beginning of a doubly linked list.
|
|
15
38
|
* @param {T} val - The `val` parameter represents the value of the element that you want to add to the beginning of
|
|
@@ -3,10 +3,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DoublyLinkedList = exports.DoublyLinkedListNode = void 0;
|
|
4
4
|
var DoublyLinkedListNode = /** @class */ (function () {
|
|
5
5
|
function DoublyLinkedListNode(nodeValue) {
|
|
6
|
-
this.
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
6
|
+
this._val = nodeValue;
|
|
7
|
+
this._next = null;
|
|
8
|
+
this._prev = null;
|
|
9
9
|
}
|
|
10
|
+
Object.defineProperty(DoublyLinkedListNode.prototype, "val", {
|
|
11
|
+
get: function () {
|
|
12
|
+
return this._val;
|
|
13
|
+
},
|
|
14
|
+
set: function (v) {
|
|
15
|
+
this._val = v;
|
|
16
|
+
},
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(DoublyLinkedListNode.prototype, "next", {
|
|
21
|
+
get: function () {
|
|
22
|
+
return this._next;
|
|
23
|
+
},
|
|
24
|
+
set: function (v) {
|
|
25
|
+
this._next = v;
|
|
26
|
+
},
|
|
27
|
+
enumerable: false,
|
|
28
|
+
configurable: true
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(DoublyLinkedListNode.prototype, "prev", {
|
|
31
|
+
get: function () {
|
|
32
|
+
return this._prev;
|
|
33
|
+
},
|
|
34
|
+
set: function (v) {
|
|
35
|
+
this._prev = v;
|
|
36
|
+
},
|
|
37
|
+
enumerable: false,
|
|
38
|
+
configurable: true
|
|
39
|
+
});
|
|
10
40
|
return DoublyLinkedListNode;
|
|
11
41
|
}());
|
|
12
42
|
exports.DoublyLinkedListNode = DoublyLinkedListNode;
|
|
@@ -15,8 +45,39 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
15
45
|
this._first = null;
|
|
16
46
|
this._last = null;
|
|
17
47
|
this._size = 0;
|
|
18
|
-
// --- end extra methods ---
|
|
19
48
|
}
|
|
49
|
+
Object.defineProperty(DoublyLinkedList.prototype, "first", {
|
|
50
|
+
get: function () {
|
|
51
|
+
return this._first;
|
|
52
|
+
},
|
|
53
|
+
set: function (v) {
|
|
54
|
+
this._first = v;
|
|
55
|
+
},
|
|
56
|
+
enumerable: false,
|
|
57
|
+
configurable: true
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
61
|
+
*/
|
|
62
|
+
DoublyLinkedList.prototype.getFirst = function () {
|
|
63
|
+
return this._first;
|
|
64
|
+
};
|
|
65
|
+
Object.defineProperty(DoublyLinkedList.prototype, "last", {
|
|
66
|
+
get: function () {
|
|
67
|
+
return this._last;
|
|
68
|
+
},
|
|
69
|
+
set: function (v) {
|
|
70
|
+
this._last = v;
|
|
71
|
+
},
|
|
72
|
+
enumerable: false,
|
|
73
|
+
configurable: true
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
77
|
+
*/
|
|
78
|
+
DoublyLinkedList.prototype.getLast = function () {
|
|
79
|
+
return this._last;
|
|
80
|
+
};
|
|
20
81
|
Object.defineProperty(DoublyLinkedList.prototype, "size", {
|
|
21
82
|
get: function () {
|
|
22
83
|
return this._size;
|
|
@@ -27,6 +88,12 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
27
88
|
enumerable: false,
|
|
28
89
|
configurable: true
|
|
29
90
|
});
|
|
91
|
+
/**
|
|
92
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
93
|
+
*/
|
|
94
|
+
DoublyLinkedList.prototype.getSize = function () {
|
|
95
|
+
return this._size;
|
|
96
|
+
};
|
|
30
97
|
/**
|
|
31
98
|
* The function adds a new node with a given value to the beginning of a doubly linked list.
|
|
32
99
|
* @param {T} val - The `val` parameter represents the value of the element that you want to add to the beginning of
|