data-structure-typed 1.34.8 → 1.35.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/.eslintrc.js +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/custom.md +10 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/CHANGELOG.md +1 -1
- package/CONTRIBUTING.md +0 -0
- package/README.md +8 -8
- package/dist/data-structures/binary-tree/aa-tree.js +2 -5
- package/dist/data-structures/binary-tree/aa-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +280 -423
- package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/avl-tree.js +63 -89
- package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/b-tree.js +2 -5
- package/dist/data-structures/binary-tree/b-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +17 -22
- package/dist/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/binary-tree.js +11 -30
- package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/bst.js +127 -214
- package/dist/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/data-structures/binary-tree/rb-tree.js +19 -43
- package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/segment-tree.js +80 -122
- package/dist/data-structures/binary-tree/segment-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/splay-tree.js +2 -5
- package/dist/data-structures/binary-tree/splay-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/tree-multiset.js +147 -218
- package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -1
- package/dist/data-structures/binary-tree/two-three-tree.js +2 -5
- package/dist/data-structures/binary-tree/two-three-tree.js.map +1 -1
- package/dist/data-structures/graph/abstract-graph.js +338 -572
- package/dist/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/data-structures/graph/directed-graph.js +145 -275
- package/dist/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/data-structures/graph/map-graph.js +46 -87
- package/dist/data-structures/graph/map-graph.js.map +1 -1
- package/dist/data-structures/graph/undirected-graph.js +90 -179
- package/dist/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/data-structures/hash/coordinate-map.js +23 -45
- package/dist/data-structures/hash/coordinate-map.js.map +1 -1
- package/dist/data-structures/hash/coordinate-set.js +20 -42
- package/dist/data-structures/hash/coordinate-set.js.map +1 -1
- package/dist/data-structures/hash/hash-map.js +85 -247
- package/dist/data-structures/hash/hash-map.js.map +1 -1
- package/dist/data-structures/hash/hash-table.js +87 -128
- package/dist/data-structures/hash/hash-table.js.map +1 -1
- package/dist/data-structures/hash/pair.js +2 -5
- package/dist/data-structures/hash/pair.js.map +1 -1
- package/dist/data-structures/hash/tree-map.js +2 -5
- package/dist/data-structures/hash/tree-map.js.map +1 -1
- package/dist/data-structures/hash/tree-set.js +2 -5
- package/dist/data-structures/hash/tree-set.js.map +1 -1
- package/dist/data-structures/heap/heap.js +56 -80
- package/dist/data-structures/heap/heap.js.map +1 -1
- package/dist/data-structures/heap/max-heap.js +8 -26
- package/dist/data-structures/heap/max-heap.js.map +1 -1
- package/dist/data-structures/heap/min-heap.js +8 -26
- package/dist/data-structures/heap/min-heap.js.map +1 -1
- package/dist/data-structures/linked-list/doubly-linked-list.js +149 -218
- package/dist/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/data-structures/linked-list/singly-linked-list.js +119 -218
- package/dist/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/data-structures/linked-list/skip-linked-list.js +50 -70
- package/dist/data-structures/linked-list/skip-linked-list.js.map +1 -1
- package/dist/data-structures/matrix/matrix.js +7 -8
- package/dist/data-structures/matrix/matrix.js.map +1 -1
- package/dist/data-structures/matrix/matrix2d.js +57 -70
- package/dist/data-structures/matrix/matrix2d.js.map +1 -1
- package/dist/data-structures/matrix/navigator.js +18 -37
- package/dist/data-structures/matrix/navigator.js.map +1 -1
- package/dist/data-structures/matrix/vector2d.js +63 -84
- package/dist/data-structures/matrix/vector2d.js.map +1 -1
- package/dist/data-structures/priority-queue/max-priority-queue.js +13 -41
- package/dist/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/data-structures/priority-queue/min-priority-queue.js +13 -41
- package/dist/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/data-structures/priority-queue/priority-queue.js +93 -139
- package/dist/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/data-structures/queue/deque.js +82 -128
- package/dist/data-structures/queue/deque.js.map +1 -1
- package/dist/data-structures/queue/queue.js +57 -157
- package/dist/data-structures/queue/queue.js.map +1 -1
- package/dist/data-structures/stack/stack.js +21 -22
- package/dist/data-structures/stack/stack.js.map +1 -1
- package/dist/data-structures/tree/tree.js +32 -45
- package/dist/data-structures/tree/tree.js.map +1 -1
- package/dist/data-structures/trie/trie.js +93 -200
- package/dist/data-structures/trie/trie.js.map +1 -1
- package/dist/types/data-structures/abstract-binary-tree.js.map +1 -1
- package/dist/utils/utils.js +22 -107
- package/dist/utils/utils.js.map +1 -1
- package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +79 -78
- package/lib/data-structures/binary-tree/abstract-binary-tree.js +61 -141
- package/lib/data-structures/binary-tree/avl-tree.d.ts +9 -0
- package/lib/data-structures/binary-tree/avl-tree.js +22 -0
- package/lib/data-structures/binary-tree/bst.d.ts +3 -3
- package/lib/data-structures/binary-tree/bst.js +12 -15
- package/lib/data-structures/binary-tree/tree-multiset.d.ts +16 -18
- package/lib/data-structures/binary-tree/tree-multiset.js +26 -36
- package/lib/data-structures/graph/abstract-graph.d.ts +2 -2
- package/lib/data-structures/graph/abstract-graph.js +5 -5
- package/lib/data-structures/priority-queue/priority-queue.d.ts +3 -3
- package/lib/data-structures/priority-queue/priority-queue.js +3 -3
- package/lib/interfaces/abstract-binary-tree.d.ts +1 -83
- package/lib/interfaces/abstract-graph.d.ts +2 -14
- package/lib/interfaces/avl-tree.d.ts +3 -4
- package/lib/interfaces/binary-tree.d.ts +4 -2
- package/lib/interfaces/bst.d.ts +2 -12
- package/lib/interfaces/directed-graph.d.ts +0 -9
- package/lib/interfaces/rb-tree.d.ts +2 -3
- package/lib/interfaces/tree-multiset.d.ts +5 -4
- package/lib/interfaces/undirected-graph.d.ts +0 -2
- package/lib/types/data-structures/abstract-binary-tree.js +0 -1
- package/package.json +7 -7
- package/src/data-structures/binary-tree/abstract-binary-tree.ts +151 -203
- package/src/data-structures/binary-tree/avl-tree.ts +29 -0
- package/src/data-structures/binary-tree/bst.ts +12 -15
- package/src/data-structures/binary-tree/tree-multiset.ts +27 -39
- package/src/data-structures/graph/abstract-graph.ts +5 -5
- package/src/data-structures/priority-queue/priority-queue.ts +3 -3
- package/src/interfaces/abstract-binary-tree.ts +2 -183
- package/src/interfaces/abstract-graph.ts +2 -26
- package/src/interfaces/avl-tree.ts +4 -21
- package/src/interfaces/binary-tree.ts +3 -2
- package/src/interfaces/bst.ts +2 -27
- package/src/interfaces/directed-graph.ts +1 -18
- package/src/interfaces/rb-tree.ts +2 -5
- package/src/interfaces/tree-multiset.ts +4 -4
- package/src/interfaces/undirected-graph.ts +1 -4
- package/src/types/data-structures/abstract-binary-tree.ts +0 -1
- package/test/integration/avl-tree.test.ts +24 -24
- package/test/integration/bst.test.ts +71 -71
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +4 -4
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +1 -9
- package/test/unit/data-structures/binary-tree/bst.test.ts +8 -8
- package/test/unit/data-structures/binary-tree/overall.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +9 -9
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +4 -4
- package/umd/bundle.min.js +1 -1
- package/umd/bundle.min.js.map +1 -1
|
@@ -1,126 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Vector2D = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (x === void 0) { x = 0; }
|
|
7
|
-
if (y === void 0) { y = 0; }
|
|
8
|
-
if (w === void 0) { w = 1; }
|
|
4
|
+
class Vector2D {
|
|
5
|
+
constructor(x = 0, y = 0, w = 1) {
|
|
9
6
|
this.x = x;
|
|
10
7
|
this.y = y;
|
|
11
8
|
this.w = w;
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
Object.defineProperty(Vector2D.prototype, "lengthSq", {
|
|
28
|
-
get: function () {
|
|
29
|
-
return this.x * this.x + this.y * this.y;
|
|
30
|
-
},
|
|
31
|
-
enumerable: false,
|
|
32
|
-
configurable: true
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperty(Vector2D.prototype, "rounded", {
|
|
35
|
-
get: function () {
|
|
36
|
-
return new Vector2D(Math.round(this.x), Math.round(this.y));
|
|
37
|
-
},
|
|
38
|
-
enumerable: false,
|
|
39
|
-
configurable: true
|
|
40
|
-
});
|
|
41
|
-
Vector2D.add = function (vector1, vector2) {
|
|
10
|
+
get isZero() {
|
|
11
|
+
return this.x === 0 && this.y === 0;
|
|
12
|
+
}
|
|
13
|
+
get length() {
|
|
14
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
15
|
+
}
|
|
16
|
+
get lengthSq() {
|
|
17
|
+
return this.x * this.x + this.y * this.y;
|
|
18
|
+
}
|
|
19
|
+
get rounded() {
|
|
20
|
+
return new Vector2D(Math.round(this.x), Math.round(this.y));
|
|
21
|
+
}
|
|
22
|
+
static add(vector1, vector2) {
|
|
42
23
|
return new Vector2D(vector1.x + vector2.x, vector1.y + vector2.y);
|
|
43
|
-
}
|
|
44
|
-
|
|
24
|
+
}
|
|
25
|
+
static subtract(vector1, vector2) {
|
|
45
26
|
return new Vector2D(vector1.x - vector2.x, vector1.y - vector2.y);
|
|
46
|
-
}
|
|
47
|
-
|
|
27
|
+
}
|
|
28
|
+
static subtractValue(vector, value) {
|
|
48
29
|
return new Vector2D(vector.x - value, vector.y - value);
|
|
49
|
-
}
|
|
50
|
-
|
|
30
|
+
}
|
|
31
|
+
static multiply(vector, value) {
|
|
51
32
|
return new Vector2D(vector.x * value, vector.y * value);
|
|
52
|
-
}
|
|
53
|
-
|
|
33
|
+
}
|
|
34
|
+
static divide(vector, value) {
|
|
54
35
|
return new Vector2D(vector.x / value, vector.y / value);
|
|
55
|
-
}
|
|
56
|
-
|
|
36
|
+
}
|
|
37
|
+
static equals(vector1, vector2) {
|
|
57
38
|
return vector1.x === vector2.x && vector1.y === vector2.y;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var vector = Vector2D.abs(Vector2D.subtract(vector1, vector2));
|
|
39
|
+
}
|
|
40
|
+
static equalsRounded(vector1, vector2, roundingFactor = 12) {
|
|
41
|
+
const vector = Vector2D.abs(Vector2D.subtract(vector1, vector2));
|
|
62
42
|
if (vector.x < roundingFactor && vector.y < roundingFactor) {
|
|
63
43
|
return true;
|
|
64
44
|
}
|
|
65
45
|
return false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
46
|
+
}
|
|
47
|
+
static normalize(vector) {
|
|
48
|
+
const length = vector.length;
|
|
69
49
|
if (length > 2.220446049250313e-16) {
|
|
70
50
|
return Vector2D.divide(vector, length);
|
|
71
51
|
}
|
|
72
52
|
return vector;
|
|
73
|
-
}
|
|
74
|
-
|
|
53
|
+
}
|
|
54
|
+
static truncate(vector, max) {
|
|
75
55
|
if (vector.length > max) {
|
|
76
56
|
return Vector2D.multiply(Vector2D.normalize(vector), max);
|
|
77
57
|
}
|
|
78
58
|
return vector;
|
|
79
|
-
}
|
|
80
|
-
|
|
59
|
+
}
|
|
60
|
+
static perp(vector) {
|
|
81
61
|
return new Vector2D(-vector.y, vector.x);
|
|
82
|
-
}
|
|
83
|
-
|
|
62
|
+
}
|
|
63
|
+
static reverse(vector) {
|
|
84
64
|
return new Vector2D(-vector.x, -vector.y);
|
|
85
|
-
}
|
|
86
|
-
|
|
65
|
+
}
|
|
66
|
+
static abs(vector) {
|
|
87
67
|
return new Vector2D(Math.abs(vector.x), Math.abs(vector.y));
|
|
88
|
-
}
|
|
89
|
-
|
|
68
|
+
}
|
|
69
|
+
static dot(vector1, vector2) {
|
|
90
70
|
return vector1.x * vector2.x + vector1.y * vector2.y;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
71
|
+
}
|
|
72
|
+
static distance(vector1, vector2) {
|
|
73
|
+
const ySeparation = vector2.y - vector1.y;
|
|
74
|
+
const xSeparation = vector2.x - vector1.x;
|
|
95
75
|
return Math.sqrt(ySeparation * ySeparation + xSeparation * xSeparation);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
76
|
+
}
|
|
77
|
+
static distanceSq(vector1, vector2) {
|
|
78
|
+
const ySeparation = vector2.y - vector1.y;
|
|
79
|
+
const xSeparation = vector2.x - vector1.x;
|
|
100
80
|
return ySeparation * ySeparation + xSeparation * xSeparation;
|
|
101
|
-
}
|
|
102
|
-
|
|
81
|
+
}
|
|
82
|
+
static sign(vector1, vector2) {
|
|
103
83
|
if (vector1.y * vector2.x > vector1.x * vector2.y) {
|
|
104
84
|
return -1;
|
|
105
85
|
}
|
|
106
86
|
return 1;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
87
|
+
}
|
|
88
|
+
static angle(vector) {
|
|
89
|
+
const origin = new Vector2D(0, -1);
|
|
90
|
+
const radian = Math.acos(Vector2D.dot(vector, origin) / (vector.length * origin.length));
|
|
111
91
|
return Vector2D.sign(vector, origin) === 1 ? Math.PI * 2 - radian : radian;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
92
|
+
}
|
|
93
|
+
static random(maxX, maxY) {
|
|
94
|
+
const randX = Math.floor(Math.random() * maxX - maxX / 2);
|
|
95
|
+
const randY = Math.floor(Math.random() * maxY - maxY / 2);
|
|
116
96
|
return new Vector2D(randX, randY);
|
|
117
|
-
}
|
|
118
|
-
|
|
97
|
+
}
|
|
98
|
+
zero() {
|
|
119
99
|
this.x = 0;
|
|
120
100
|
this.y = 0;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
}());
|
|
101
|
+
}
|
|
102
|
+
}
|
|
124
103
|
exports.Vector2D = Vector2D;
|
|
125
104
|
exports.default = Vector2D;
|
|
126
105
|
//# sourceMappingURL=vector2d.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector2d.js","sourceRoot":"","sources":["../../../src/data-structures/matrix/vector2d.ts"],"names":[],"mappings":";;;AAOA
|
|
1
|
+
{"version":3,"file":"vector2d.js","sourceRoot":"","sources":["../../../src/data-structures/matrix/vector2d.ts"],"names":[],"mappings":";;;AAOA,MAAa,QAAQ;IACnB,YACS,IAAY,CAAC,EACb,IAAY,CAAC,EACb,IAAY,CAAC;QAFb,MAAC,GAAD,CAAC,CAAY;QACb,MAAC,GAAD,CAAC,CAAY;QACb,MAAC,GAAD,CAAC,CAAY;IACnB,CAAC;IAMJ,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAMD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,C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C;IACX,CAAC;IASD,MAAM,CAAC,KAAK,CAAC,MAAgB;QAC3B,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACzF,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IAC7E,CAAC;IASD,MAAM,CAAC,MAAM,CAAC,IAAY,EAAE,IAAY;QACtC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;QAC1D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;QAC1D,OAAO,IAAI,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAKD,IAAI;QACF,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;CACF;AAlTD,4BAkTC;AAED,kBAAe,QAAQ,CAAC"}
|
|
@@ -1,54 +1,26 @@
|
|
|
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 __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
3
|
exports.MaxPriorityQueue = void 0;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return _super.call(this, __assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator)
|
|
4
|
+
const priority_queue_1 = require("./priority-queue");
|
|
5
|
+
class MaxPriorityQueue extends priority_queue_1.PriorityQueue {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super(Object.assign(Object.assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator)
|
|
35
8
|
? options.comparator
|
|
36
|
-
:
|
|
37
|
-
|
|
9
|
+
: (a, b) => {
|
|
10
|
+
const aKey = a, bKey = b;
|
|
38
11
|
return bKey - aKey;
|
|
39
|
-
} }))
|
|
12
|
+
} }));
|
|
40
13
|
}
|
|
41
|
-
|
|
42
|
-
|
|
14
|
+
static heapify(options) {
|
|
15
|
+
const maxPQ = new MaxPriorityQueue(Object.assign(Object.assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator)
|
|
43
16
|
? options.comparator
|
|
44
|
-
:
|
|
45
|
-
|
|
17
|
+
: (a, b) => {
|
|
18
|
+
const aKey = a, bKey = b;
|
|
46
19
|
return bKey - aKey;
|
|
47
20
|
} }));
|
|
48
21
|
maxPQ._fix();
|
|
49
22
|
return maxPQ;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}(priority_queue_1.PriorityQueue));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
53
25
|
exports.MaxPriorityQueue = MaxPriorityQueue;
|
|
54
26
|
//# sourceMappingURL=max-priority-queue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"max-priority-queue.js","sourceRoot":"","sources":["../../../src/data-structures/priority-queue/max-priority-queue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"max-priority-queue.js","sourceRoot":"","sources":["../../../src/data-structures/priority-queue/max-priority-queue.ts"],"names":[],"mappings":";;;AAOA,qDAA+C;AAG/C,MAAa,gBAA0B,SAAQ,8BAAgB;IAS7D,YAAY,OAAgE;QAC1E,KAAK,iCACA,OAAO,KACV,UAAU,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;gBAC7B,CAAC,CAAC,OAAO,CAAC,UAAU;gBACpB,CAAC,CAAC,CAAC,CAAI,EAAE,CAAI,EAAE,EAAE;oBACb,MAAM,IAAI,GAAG,CAAsB,EACjC,IAAI,GAAG,CAAsB,CAAC;oBAChC,OAAO,IAAI,GAAG,IAAI,CAAC;gBACrB,CAAC,IACL,CAAC;IACL,CAAC;IAWD,MAAM,CAAU,OAAO,CAAI,OAAgC;QACzD,MAAM,KAAK,GAAG,IAAI,gBAAgB,iCAC7B,OAAO,KACV,UAAU,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;gBAC7B,CAAC,CAAC,OAAO,CAAC,UAAU;gBACpB,CAAC,CAAC,CAAC,CAAI,EAAE,CAAI,EAAE,EAAE;oBACb,MAAM,IAAI,GAAG,CAAsB,EACjC,IAAI,GAAG,CAAsB,CAAC;oBAChC,OAAO,IAAI,GAAG,IAAI,CAAC;gBACrB,CAAC,IACL,CAAC;QACH,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA7CD,4CA6CC"}
|
|
@@ -1,54 +1,26 @@
|
|
|
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 __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
3
|
exports.MinPriorityQueue = void 0;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return _super.call(this, __assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator)
|
|
4
|
+
const priority_queue_1 = require("./priority-queue");
|
|
5
|
+
class MinPriorityQueue extends priority_queue_1.PriorityQueue {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super(Object.assign(Object.assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator)
|
|
35
8
|
? options.comparator
|
|
36
|
-
:
|
|
37
|
-
|
|
9
|
+
: (a, b) => {
|
|
10
|
+
const aKey = a, bKey = b;
|
|
38
11
|
return aKey - bKey;
|
|
39
|
-
} }))
|
|
12
|
+
} }));
|
|
40
13
|
}
|
|
41
|
-
|
|
42
|
-
|
|
14
|
+
static heapify(options) {
|
|
15
|
+
const minPQ = new MinPriorityQueue(Object.assign(Object.assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator)
|
|
43
16
|
? options.comparator
|
|
44
|
-
:
|
|
45
|
-
|
|
17
|
+
: (a, b) => {
|
|
18
|
+
const aKey = a, bKey = b;
|
|
46
19
|
return aKey - bKey;
|
|
47
20
|
} }));
|
|
48
21
|
minPQ._fix();
|
|
49
22
|
return minPQ;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}(priority_queue_1.PriorityQueue));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
53
25
|
exports.MinPriorityQueue = MinPriorityQueue;
|
|
54
26
|
//# sourceMappingURL=min-priority-queue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"min-priority-queue.js","sourceRoot":"","sources":["../../../src/data-structures/priority-queue/min-priority-queue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"min-priority-queue.js","sourceRoot":"","sources":["../../../src/data-structures/priority-queue/min-priority-queue.ts"],"names":[],"mappings":";;;AAOA,qDAA+C;AAG/C,MAAa,gBAA0B,SAAQ,8BAAgB;IAS7D,YAAY,OAAgE;QAC1E,KAAK,iCACA,OAAO,KACV,UAAU,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;gBAC7B,CAAC,CAAC,OAAO,CAAC,UAAU;gBACpB,CAAC,CAAC,CAAC,CAAI,EAAE,CAAI,EAAE,EAAE;oBACb,MAAM,IAAI,GAAG,CAAsB,EACjC,IAAI,GAAG,CAAsB,CAAC;oBAChC,OAAO,IAAI,GAAG,IAAI,CAAC;gBACrB,CAAC,IACL,CAAC;IACL,CAAC;IAYD,MAAM,CAAU,OAAO,CAAI,OAAgC;QACzD,MAAM,KAAK,GAAG,IAAI,gBAAgB,iCAC7B,OAAO,KACV,UAAU,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;gBAC7B,CAAC,CAAC,OAAO,CAAC,UAAU;gBACpB,CAAC,CAAC,CAAC,CAAI,EAAE,CAAI,EAAE,EAAE;oBACb,MAAM,IAAI,GAAG,CAAsB,EACjC,IAAI,GAAG,CAAsB,CAAC;oBAChC,OAAO,IAAI,GAAG,IAAI,CAAC;gBACrB,CAAC,IACL,CAAC;QACH,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA9CD,4CA8CC"}
|