data-structure-typed 0.8.18 → 0.9.16
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/.idea/modules.xml +1 -1
- package/README.md +197 -2
- package/dist/data-structures/binary-tree/aa-tree.js +5 -2
- package/dist/data-structures/binary-tree/avl-tree.d.ts +1 -5
- package/dist/data-structures/binary-tree/avl-tree.js +93 -46
- package/dist/data-structures/binary-tree/b-tree.js +5 -2
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -1
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +14 -13
- package/dist/data-structures/binary-tree/binary-tree.d.ts +20 -32
- package/dist/data-structures/binary-tree/binary-tree.js +480 -370
- package/dist/data-structures/binary-tree/bst.d.ts +4 -8
- package/dist/data-structures/binary-tree/bst.js +152 -107
- package/dist/data-structures/binary-tree/rb-tree.js +5 -2
- package/dist/data-structures/binary-tree/segment-tree.d.ts +3 -3
- package/dist/data-structures/binary-tree/segment-tree.js +91 -61
- package/dist/data-structures/binary-tree/splay-tree.js +5 -2
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +1 -5
- package/dist/data-structures/binary-tree/tree-multiset.js +31 -11
- package/dist/data-structures/binary-tree/two-three-tree.js +5 -2
- package/dist/data-structures/graph/abstract-graph.d.ts +5 -33
- package/dist/data-structures/graph/abstract-graph.js +546 -311
- package/dist/data-structures/graph/directed-graph.d.ts +5 -13
- package/dist/data-structures/graph/directed-graph.js +250 -128
- package/dist/data-structures/graph/undirected-graph.d.ts +4 -3
- package/dist/data-structures/graph/undirected-graph.js +166 -81
- package/dist/data-structures/hash/coordinate-map.d.ts +1 -1
- package/dist/data-structures/hash/coordinate-map.js +38 -20
- package/dist/data-structures/hash/coordinate-set.js +33 -15
- package/dist/data-structures/hash/index.d.ts +5 -0
- package/dist/data-structures/hash/index.js +5 -0
- package/dist/data-structures/heap/heap.d.ts +2 -8
- package/dist/data-structures/heap/heap.js +36 -31
- package/dist/data-structures/heap/max-heap.d.ts +3 -2
- package/dist/data-structures/heap/max-heap.js +27 -9
- package/dist/data-structures/heap/min-heap.d.ts +3 -2
- package/dist/data-structures/heap/min-heap.js +27 -9
- package/dist/data-structures/index.d.ts +1 -0
- package/dist/data-structures/index.js +1 -0
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +0 -1
- package/dist/data-structures/linked-list/doubly-linked-list.js +56 -53
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +8 -12
- package/dist/data-structures/linked-list/singly-linked-list.js +308 -174
- package/dist/data-structures/matrix/matrix.js +8 -7
- package/dist/data-structures/matrix/matrix2d.d.ts +5 -5
- package/dist/data-structures/matrix/matrix2d.js +80 -63
- package/dist/data-structures/matrix/navigator.d.ts +2 -16
- package/dist/data-structures/matrix/navigator.js +37 -18
- package/dist/data-structures/matrix/vector2d.d.ts +18 -18
- package/dist/data-structures/matrix/vector2d.js +117 -94
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +3 -2
- package/dist/data-structures/priority-queue/max-priority-queue.js +25 -8
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +3 -2
- package/dist/data-structures/priority-queue/min-priority-queue.js +25 -8
- package/dist/data-structures/priority-queue/priority-queue.d.ts +15 -21
- package/dist/data-structures/priority-queue/priority-queue.js +159 -116
- package/dist/data-structures/queue/deque.js +82 -56
- package/dist/data-structures/queue/queue.d.ts +9 -10
- package/dist/data-structures/queue/queue.js +34 -34
- package/dist/data-structures/stack/stack.d.ts +9 -10
- package/dist/data-structures/stack/stack.js +31 -31
- package/dist/data-structures/trampoline.d.ts +14 -23
- package/dist/data-structures/trampoline.js +103 -25
- package/dist/data-structures/trie/trie.d.ts +13 -3
- package/dist/data-structures/trie/trie.js +234 -80
- package/dist/data-structures/types/abstract-graph.d.ts +29 -0
- package/dist/data-structures/types/abstract-graph.js +2 -0
- package/dist/data-structures/types/avl-tree.d.ts +5 -0
- package/dist/data-structures/types/avl-tree.js +2 -0
- package/dist/data-structures/types/binary-tree.d.ts +16 -0
- package/dist/data-structures/types/binary-tree.js +2 -0
- package/dist/data-structures/types/bst.d.ts +7 -0
- package/dist/data-structures/types/bst.js +2 -0
- package/dist/data-structures/types/directed-graph.d.ts +10 -0
- package/dist/data-structures/types/directed-graph.js +2 -0
- package/dist/data-structures/types/doubly-linked-list.d.ts +1 -0
- package/dist/data-structures/types/doubly-linked-list.js +2 -0
- package/dist/data-structures/types/heap.d.ts +7 -0
- package/dist/data-structures/types/heap.js +2 -0
- package/dist/data-structures/types/index.d.ts +13 -0
- package/dist/data-structures/types/index.js +29 -0
- package/dist/data-structures/types/navigator.d.ts +14 -0
- package/dist/data-structures/types/navigator.js +2 -0
- package/dist/data-structures/types/priority-queue.d.ts +7 -0
- package/dist/data-structures/types/priority-queue.js +2 -0
- package/dist/data-structures/types/segment-tree.d.ts +1 -0
- package/dist/data-structures/types/segment-tree.js +2 -0
- package/dist/data-structures/types/singly-linked-list.d.ts +5 -0
- package/dist/data-structures/types/singly-linked-list.js +2 -0
- package/dist/data-structures/types/tree-multiset.d.ts +5 -0
- package/dist/data-structures/types/tree-multiset.js +2 -0
- package/dist/{types → data-structures/types}/utils.d.ts +7 -1
- package/dist/{types → data-structures/types}/utils.js +20 -19
- package/dist/{utils.d.ts → utils/utils.d.ts} +6 -23
- package/dist/utils/utils.js +651 -0
- package/package.json +20 -42
- package/src/data-structures/binary-tree/avl-tree.ts +1 -6
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +4 -4
- package/src/data-structures/binary-tree/binary-tree.ts +184 -139
- package/src/data-structures/binary-tree/bst.ts +15 -24
- 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/segment-tree.ts +20 -12
- package/src/data-structures/binary-tree/tree-multiset.ts +1 -4
- package/src/data-structures/diagrams/README.md +7 -0
- package/src/data-structures/graph/abstract-graph.ts +58 -94
- 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 +12 -28
- package/src/data-structures/graph/undirected-graph.ts +11 -10
- package/src/data-structures/hash/coordinate-map.ts +1 -1
- package/src/data-structures/hash/index.ts +5 -0
- package/src/data-structures/heap/heap.ts +2 -11
- package/src/data-structures/heap/max-heap.ts +3 -2
- package/src/data-structures/heap/min-heap.ts +3 -2
- package/src/data-structures/index.ts +1 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +1 -9
- package/src/data-structures/linked-list/singly-linked-list.ts +18 -32
- package/src/data-structures/matrix/matrix2d.ts +11 -11
- package/src/data-structures/matrix/navigator.ts +2 -14
- package/src/data-structures/matrix/vector2d.ts +52 -52
- package/src/data-structures/priority-queue/max-priority-queue.ts +4 -3
- package/src/data-structures/priority-queue/min-priority-queue.ts +4 -3
- package/src/data-structures/priority-queue/priority-queue.ts +70 -78
- package/src/data-structures/queue/deque.ts +2 -2
- package/src/data-structures/queue/queue.ts +12 -13
- package/src/data-structures/stack/stack.ts +12 -13
- package/src/data-structures/trampoline.ts +31 -71
- package/src/data-structures/trie/trie.ts +61 -11
- package/src/data-structures/types/abstract-graph.ts +51 -0
- package/src/data-structures/types/avl-tree.ts +6 -0
- package/src/data-structures/types/binary-tree.ts +15 -0
- package/src/data-structures/types/bst.ts +5 -0
- package/src/data-structures/types/directed-graph.ts +18 -0
- package/src/data-structures/types/doubly-linked-list.ts +1 -0
- package/src/data-structures/types/heap.ts +8 -0
- package/src/data-structures/types/index.ts +13 -0
- package/src/data-structures/types/navigator.ts +12 -0
- package/src/data-structures/types/priority-queue.ts +9 -0
- package/src/data-structures/types/segment-tree.ts +1 -0
- package/src/data-structures/types/singly-linked-list.ts +15 -0
- package/src/data-structures/types/tree-multiset.ts +3 -0
- package/src/{types → data-structures/types}/utils.ts +20 -5
- package/src/utils/index.ts +1 -0
- package/src/{utils.ts → utils/utils.ts} +32 -132
- package/tsconfig.json +9 -6
- package/dist/types/data-structures/binary-tree/aa-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -21
- package/dist/types/data-structures/binary-tree/b-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -8
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -140
- package/dist/types/data-structures/binary-tree/bst.d.ts +0 -32
- package/dist/types/data-structures/binary-tree/index.d.ts +0 -4
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +0 -33
- package/dist/types/data-structures/binary-tree/splay-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/tree-multiset.d.ts +0 -11
- package/dist/types/data-structures/binary-tree/two-three-tree.d.ts +0 -2
- package/dist/types/data-structures/graph/abstract-graph.d.ts +0 -126
- package/dist/types/data-structures/graph/directed-graph.d.ts +0 -51
- package/dist/types/data-structures/graph/index.d.ts +0 -3
- package/dist/types/data-structures/graph/undirected-graph.d.ts +0 -24
- package/dist/types/data-structures/hash/coordinate-map.d.ts +0 -8
- package/dist/types/data-structures/hash/coordinate-set.d.ts +0 -7
- package/dist/types/data-structures/hash/hash-table.d.ts +0 -1
- package/dist/types/data-structures/hash/index.d.ts +0 -1
- package/dist/types/data-structures/hash/pair.d.ts +0 -1
- package/dist/types/data-structures/hash/tree-map.d.ts +0 -1
- package/dist/types/data-structures/hash/tree-set.d.ts +0 -1
- package/dist/types/data-structures/heap/heap.d.ts +0 -72
- package/dist/types/data-structures/heap/index.d.ts +0 -3
- package/dist/types/data-structures/heap/max-heap.d.ts +0 -14
- package/dist/types/data-structures/heap/min-heap.d.ts +0 -14
- package/dist/types/data-structures/index.d.ts +0 -9
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -59
- package/dist/types/data-structures/linked-list/index.d.ts +0 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +0 -358
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +0 -1
- package/dist/types/data-structures/matrix/index.d.ts +0 -3
- package/dist/types/data-structures/matrix/matrix.d.ts +0 -9
- package/dist/types/data-structures/matrix/matrix2d.d.ts +0 -25
- package/dist/types/data-structures/matrix/navigator.d.ts +0 -31
- package/dist/types/data-structures/matrix/vector2d.d.ts +0 -74
- package/dist/types/data-structures/priority-queue/index.d.ts +0 -3
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -4
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -4
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +0 -36
- package/dist/types/data-structures/queue/deque.d.ts +0 -37
- package/dist/types/data-structures/queue/index.d.ts +0 -1
- package/dist/types/data-structures/queue/queue.d.ts +0 -76
- package/dist/types/data-structures/stack/index.d.ts +0 -1
- package/dist/types/data-structures/stack/stack.d.ts +0 -69
- package/dist/types/data-structures/trampoline.d.ts +0 -25
- package/dist/types/data-structures/trie/index.d.ts +0 -1
- package/dist/types/data-structures/trie/trie.d.ts +0 -28
- package/dist/types/types/index.d.ts +0 -1
- package/dist/types/types/utils.d.ts +0 -46
- package/dist/utils.js +0 -569
- package/src/types/index.ts +0 -1
- package/src/types/patches/index.d.ts +0 -0
- /package/dist/{types → utils}/index.d.ts +0 -0
- /package/dist/{types → utils}/index.js +0 -0
|
@@ -1,44 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SegmentTree = exports.SegmentTreeNode = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return this._start;
|
|
7
|
-
}
|
|
8
|
-
set start(v) {
|
|
9
|
-
this._start = v;
|
|
10
|
-
}
|
|
11
|
-
get end() {
|
|
12
|
-
return this._end;
|
|
13
|
-
}
|
|
14
|
-
set end(v) {
|
|
15
|
-
this._end = v;
|
|
16
|
-
}
|
|
17
|
-
get val() {
|
|
18
|
-
return this._val;
|
|
19
|
-
}
|
|
20
|
-
set val(v) {
|
|
21
|
-
this._val = v;
|
|
22
|
-
}
|
|
23
|
-
get sum() {
|
|
24
|
-
return this._sum;
|
|
25
|
-
}
|
|
26
|
-
set sum(v) {
|
|
27
|
-
this._sum = v;
|
|
28
|
-
}
|
|
29
|
-
get left() {
|
|
30
|
-
return this._left;
|
|
31
|
-
}
|
|
32
|
-
set left(v) {
|
|
33
|
-
this._left = v;
|
|
34
|
-
}
|
|
35
|
-
get right() {
|
|
36
|
-
return this._right;
|
|
37
|
-
}
|
|
38
|
-
set right(v) {
|
|
39
|
-
this._right = v;
|
|
40
|
-
}
|
|
41
|
-
constructor(start, end, sum, val) {
|
|
4
|
+
var SegmentTreeNode = /** @class */ (function () {
|
|
5
|
+
function SegmentTreeNode(start, end, sum, val) {
|
|
42
6
|
this._start = 0;
|
|
43
7
|
this._end = 0;
|
|
44
8
|
this._val = null;
|
|
@@ -50,13 +14,71 @@ class SegmentTreeNode {
|
|
|
50
14
|
this._sum = sum;
|
|
51
15
|
this._val = val || null;
|
|
52
16
|
}
|
|
53
|
-
|
|
17
|
+
Object.defineProperty(SegmentTreeNode.prototype, "start", {
|
|
18
|
+
get: function () {
|
|
19
|
+
return this._start;
|
|
20
|
+
},
|
|
21
|
+
set: function (v) {
|
|
22
|
+
this._start = v;
|
|
23
|
+
},
|
|
24
|
+
enumerable: false,
|
|
25
|
+
configurable: true
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(SegmentTreeNode.prototype, "end", {
|
|
28
|
+
get: function () {
|
|
29
|
+
return this._end;
|
|
30
|
+
},
|
|
31
|
+
set: function (v) {
|
|
32
|
+
this._end = v;
|
|
33
|
+
},
|
|
34
|
+
enumerable: false,
|
|
35
|
+
configurable: true
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(SegmentTreeNode.prototype, "val", {
|
|
38
|
+
get: function () {
|
|
39
|
+
return this._val;
|
|
40
|
+
},
|
|
41
|
+
set: function (v) {
|
|
42
|
+
this._val = v;
|
|
43
|
+
},
|
|
44
|
+
enumerable: false,
|
|
45
|
+
configurable: true
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(SegmentTreeNode.prototype, "sum", {
|
|
48
|
+
get: function () {
|
|
49
|
+
return this._sum;
|
|
50
|
+
},
|
|
51
|
+
set: function (v) {
|
|
52
|
+
this._sum = v;
|
|
53
|
+
},
|
|
54
|
+
enumerable: false,
|
|
55
|
+
configurable: true
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(SegmentTreeNode.prototype, "left", {
|
|
58
|
+
get: function () {
|
|
59
|
+
return this._left;
|
|
60
|
+
},
|
|
61
|
+
set: function (v) {
|
|
62
|
+
this._left = v;
|
|
63
|
+
},
|
|
64
|
+
enumerable: false,
|
|
65
|
+
configurable: true
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(SegmentTreeNode.prototype, "right", {
|
|
68
|
+
get: function () {
|
|
69
|
+
return this._right;
|
|
70
|
+
},
|
|
71
|
+
set: function (v) {
|
|
72
|
+
this._right = v;
|
|
73
|
+
},
|
|
74
|
+
enumerable: false,
|
|
75
|
+
configurable: true
|
|
76
|
+
});
|
|
77
|
+
return SegmentTreeNode;
|
|
78
|
+
}());
|
|
54
79
|
exports.SegmentTreeNode = SegmentTreeNode;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return this._root;
|
|
58
|
-
}
|
|
59
|
-
constructor(values, start, end) {
|
|
80
|
+
var SegmentTree = /** @class */ (function () {
|
|
81
|
+
function SegmentTree(values, start, end) {
|
|
60
82
|
this._values = [];
|
|
61
83
|
this._start = 0;
|
|
62
84
|
start = start || 0;
|
|
@@ -66,30 +88,37 @@ class SegmentTree {
|
|
|
66
88
|
this._end = end;
|
|
67
89
|
this._root = this.build(start, end);
|
|
68
90
|
}
|
|
69
|
-
|
|
91
|
+
Object.defineProperty(SegmentTree.prototype, "root", {
|
|
92
|
+
get: function () {
|
|
93
|
+
return this._root;
|
|
94
|
+
},
|
|
95
|
+
enumerable: false,
|
|
96
|
+
configurable: true
|
|
97
|
+
});
|
|
98
|
+
SegmentTree.prototype.build = function (start, end) {
|
|
70
99
|
if (start === end) {
|
|
71
100
|
return new SegmentTreeNode(start, end, this._values[start]);
|
|
72
101
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
102
|
+
var mid = start + Math.floor((end - start) / 2);
|
|
103
|
+
var left = this.build(start, mid);
|
|
104
|
+
var right = this.build(mid + 1, end);
|
|
105
|
+
var cur = new SegmentTreeNode(start, end, left.sum + right.sum);
|
|
77
106
|
cur.left = left;
|
|
78
107
|
cur.right = right;
|
|
79
108
|
return cur;
|
|
80
|
-
}
|
|
81
|
-
updateNode(index, sum, val) {
|
|
82
|
-
|
|
109
|
+
};
|
|
110
|
+
SegmentTree.prototype.updateNode = function (index, sum, val) {
|
|
111
|
+
var root = this.root || null;
|
|
83
112
|
if (!root) {
|
|
84
113
|
return;
|
|
85
114
|
}
|
|
86
|
-
|
|
115
|
+
var dfs = function (cur, index, sum, val) {
|
|
87
116
|
if (cur.start === cur.end && cur.start === index) {
|
|
88
117
|
cur.sum = sum;
|
|
89
118
|
// cur.val = val;
|
|
90
119
|
return;
|
|
91
120
|
}
|
|
92
|
-
|
|
121
|
+
var mid = cur.start + Math.floor((cur.end - cur.start) / 2);
|
|
93
122
|
if (index <= mid) {
|
|
94
123
|
if (cur.left) {
|
|
95
124
|
dfs(cur.left, index, sum, val);
|
|
@@ -105,17 +134,17 @@ class SegmentTree {
|
|
|
105
134
|
}
|
|
106
135
|
};
|
|
107
136
|
dfs(root, index, sum);
|
|
108
|
-
}
|
|
109
|
-
querySumByRange(indexA, indexB) {
|
|
110
|
-
|
|
137
|
+
};
|
|
138
|
+
SegmentTree.prototype.querySumByRange = function (indexA, indexB) {
|
|
139
|
+
var root = this.root || null;
|
|
111
140
|
if (!root) {
|
|
112
141
|
return 0;
|
|
113
142
|
}
|
|
114
|
-
|
|
143
|
+
var dfs = function (cur, i, j) {
|
|
115
144
|
if (cur.start === i && cur.end === j) {
|
|
116
145
|
return cur.sum;
|
|
117
146
|
}
|
|
118
|
-
|
|
147
|
+
var mid = cur.start + Math.floor((cur.end - cur.start) / 2);
|
|
119
148
|
if (j <= mid) {
|
|
120
149
|
// TODO after no-non-null-assertion not ensure the logic
|
|
121
150
|
if (cur.left) {
|
|
@@ -146,6 +175,7 @@ class SegmentTree {
|
|
|
146
175
|
}
|
|
147
176
|
};
|
|
148
177
|
return dfs(root, indexA, indexB);
|
|
149
|
-
}
|
|
150
|
-
|
|
178
|
+
};
|
|
179
|
+
return SegmentTree;
|
|
180
|
+
}());
|
|
151
181
|
exports.SegmentTree = SegmentTree;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SplayTree = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
var SplayTree = /** @class */ (function () {
|
|
5
|
+
function SplayTree() {
|
|
6
|
+
}
|
|
7
|
+
return SplayTree;
|
|
8
|
+
}());
|
|
6
9
|
exports.SplayTree = SplayTree;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { BST, BSTNode } from './bst';
|
|
2
|
-
import { BinaryTreeNodeId } from '
|
|
3
|
-
export type TreeMultiSetDeletedResult<T> = {
|
|
4
|
-
deleted: BSTNode<T> | null;
|
|
5
|
-
needBalanced: BSTNode<T> | null;
|
|
6
|
-
};
|
|
2
|
+
import type { BinaryTreeNodeId, TreeMultiSetDeletedResult } from '../types';
|
|
7
3
|
export declare class TreeMultiSet<T> extends BST<T> {
|
|
8
4
|
createNode(id: BinaryTreeNodeId, val: T, count?: number): BSTNode<T>;
|
|
9
5
|
put(id: BinaryTreeNodeId, val: T | null, count?: number): BSTNode<T> | null;
|
|
@@ -1,16 +1,36 @@
|
|
|
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
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.TreeMultiSet = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
put(id, val, count) {
|
|
10
|
-
return super.put(id, val, count);
|
|
19
|
+
var bst_1 = require("./bst");
|
|
20
|
+
var TreeMultiSet = /** @class */ (function (_super) {
|
|
21
|
+
__extends(TreeMultiSet, _super);
|
|
22
|
+
function TreeMultiSet() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
11
24
|
}
|
|
12
|
-
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
|
|
25
|
+
TreeMultiSet.prototype.createNode = function (id, val, count) {
|
|
26
|
+
return new bst_1.BSTNode(id, val, count);
|
|
27
|
+
};
|
|
28
|
+
TreeMultiSet.prototype.put = function (id, val, count) {
|
|
29
|
+
return _super.prototype.put.call(this, id, val, count);
|
|
30
|
+
};
|
|
31
|
+
TreeMultiSet.prototype.remove = function (id, isUpdateAllLeftSum) {
|
|
32
|
+
return _super.prototype.remove.call(this, id, isUpdateAllLeftSum);
|
|
33
|
+
};
|
|
34
|
+
return TreeMultiSet;
|
|
35
|
+
}(bst_1.BST));
|
|
16
36
|
exports.TreeMultiSet = TreeMultiSet;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TwoThreeTree = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
var TwoThreeTree = /** @class */ (function () {
|
|
5
|
+
function TwoThreeTree() {
|
|
6
|
+
}
|
|
7
|
+
return TwoThreeTree;
|
|
8
|
+
}());
|
|
6
9
|
exports.TwoThreeTree = TwoThreeTree;
|
|
@@ -1,49 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
export type DijkstraResult<V> = {
|
|
3
|
-
distMap: Map<V, number>;
|
|
4
|
-
preMap: Map<V, V | null>;
|
|
5
|
-
seen: Set<V>;
|
|
6
|
-
paths: V[][];
|
|
7
|
-
minDist: number;
|
|
8
|
-
minPath: V[];
|
|
9
|
-
} | null;
|
|
10
|
-
export interface I_Graph<V, E> {
|
|
11
|
-
containsVertex(vertexOrId: V | VertexId): boolean;
|
|
12
|
-
getVertex(vertexOrId: VertexId | V): V | null;
|
|
13
|
-
getVertexId(vertexOrId: V | VertexId): VertexId;
|
|
14
|
-
vertexSet(): Map<VertexId, V>;
|
|
15
|
-
addVertex(v: V): boolean;
|
|
16
|
-
removeVertex(vertexOrId: V | VertexId): boolean;
|
|
17
|
-
removeAllVertices(vertices: V[] | VertexId[]): boolean;
|
|
18
|
-
degreeOf(vertexOrId: V | VertexId): number;
|
|
19
|
-
edgesOf(vertexOrId: V | VertexId): E[];
|
|
20
|
-
containsEdge(src: V | VertexId, dest: V | VertexId): boolean;
|
|
21
|
-
getEdge(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
|
|
22
|
-
edgeSet(): E[];
|
|
23
|
-
addEdge(edge: E): boolean;
|
|
24
|
-
removeEdgeBetween(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
|
|
25
|
-
removeEdge(edge: E): E | null;
|
|
26
|
-
setEdgeWeight(srcOrId: V | VertexId, destOrId: V | VertexId, weight: number): boolean;
|
|
27
|
-
getMinPathBetween(v1: V | VertexId, v2: V | VertexId, isWeight?: boolean): V[] | null;
|
|
28
|
-
getNeighbors(vertexOrId: V | VertexId): V[];
|
|
29
|
-
}
|
|
1
|
+
import type { DijkstraResult, IGraph, VertexId } from '../types';
|
|
30
2
|
export declare class AbstractVertex {
|
|
3
|
+
constructor(id: VertexId);
|
|
31
4
|
private _id;
|
|
32
5
|
get id(): VertexId;
|
|
33
6
|
set id(v: VertexId);
|
|
34
|
-
constructor(id: VertexId);
|
|
35
7
|
}
|
|
36
8
|
export declare abstract class AbstractEdge {
|
|
9
|
+
static DEFAULT_EDGE_WEIGHT: number;
|
|
10
|
+
protected constructor(weight?: number);
|
|
37
11
|
private _weight;
|
|
38
12
|
get weight(): number;
|
|
39
13
|
set weight(v: number);
|
|
40
14
|
private _hashCode;
|
|
41
15
|
get hashCode(): string;
|
|
42
16
|
set hashCode(v: string);
|
|
43
|
-
protected constructor(weight?: number);
|
|
44
|
-
static DEFAULT_EDGE_WEIGHT: number;
|
|
45
17
|
}
|
|
46
|
-
export declare abstract class AbstractGraph<V extends AbstractVertex, E extends AbstractEdge> implements
|
|
18
|
+
export declare abstract class AbstractGraph<V extends AbstractVertex, E extends AbstractEdge> implements IGraph<V, E> {
|
|
47
19
|
protected _vertices: Map<VertexId, V>;
|
|
48
20
|
abstract removeEdgeBetween(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
|
|
49
21
|
abstract removeEdge(edge: E): E | null;
|