data-structure-typed 0.9.16 → 1.3.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/LICENSE +21 -0
- package/README.md +665 -172
- package/dist/bundle.js +2 -0
- package/dist/bundle.js.LICENSE.txt +13 -0
- package/dist/data-structures/binary-tree/aa-tree.js +2 -5
- package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +364 -0
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +1308 -0
- package/dist/data-structures/binary-tree/avl-tree.d.ts +85 -14
- package/dist/data-structures/binary-tree/avl-tree.js +142 -116
- package/dist/data-structures/binary-tree/b-tree.js +2 -5
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +39 -1
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +54 -13
- package/dist/data-structures/binary-tree/binary-tree.d.ts +29 -126
- package/dist/data-structures/binary-tree/binary-tree.js +31 -1093
- package/dist/data-structures/binary-tree/bst.d.ts +117 -23
- package/dist/data-structures/binary-tree/bst.js +233 -240
- package/dist/data-structures/binary-tree/index.d.ts +1 -0
- package/dist/data-structures/binary-tree/index.js +1 -0
- package/dist/data-structures/binary-tree/rb-tree.d.ts +18 -1
- package/dist/data-structures/binary-tree/rb-tree.js +40 -5
- package/dist/data-structures/binary-tree/segment-tree.d.ts +61 -11
- package/dist/data-structures/binary-tree/segment-tree.js +126 -93
- package/dist/data-structures/binary-tree/splay-tree.js +2 -5
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +213 -6
- package/dist/data-structures/binary-tree/tree-multiset.js +687 -34
- package/dist/data-structures/binary-tree/two-three-tree.js +2 -5
- package/dist/data-structures/graph/abstract-graph.d.ts +270 -36
- package/dist/data-structures/graph/abstract-graph.js +610 -572
- package/dist/data-structures/graph/directed-graph.d.ts +173 -16
- package/dist/data-structures/graph/directed-graph.js +345 -313
- package/dist/data-structures/graph/index.d.ts +1 -0
- package/dist/data-structures/graph/index.js +1 -0
- package/dist/data-structures/graph/map-graph.d.ts +79 -0
- package/dist/data-structures/graph/map-graph.js +111 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +111 -9
- package/dist/data-structures/graph/undirected-graph.js +203 -178
- package/dist/data-structures/hash/coordinate-map.d.ts +38 -1
- package/dist/data-structures/hash/coordinate-map.js +59 -36
- package/dist/data-structures/hash/coordinate-set.d.ts +32 -2
- package/dist/data-structures/hash/coordinate-set.js +49 -33
- package/dist/data-structures/hash/hash-table.d.ts +2 -1
- package/dist/data-structures/hash/hash-table.js +4 -0
- package/dist/data-structures/hash/pair.d.ts +2 -1
- package/dist/data-structures/hash/pair.js +4 -0
- package/dist/data-structures/hash/tree-map.d.ts +2 -1
- package/dist/data-structures/hash/tree-map.js +4 -0
- package/dist/data-structures/hash/tree-set.d.ts +2 -1
- package/dist/data-structures/hash/tree-set.js +4 -0
- package/dist/data-structures/heap/heap.d.ts +62 -45
- package/dist/data-structures/heap/heap.js +124 -86
- package/dist/data-structures/heap/max-heap.d.ts +13 -5
- package/dist/data-structures/heap/max-heap.js +18 -28
- package/dist/data-structures/heap/min-heap.d.ts +14 -5
- package/dist/data-structures/heap/min-heap.js +19 -28
- package/dist/data-structures/index.d.ts +1 -1
- package/dist/data-structures/index.js +1 -1
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +193 -56
- package/dist/data-structures/linked-list/doubly-linked-list.js +484 -220
- package/dist/data-structures/linked-list/index.d.ts +1 -0
- package/dist/data-structures/linked-list/index.js +1 -0
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +117 -315
- package/dist/data-structures/linked-list/singly-linked-list.js +374 -727
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -1
- package/dist/data-structures/linked-list/skip-linked-list.js +4 -0
- package/dist/data-structures/matrix/matrix.d.ts +12 -0
- package/dist/data-structures/matrix/matrix.js +21 -8
- package/dist/data-structures/matrix/matrix2d.d.ts +85 -2
- package/dist/data-structures/matrix/matrix2d.js +146 -80
- package/dist/data-structures/matrix/navigator.d.ts +36 -1
- package/dist/data-structures/matrix/navigator.js +46 -37
- package/dist/data-structures/matrix/vector2d.d.ts +142 -15
- package/dist/data-structures/matrix/vector2d.js +215 -109
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -2
- package/dist/data-structures/priority-queue/max-priority-queue.js +33 -26
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +12 -2
- package/dist/data-structures/priority-queue/min-priority-queue.js +34 -26
- package/dist/data-structures/priority-queue/priority-queue.d.ts +153 -3
- package/dist/data-structures/priority-queue/priority-queue.js +244 -143
- package/dist/data-structures/queue/deque.d.ts +141 -13
- package/dist/data-structures/queue/deque.js +200 -82
- package/dist/data-structures/queue/queue.d.ts +65 -38
- package/dist/data-structures/queue/queue.js +110 -66
- package/dist/data-structures/stack/stack.d.ts +27 -32
- package/dist/data-structures/stack/stack.js +47 -53
- package/dist/data-structures/tree/index.d.ts +1 -0
- package/dist/data-structures/tree/index.js +17 -0
- package/dist/data-structures/tree/tree.d.ts +14 -0
- package/dist/data-structures/tree/tree.js +60 -0
- package/dist/data-structures/trie/trie.d.ts +33 -10
- package/dist/data-structures/trie/trie.js +123 -208
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/interfaces/abstract-binary-tree.d.ts +90 -0
- package/dist/interfaces/abstract-graph.d.ts +17 -0
- package/dist/interfaces/avl-tree.d.ts +9 -0
- package/dist/interfaces/binary-tree.d.ts +6 -0
- package/dist/interfaces/bst.d.ts +17 -0
- package/dist/interfaces/directed-graph.d.ts +12 -0
- package/{src/data-structures/types/index.ts → dist/interfaces/index.d.ts} +10 -8
- package/dist/interfaces/index.js +31 -0
- package/{src/data-structures/hash/hash-table.ts → dist/interfaces/priority-queue.d.ts} +1 -1
- package/dist/interfaces/rb-tree.d.ts +8 -0
- package/dist/interfaces/segment-tree.d.ts +1 -0
- package/dist/interfaces/singly-linked-list.d.ts +1 -0
- package/dist/interfaces/singly-linked-list.js +2 -0
- package/dist/interfaces/tree-multiset.d.ts +7 -0
- package/dist/interfaces/tree-multiset.js +2 -0
- package/dist/interfaces/undirected-graph.d.ts +5 -0
- package/dist/interfaces/undirected-graph.js +2 -0
- package/dist/types/data-structures/abstract-binary-tree.d.ts +34 -0
- package/dist/types/data-structures/abstract-binary-tree.js +25 -0
- package/dist/types/data-structures/abstract-graph.d.ts +11 -0
- package/dist/types/data-structures/abstract-graph.js +2 -0
- package/dist/types/data-structures/avl-tree.d.ts +4 -0
- package/dist/types/data-structures/avl-tree.js +2 -0
- package/dist/types/data-structures/binary-tree.d.ts +4 -0
- package/dist/types/data-structures/binary-tree.js +2 -0
- package/dist/types/data-structures/bst.d.ts +13 -0
- package/dist/types/data-structures/bst.js +9 -0
- package/dist/types/data-structures/directed-graph.d.ts +6 -0
- package/dist/types/data-structures/directed-graph.js +9 -0
- package/dist/types/data-structures/doubly-linked-list.d.ts +1 -0
- package/dist/types/data-structures/doubly-linked-list.js +2 -0
- package/dist/types/data-structures/heap.d.ts +3 -0
- package/dist/types/data-structures/heap.js +2 -0
- package/dist/{data-structures/types → types/data-structures}/index.d.ts +3 -1
- package/dist/{data-structures/types → types/data-structures}/index.js +3 -1
- package/dist/types/data-structures/map-graph.d.ts +1 -0
- package/dist/types/data-structures/map-graph.js +2 -0
- package/dist/{data-structures/types → types/data-structures}/navigator.d.ts +2 -2
- package/dist/types/data-structures/navigator.js +2 -0
- package/dist/{data-structures/types → types/data-structures}/priority-queue.d.ts +2 -2
- package/dist/types/data-structures/priority-queue.js +2 -0
- package/dist/types/data-structures/rb-tree.d.ts +8 -0
- package/dist/types/data-structures/rb-tree.js +8 -0
- package/dist/types/data-structures/segment-tree.js +2 -0
- package/dist/types/data-structures/singly-linked-list.d.ts +1 -0
- package/dist/types/data-structures/singly-linked-list.js +2 -0
- package/dist/types/data-structures/tree-multiset.d.ts +4 -0
- package/dist/types/data-structures/tree-multiset.js +2 -0
- package/dist/types/helpers.d.ts +1 -0
- package/dist/types/helpers.js +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +19 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.js +18 -0
- package/dist/types/utils/utils.d.ts +7 -0
- package/dist/types/utils/utils.js +2 -0
- package/dist/types/utils/validate-type.d.ts +19 -0
- package/dist/types/utils/validate-type.js +2 -0
- package/dist/utils/utils.d.ts +17 -103
- package/dist/utils/utils.js +40 -625
- package/package.json +134 -23
- package/.idea/data-structure-typed.iml +0 -12
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/dist/data-structures/trampoline.d.ts +0 -16
- package/dist/data-structures/trampoline.js +0 -130
- package/dist/data-structures/types/abstract-graph.d.ts +0 -29
- package/dist/data-structures/types/avl-tree.d.ts +0 -5
- package/dist/data-structures/types/binary-tree.d.ts +0 -16
- package/dist/data-structures/types/bst.d.ts +0 -7
- package/dist/data-structures/types/directed-graph.d.ts +0 -10
- package/dist/data-structures/types/doubly-linked-list.d.ts +0 -1
- package/dist/data-structures/types/heap.d.ts +0 -7
- package/dist/data-structures/types/singly-linked-list.d.ts +0 -5
- package/dist/data-structures/types/tree-multiset.d.ts +0 -5
- package/dist/data-structures/types/utils.d.ts +0 -52
- package/dist/data-structures/types/utils.js +0 -54
- package/src/data-structures/binary-tree/aa-tree.ts +0 -3
- package/src/data-structures/binary-tree/avl-tree.ts +0 -227
- package/src/data-structures/binary-tree/b-tree.ts +0 -3
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -33
- package/src/data-structures/binary-tree/binary-tree.ts +0 -1133
- package/src/data-structures/binary-tree/bst.ts +0 -395
- package/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
- package/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
- package/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
- package/src/data-structures/binary-tree/index.ts +0 -11
- package/src/data-structures/binary-tree/rb-tree.ts +0 -3
- package/src/data-structures/binary-tree/segment-tree.ts +0 -172
- package/src/data-structures/binary-tree/splay-tree.ts +0 -3
- package/src/data-structures/binary-tree/tree-multiset.ts +0 -18
- package/src/data-structures/binary-tree/two-three-tree.ts +0 -3
- package/src/data-structures/diagrams/README.md +0 -7
- package/src/data-structures/graph/abstract-graph.ts +0 -753
- package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.png +0 -0
- package/src/data-structures/graph/diagrams/adjacency-list.png +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.png +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix.png +0 -0
- package/src/data-structures/graph/diagrams/dfs-can-do.png +0 -0
- package/src/data-structures/graph/diagrams/edge-list-pros-cons.png +0 -0
- package/src/data-structures/graph/diagrams/edge-list.png +0 -0
- package/src/data-structures/graph/diagrams/max-flow.png +0 -0
- package/src/data-structures/graph/diagrams/mst.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
- package/src/data-structures/graph/directed-graph.ts +0 -306
- package/src/data-structures/graph/index.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +0 -155
- package/src/data-structures/hash/coordinate-map.ts +0 -24
- package/src/data-structures/hash/coordinate-set.ts +0 -20
- package/src/data-structures/hash/index.ts +0 -6
- package/src/data-structures/heap/heap.ts +0 -127
- package/src/data-structures/heap/index.ts +0 -3
- package/src/data-structures/heap/max-heap.ts +0 -23
- package/src/data-structures/heap/min-heap.ts +0 -25
- package/src/data-structures/index.ts +0 -12
- package/src/data-structures/linked-list/doubly-linked-list.ts +0 -250
- package/src/data-structures/linked-list/index.ts +0 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +0 -736
- package/src/data-structures/linked-list/skip-linked-list.ts +0 -1
- package/src/data-structures/matrix/index.ts +0 -4
- package/src/data-structures/matrix/matrix.ts +0 -13
- package/src/data-structures/matrix/matrix2d.ts +0 -125
- package/src/data-structures/matrix/navigator.ts +0 -87
- package/src/data-structures/matrix/vector2d.ts +0 -189
- package/src/data-structures/priority-queue/index.ts +0 -3
- package/src/data-structures/priority-queue/max-priority-queue.ts +0 -13
- package/src/data-structures/priority-queue/min-priority-queue.ts +0 -13
- package/src/data-structures/priority-queue/priority-queue.ts +0 -200
- package/src/data-structures/queue/deque.ts +0 -139
- package/src/data-structures/queue/index.ts +0 -2
- package/src/data-structures/queue/queue.ts +0 -122
- package/src/data-structures/stack/index.ts +0 -1
- package/src/data-structures/stack/stack.ts +0 -103
- package/src/data-structures/trampoline.ts +0 -51
- package/src/data-structures/trie/index.ts +0 -1
- package/src/data-structures/trie/trie.ts +0 -203
- package/src/data-structures/types/abstract-graph.ts +0 -51
- package/src/data-structures/types/avl-tree.ts +0 -6
- package/src/data-structures/types/binary-tree.ts +0 -15
- package/src/data-structures/types/bst.ts +0 -5
- package/src/data-structures/types/directed-graph.ts +0 -18
- package/src/data-structures/types/doubly-linked-list.ts +0 -1
- package/src/data-structures/types/heap.ts +0 -8
- package/src/data-structures/types/navigator.ts +0 -12
- package/src/data-structures/types/priority-queue.ts +0 -9
- package/src/data-structures/types/segment-tree.ts +0 -1
- package/src/data-structures/types/singly-linked-list.ts +0 -15
- package/src/data-structures/types/tree-multiset.ts +0 -3
- package/src/data-structures/types/utils.ts +0 -173
- package/src/index.ts +0 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/utils.ts +0 -505
- package/tsconfig.json +0 -56
- /package/dist/{data-structures/types/abstract-graph.js → interfaces/abstract-binary-tree.js} +0 -0
- /package/dist/{data-structures/types/avl-tree.js → interfaces/abstract-graph.js} +0 -0
- /package/dist/{data-structures/types/binary-tree.js → interfaces/avl-tree.js} +0 -0
- /package/dist/{data-structures/types/bst.js → interfaces/binary-tree.js} +0 -0
- /package/dist/{data-structures/types/directed-graph.js → interfaces/bst.js} +0 -0
- /package/dist/{data-structures/types/doubly-linked-list.js → interfaces/directed-graph.js} +0 -0
- /package/{src/data-structures/hash/pair.ts → dist/interfaces/doubly-linked-list.d.ts} +0 -0
- /package/dist/{data-structures/types/heap.js → interfaces/doubly-linked-list.js} +0 -0
- /package/{src/data-structures/hash/tree-map.ts → dist/interfaces/heap.d.ts} +0 -0
- /package/dist/{data-structures/types/navigator.js → interfaces/heap.js} +0 -0
- /package/{src/data-structures/hash/tree-set.ts → dist/interfaces/navigator.d.ts} +0 -0
- /package/dist/{data-structures/types/priority-queue.js → interfaces/navigator.js} +0 -0
- /package/dist/{data-structures/types/segment-tree.js → interfaces/priority-queue.js} +0 -0
- /package/dist/{data-structures/types/singly-linked-list.js → interfaces/rb-tree.js} +0 -0
- /package/dist/{data-structures/types/tree-multiset.js → interfaces/segment-tree.js} +0 -0
- /package/dist/{data-structures/types → types/data-structures}/segment-tree.d.ts +0 -0
|
@@ -1,227 +1,252 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __values = (this && this.__values) || function(o) {
|
|
18
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
19
|
-
if (m) return m.call(o);
|
|
20
|
-
if (o && typeof o.length === "number") return {
|
|
21
|
-
next: function () {
|
|
22
|
-
if (o && i >= o.length) o = void 0;
|
|
23
|
-
return { value: o && o[i++], done: !o };
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
27
|
-
};
|
|
28
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
29
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
30
|
-
if (!m) return o;
|
|
31
|
-
var i = m.call(o), r, ar = [], e;
|
|
32
|
-
try {
|
|
33
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
34
|
-
}
|
|
35
|
-
catch (error) { e = { error: error }; }
|
|
36
|
-
finally {
|
|
37
|
-
try {
|
|
38
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
39
|
-
}
|
|
40
|
-
finally { if (e) throw e.error; }
|
|
41
|
-
}
|
|
42
|
-
return ar;
|
|
43
|
-
};
|
|
44
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
45
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
46
|
-
if (ar || !(i in from)) {
|
|
47
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
48
|
-
ar[i] = from[i];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
52
|
-
};
|
|
53
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
3
|
exports.UndirectedGraph = exports.UndirectedEdge = exports.UndirectedVertex = void 0;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
4
|
+
/**
|
|
5
|
+
* data-structure-typed
|
|
6
|
+
*
|
|
7
|
+
* @author Tyler Zeng
|
|
8
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
9
|
+
* @license MIT License
|
|
10
|
+
*/
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
const abstract_graph_1 = require("./abstract-graph");
|
|
13
|
+
class UndirectedVertex extends abstract_graph_1.AbstractVertex {
|
|
14
|
+
/**
|
|
15
|
+
* The constructor function initializes a vertex with an optional value.
|
|
16
|
+
* @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex. It is
|
|
17
|
+
* used to uniquely identify the vertex within a graph or network.
|
|
18
|
+
* @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to initialize the value of the
|
|
19
|
+
* vertex. If no value is provided, the vertex will be initialized with a default value.
|
|
20
|
+
*/
|
|
21
|
+
constructor(id, val) {
|
|
22
|
+
super(id, val);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
64
25
|
exports.UndirectedVertex = UndirectedVertex;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
26
|
+
class UndirectedEdge extends abstract_graph_1.AbstractEdge {
|
|
27
|
+
/**
|
|
28
|
+
* The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional
|
|
29
|
+
* value.
|
|
30
|
+
* @param {VertexId} v1 - The first vertex ID of the edge.
|
|
31
|
+
* @param {VertexId} v2 - The parameter `v2` is a `VertexId`, which represents the identifier of the second vertex in a
|
|
32
|
+
* graph edge.
|
|
33
|
+
* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
|
|
34
|
+
* @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to store a value associated
|
|
35
|
+
* with the edge.
|
|
36
|
+
*/
|
|
37
|
+
constructor(v1, v2, weight, val) {
|
|
38
|
+
super(weight, val);
|
|
39
|
+
this._vertices = [v1, v2];
|
|
40
|
+
}
|
|
41
|
+
get vertices() {
|
|
42
|
+
return this._vertices;
|
|
43
|
+
}
|
|
44
|
+
set vertices(v) {
|
|
45
|
+
this._vertices = v;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
84
48
|
exports.UndirectedEdge = UndirectedEdge;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
49
|
+
class UndirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
50
|
+
/**
|
|
51
|
+
* The constructor initializes a new Map object to store edges.
|
|
52
|
+
*/
|
|
53
|
+
constructor() {
|
|
54
|
+
super();
|
|
55
|
+
this._edges = new Map();
|
|
56
|
+
}
|
|
57
|
+
get edges() {
|
|
58
|
+
return this._edges;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The function creates a new vertex with an optional value and returns it.
|
|
62
|
+
* @param {VertexId} id - The `id` parameter is the unique identifier for the vertex. It is used to distinguish one
|
|
63
|
+
* vertex from another in the graph.
|
|
64
|
+
* @param [val] - The `val` parameter is an optional value that can be assigned to the vertex. If a value is provided,
|
|
65
|
+
* it will be used as the value of the vertex. If no value is provided, the `id` parameter will be used as the value of
|
|
66
|
+
* the vertex.
|
|
67
|
+
* @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `V`.
|
|
68
|
+
*/
|
|
69
|
+
createVertex(id, val) {
|
|
70
|
+
return new UndirectedVertex(id, val !== null && val !== void 0 ? val : id);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The function creates an undirected edge between two vertices with an optional weight and value.
|
|
74
|
+
* @param {VertexId} v1 - The parameter `v1` represents the first vertex of the edge.
|
|
75
|
+
* @param {VertexId} v2 - The parameter `v2` represents the second vertex of the edge.
|
|
76
|
+
* @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. If
|
|
77
|
+
* no weight is provided, it defaults to 1.
|
|
78
|
+
* @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type and
|
|
79
|
+
* is used to store additional information or data associated with the edge.
|
|
80
|
+
* @returns a new instance of the `UndirectedEdge` class, which is casted as type `E`.
|
|
81
|
+
*/
|
|
82
|
+
createEdge(v1, v2, weight, val) {
|
|
83
|
+
return new UndirectedEdge(v1, v2, weight !== null && weight !== void 0 ? weight : 1, val);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
|
|
87
|
+
* @param {V | null | VertexId} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `V` (vertex
|
|
88
|
+
* object), `null`, or `VertexId` (a string or number representing the ID of a vertex).
|
|
89
|
+
* @param {V | null | VertexId} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `V` (vertex
|
|
90
|
+
* object), `null`, or `VertexId` (vertex ID).
|
|
91
|
+
* @returns an edge (E) or null.
|
|
92
|
+
*/
|
|
93
|
+
getEdge(v1, v2) {
|
|
93
94
|
var _a;
|
|
94
|
-
|
|
95
|
+
let edges = [];
|
|
95
96
|
if (v1 !== null && v2 !== null) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (vertex1 &&
|
|
99
|
-
edges = (_a = this._edges.get(vertex1)) === null || _a === void 0 ? void 0 : _a.filter(
|
|
97
|
+
const vertex1 = this._getVertex(v1);
|
|
98
|
+
const vertex2 = this._getVertex(v2);
|
|
99
|
+
if (vertex1 && vertex2) {
|
|
100
|
+
edges = (_a = this._edges.get(vertex1)) === null || _a === void 0 ? void 0 : _a.filter(e => e.vertices.includes(vertex2.id));
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
return edges ? edges[0] || null : null;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (edges) {
|
|
115
|
-
edges.push(edge);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
this._edges.set(endVertex, [edge]);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
124
|
-
finally {
|
|
125
|
-
try {
|
|
126
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
127
|
-
}
|
|
128
|
-
finally { if (e_1) throw e_1.error; }
|
|
129
|
-
}
|
|
130
|
-
return true;
|
|
131
|
-
};
|
|
132
|
-
UndirectedGraph.prototype.removeEdgeBetween = function (v1, v2) {
|
|
133
|
-
var vertex1 = this.getVertex(v1);
|
|
134
|
-
var vertex2 = this.getVertex(v2);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The function removes an edge between two vertices in a graph and returns the removed edge.
|
|
107
|
+
* @param {V | VertexId} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexId`).
|
|
108
|
+
* @param {V | VertexId} v2 - V | VertexId - This parameter can be either a vertex object (V) or a vertex ID
|
|
109
|
+
* (VertexId). It represents the second vertex of the edge that needs to be removed.
|
|
110
|
+
* @returns the removed edge (E) if it exists, or null if either of the vertices (V) does not exist.
|
|
111
|
+
*/
|
|
112
|
+
removeEdgeBetween(v1, v2) {
|
|
113
|
+
const vertex1 = this._getVertex(v1);
|
|
114
|
+
const vertex2 = this._getVertex(v2);
|
|
135
115
|
if (!vertex1 || !vertex2) {
|
|
136
116
|
return null;
|
|
137
117
|
}
|
|
138
|
-
|
|
139
|
-
|
|
118
|
+
const v1Edges = this._edges.get(vertex1);
|
|
119
|
+
let removed = null;
|
|
140
120
|
if (v1Edges) {
|
|
141
|
-
removed = (0, utils_1.arrayRemove)(v1Edges,
|
|
121
|
+
removed = (0, utils_1.arrayRemove)(v1Edges, (e) => e.vertices.includes(vertex2.id))[0] || null;
|
|
142
122
|
}
|
|
143
|
-
|
|
123
|
+
const v2Edges = this._edges.get(vertex2);
|
|
144
124
|
if (v2Edges) {
|
|
145
|
-
(0, utils_1.arrayRemove)(v2Edges,
|
|
125
|
+
(0, utils_1.arrayRemove)(v2Edges, (e) => e.vertices.includes(vertex1.id));
|
|
146
126
|
}
|
|
147
127
|
return removed;
|
|
148
|
-
}
|
|
149
|
-
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The removeEdge function removes an edge between two vertices in a graph.
|
|
131
|
+
* @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
|
|
132
|
+
* @returns The method is returning either the removed edge (of type E) or null if the edge was not found.
|
|
133
|
+
*/
|
|
134
|
+
removeEdge(edge) {
|
|
150
135
|
return this.removeEdgeBetween(edge.vertices[0], edge.vertices[1]);
|
|
151
|
-
}
|
|
152
|
-
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
|
|
139
|
+
* vertex.
|
|
140
|
+
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`.
|
|
141
|
+
* @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
|
|
142
|
+
* edges connected to that vertex.
|
|
143
|
+
*/
|
|
144
|
+
degreeOf(vertexOrId) {
|
|
153
145
|
var _a;
|
|
154
|
-
|
|
146
|
+
const vertex = this._getVertex(vertexOrId);
|
|
155
147
|
if (vertex) {
|
|
156
148
|
return ((_a = this._edges.get(vertex)) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
157
149
|
}
|
|
158
150
|
else {
|
|
159
151
|
return 0;
|
|
160
152
|
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The function returns the edges of a given vertex or vertex ID.
|
|
156
|
+
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`. A `VertexId` is a
|
|
157
|
+
* unique identifier for a vertex in a graph, while `V` represents the type of the vertex.
|
|
158
|
+
* @returns an array of edges.
|
|
159
|
+
*/
|
|
160
|
+
edgesOf(vertexOrId) {
|
|
161
|
+
const vertex = this._getVertex(vertexOrId);
|
|
164
162
|
if (vertex) {
|
|
165
163
|
return this._edges.get(vertex) || [];
|
|
166
164
|
}
|
|
167
165
|
else {
|
|
168
166
|
return [];
|
|
169
167
|
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The function "edgeSet" returns an array of unique edges from a set of edges.
|
|
171
|
+
* @returns The method `edgeSet()` returns an array of type `E[]`.
|
|
172
|
+
*/
|
|
173
|
+
edgeSet() {
|
|
174
|
+
const edgeSet = new Set();
|
|
175
|
+
this._edges.forEach(edges => {
|
|
176
|
+
edges.forEach(edge => {
|
|
175
177
|
edgeSet.add(edge);
|
|
176
178
|
});
|
|
177
179
|
});
|
|
178
|
-
return
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
var neighbors = [];
|
|
190
|
-
var vertex = this.getVertex(vertexOrId);
|
|
180
|
+
return [...edgeSet];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
|
|
184
|
+
* @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a vertex object (`V`) or a vertex ID
|
|
185
|
+
* (`VertexId`).
|
|
186
|
+
* @returns an array of vertices (V[]).
|
|
187
|
+
*/
|
|
188
|
+
getNeighbors(vertexOrId) {
|
|
189
|
+
const neighbors = [];
|
|
190
|
+
const vertex = this._getVertex(vertexOrId);
|
|
191
191
|
if (vertex) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (neighbor) {
|
|
198
|
-
neighbors.push(neighbor);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
203
|
-
finally {
|
|
204
|
-
try {
|
|
205
|
-
if (neighborEdges_1_1 && !neighborEdges_1_1.done && (_a = neighborEdges_1.return)) _a.call(neighborEdges_1);
|
|
192
|
+
const neighborEdges = this.edgesOf(vertex);
|
|
193
|
+
for (const edge of neighborEdges) {
|
|
194
|
+
const neighbor = this._getVertex(edge.vertices.filter(e => e !== vertex.id)[0]);
|
|
195
|
+
if (neighbor) {
|
|
196
|
+
neighbors.push(neighbor);
|
|
206
197
|
}
|
|
207
|
-
finally { if (e_2) throw e_2.error; }
|
|
208
198
|
}
|
|
209
199
|
}
|
|
210
200
|
return neighbors;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
|
|
204
|
+
* it returns null.
|
|
205
|
+
* @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
|
|
206
|
+
* @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
|
|
207
|
+
* graph. If the edge does not exist, it returns `null`.
|
|
208
|
+
*/
|
|
209
|
+
getEndsOfEdge(edge) {
|
|
210
|
+
if (!this.hasEdge(edge.vertices[0], edge.vertices[1])) {
|
|
214
211
|
return null;
|
|
215
212
|
}
|
|
216
|
-
|
|
217
|
-
|
|
213
|
+
const v1 = this._getVertex(edge.vertices[0]);
|
|
214
|
+
const v2 = this._getVertex(edge.vertices[1]);
|
|
218
215
|
if (v1 && v2) {
|
|
219
216
|
return [v1, v2];
|
|
220
217
|
}
|
|
221
218
|
else {
|
|
222
219
|
return null;
|
|
223
220
|
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
|
|
224
|
+
* @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
|
|
225
|
+
* @returns a boolean value.
|
|
226
|
+
*/
|
|
227
|
+
_addEdgeOnly(edge) {
|
|
228
|
+
for (const end of edge.vertices) {
|
|
229
|
+
const endVertex = this._getVertex(end);
|
|
230
|
+
if (endVertex === null)
|
|
231
|
+
return false;
|
|
232
|
+
if (endVertex) {
|
|
233
|
+
const edges = this._edges.get(endVertex);
|
|
234
|
+
if (edges) {
|
|
235
|
+
edges.push(edge);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
this._edges.set(endVertex, [edge]);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The function sets the edges of a graph.
|
|
246
|
+
* @param v - A map where the keys are of type V and the values are arrays of type E.
|
|
247
|
+
*/
|
|
248
|
+
_setEdges(v) {
|
|
249
|
+
this._edges = v;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
227
252
|
exports.UndirectedGraph = UndirectedGraph;
|
|
@@ -1,8 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data-structure-typed
|
|
3
|
+
*
|
|
4
|
+
* @author Tyler Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
|
+
* @license MIT License
|
|
7
|
+
*/
|
|
1
8
|
export declare class CoordinateMap<V> extends Map<any, V> {
|
|
2
|
-
private readonly _joint;
|
|
3
9
|
constructor(joint?: string);
|
|
10
|
+
protected _joint: string;
|
|
11
|
+
get joint(): string;
|
|
12
|
+
/**
|
|
13
|
+
* The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
|
|
14
|
+
* key array with a specified delimiter.
|
|
15
|
+
* @param {number[]} key - The parameter "key" is an array of numbers.
|
|
16
|
+
* @returns The `has` method is being overridden to return the result of calling the `has` method of the superclass
|
|
17
|
+
* (`super.has`) with the `key` array joined together using the `_joint` property.
|
|
18
|
+
*/
|
|
4
19
|
has(key: number[]): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The function overrides the set method of a Map object to convert the key from an array to a string using a specified
|
|
22
|
+
* delimiter before calling the original set method.
|
|
23
|
+
* @param {number[]} key - The key parameter is an array of numbers.
|
|
24
|
+
* @param {V} value - The value parameter is the value that you want to associate with the specified key.
|
|
25
|
+
* @returns The `set` method is returning the result of calling the `set` method of the superclass
|
|
26
|
+
* (`super.set(key.join(this._joint), value)`).
|
|
27
|
+
*/
|
|
5
28
|
set(key: number[], value: V): this;
|
|
29
|
+
/**
|
|
30
|
+
* The function overrides the get method to join the key array with a specified joint and then calls the super get
|
|
31
|
+
* method.
|
|
32
|
+
* @param {number[]} key - An array of numbers
|
|
33
|
+
* @returns The code is returning the value associated with the specified key in the map.
|
|
34
|
+
*/
|
|
6
35
|
get(key: number[]): V | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The function overrides the delete method and joins the key array using a specified joint character before calling
|
|
38
|
+
* the super delete method.
|
|
39
|
+
* @param {number[]} key - An array of numbers that represents the key to be deleted.
|
|
40
|
+
* @returns The `delete` method is returning the result of calling the `delete` method on the superclass, with the
|
|
41
|
+
* `key` array joined together using the `_joint` property.
|
|
42
|
+
*/
|
|
7
43
|
delete(key: number[]): boolean;
|
|
44
|
+
protected _setJoint(v: string): void;
|
|
8
45
|
}
|
|
@@ -1,42 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.CoordinateMap = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
4
|
+
/**
|
|
5
|
+
* data-structure-typed
|
|
6
|
+
*
|
|
7
|
+
* @author Tyler Zeng
|
|
8
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
9
|
+
* @license MIT License
|
|
10
|
+
*/
|
|
11
|
+
class CoordinateMap extends Map {
|
|
12
|
+
constructor(joint) {
|
|
13
|
+
super();
|
|
14
|
+
this._joint = '_';
|
|
24
15
|
if (joint !== undefined)
|
|
25
|
-
|
|
26
|
-
return _this;
|
|
16
|
+
this._joint = joint;
|
|
27
17
|
}
|
|
28
|
-
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
18
|
+
get joint() {
|
|
19
|
+
return this._joint;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
|
|
23
|
+
* key array with a specified delimiter.
|
|
24
|
+
* @param {number[]} key - The parameter "key" is an array of numbers.
|
|
25
|
+
* @returns The `has` method is being overridden to return the result of calling the `has` method of the superclass
|
|
26
|
+
* (`super.has`) with the `key` array joined together using the `_joint` property.
|
|
27
|
+
*/
|
|
28
|
+
has(key) {
|
|
29
|
+
return super.has(key.join(this._joint));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The function overrides the set method of a Map object to convert the key from an array to a string using a specified
|
|
33
|
+
* delimiter before calling the original set method.
|
|
34
|
+
* @param {number[]} key - The key parameter is an array of numbers.
|
|
35
|
+
* @param {V} value - The value parameter is the value that you want to associate with the specified key.
|
|
36
|
+
* @returns The `set` method is returning the result of calling the `set` method of the superclass
|
|
37
|
+
* (`super.set(key.join(this._joint), value)`).
|
|
38
|
+
*/
|
|
39
|
+
set(key, value) {
|
|
40
|
+
return super.set(key.join(this._joint), value);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The function overrides the get method to join the key array with a specified joint and then calls the super get
|
|
44
|
+
* method.
|
|
45
|
+
* @param {number[]} key - An array of numbers
|
|
46
|
+
* @returns The code is returning the value associated with the specified key in the map.
|
|
47
|
+
*/
|
|
48
|
+
get(key) {
|
|
49
|
+
return super.get(key.join(this._joint));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The function overrides the delete method and joins the key array using a specified joint character before calling
|
|
53
|
+
* the super delete method.
|
|
54
|
+
* @param {number[]} key - An array of numbers that represents the key to be deleted.
|
|
55
|
+
* @returns The `delete` method is returning the result of calling the `delete` method on the superclass, with the
|
|
56
|
+
* `key` array joined together using the `_joint` property.
|
|
57
|
+
*/
|
|
58
|
+
delete(key) {
|
|
59
|
+
return super.delete(key.join(this._joint));
|
|
60
|
+
}
|
|
61
|
+
_setJoint(v) {
|
|
62
|
+
this._joint = v;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
42
65
|
exports.CoordinateMap = CoordinateMap;
|
|
@@ -1,7 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* data-structure-typed
|
|
3
|
+
*
|
|
4
|
+
* @author Tyler Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
|
+
* @license MIT License
|
|
7
|
+
*/
|
|
8
|
+
export declare class CoordinateSet extends Set<any> {
|
|
3
9
|
constructor(joint?: string);
|
|
10
|
+
protected _joint: string;
|
|
11
|
+
get joint(): string;
|
|
12
|
+
/**
|
|
13
|
+
* The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
|
|
14
|
+
* joining its elements with a specified separator.
|
|
15
|
+
* @param {number[]} value - The parameter "value" is an array of numbers.
|
|
16
|
+
* @returns The overridden `has` method is returning the result of calling the `has` method of the superclass, passing
|
|
17
|
+
* in the joined value as an argument.
|
|
18
|
+
*/
|
|
4
19
|
has(value: number[]): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The "add" function overrides the parent class's "add" function by joining the elements of the input array with a
|
|
22
|
+
* specified delimiter before calling the parent class's "add" function.
|
|
23
|
+
* @param {number[]} value - An array of numbers
|
|
24
|
+
* @returns The overridden `add` method is returning the result of calling the `add` method of the superclass
|
|
25
|
+
* (`super.add`) with the joined string representation of the `value` array (`value.join(this._joint)`).
|
|
26
|
+
*/
|
|
5
27
|
add(value: number[]): this;
|
|
28
|
+
/**
|
|
29
|
+
* The function overrides the delete method and deletes an element from a Set by joining the elements of the input
|
|
30
|
+
* array with a specified joint and then calling the delete method of the parent class.
|
|
31
|
+
* @param {number[]} value - An array of numbers
|
|
32
|
+
* @returns The `delete` method is returning the result of calling the `delete` method of the superclass, with the
|
|
33
|
+
* `value` array joined together using the `_joint` property.
|
|
34
|
+
*/
|
|
6
35
|
delete(value: number[]): boolean;
|
|
36
|
+
protected _setJoint(v: string): void;
|
|
7
37
|
}
|