@gabrielrufino/cube 1.0.19 → 1.0.22
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/build/BinarySearchTree/BinarySearchTreeNode.d.ts +1 -1
- package/build/BinarySearchTree/BinarySearchTreeNode.js +6 -7
- package/build/BinarySearchTree/index.js +7 -8
- package/build/DoublyLinkedList/index.js +19 -22
- package/build/LinkedList/index.js +12 -15
- package/build/MaxHeap/index.js +7 -8
- package/build/MinHeap/index.js +7 -8
- package/package.json +1 -1
|
@@ -9,13 +9,12 @@ var BinarySearchTreeNode = /** @class */ (function () {
|
|
|
9
9
|
this.right = null;
|
|
10
10
|
}
|
|
11
11
|
BinarySearchTreeNode.prototype[Symbol.toPrimitive] = function (type) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return null;
|
|
12
|
+
var primitives = {
|
|
13
|
+
default: true,
|
|
14
|
+
number: 1 + (this.left ? 1 : 0) + (this.right ? 1 : 0),
|
|
15
|
+
string: "[".concat(this.left, "] <= (").concat(this.value, ") => [").concat(this.right, "]"),
|
|
16
|
+
};
|
|
17
|
+
return primitives[type];
|
|
19
18
|
};
|
|
20
19
|
return BinarySearchTreeNode;
|
|
21
20
|
}());
|
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
var BinarySearchTreeNode_1 = __importDefault(require("./BinarySearchTreeNode"));
|
|
18
18
|
var BinarySearchTree = /** @class */ (function () {
|
|
19
19
|
function BinarySearchTree(_a) {
|
|
20
|
-
var _b = _a === void 0 ? {
|
|
20
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.inputs, inputs = _c === void 0 ? [] : _c, lessThanOrEqualTo = _b.lessThanOrEqualTo;
|
|
21
21
|
this._root = null;
|
|
22
22
|
this._size = 0;
|
|
23
23
|
if (lessThanOrEqualTo) {
|
|
@@ -183,13 +183,12 @@ var BinarySearchTree = /** @class */ (function () {
|
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
BinarySearchTree.prototype[Symbol.toPrimitive] = function (type) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return null;
|
|
186
|
+
var primitives = {
|
|
187
|
+
default: true,
|
|
188
|
+
number: this.size,
|
|
189
|
+
string: "".concat(this._root),
|
|
190
|
+
};
|
|
191
|
+
return primitives[type];
|
|
193
192
|
};
|
|
194
193
|
return BinarySearchTree;
|
|
195
194
|
}());
|
|
@@ -13,16 +13,14 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
13
13
|
this._head = null;
|
|
14
14
|
this._tail = null;
|
|
15
15
|
this._size = 0;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this._size = inputs.length;
|
|
25
|
-
}
|
|
16
|
+
var nodes = inputs.map(function (input) { return new Node_1.default(input); });
|
|
17
|
+
for (var i = 0; i < inputs.length; i++) {
|
|
18
|
+
nodes[i].previous = nodes[i - 1] || null;
|
|
19
|
+
nodes[i].next = nodes[i + 1] || null;
|
|
20
|
+
}
|
|
21
|
+
this._head = nodes[0];
|
|
22
|
+
this._tail = nodes[nodes.length - 1];
|
|
23
|
+
this._size = inputs.length;
|
|
26
24
|
}
|
|
27
25
|
Object.defineProperty(DoublyLinkedList.prototype, "data", {
|
|
28
26
|
get: function () {
|
|
@@ -70,7 +68,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
70
68
|
*/
|
|
71
69
|
DoublyLinkedList.prototype.getFromPosition = function (position) {
|
|
72
70
|
var _a, _b;
|
|
73
|
-
if (position < 0 || position >= this.
|
|
71
|
+
if (position < 0 || position >= this.size) {
|
|
74
72
|
return undefined;
|
|
75
73
|
}
|
|
76
74
|
var distanceToTheHead = position;
|
|
@@ -90,9 +88,9 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
90
88
|
}
|
|
91
89
|
if (current === null || current === void 0 ? void 0 : current.value) {
|
|
92
90
|
return {
|
|
93
|
-
previous: ((_a = current
|
|
94
|
-
value: current
|
|
95
|
-
next: ((_b = current
|
|
91
|
+
previous: ((_a = current.previous) === null || _a === void 0 ? void 0 : _a.value) || null,
|
|
92
|
+
value: current.value,
|
|
93
|
+
next: ((_b = current.next) === null || _b === void 0 ? void 0 : _b.value) || null,
|
|
96
94
|
};
|
|
97
95
|
}
|
|
98
96
|
};
|
|
@@ -205,16 +203,15 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
205
203
|
return 'DESC';
|
|
206
204
|
};
|
|
207
205
|
DoublyLinkedList.prototype[Symbol.toPrimitive] = function (type) {
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
var primitives = {
|
|
207
|
+
default: true,
|
|
208
|
+
number: this.size,
|
|
209
|
+
string: "[Head] ".concat(this.data.map(function (_a) {
|
|
210
210
|
var value = _a.value;
|
|
211
211
|
return value;
|
|
212
|
-
}).join(' <=> '), " [Tail]")
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return this.size;
|
|
216
|
-
}
|
|
217
|
-
return null;
|
|
212
|
+
}).join(' <=> '), " [Tail]"),
|
|
213
|
+
};
|
|
214
|
+
return primitives[type];
|
|
218
215
|
};
|
|
219
216
|
return DoublyLinkedList;
|
|
220
217
|
}());
|
|
@@ -13,14 +13,12 @@ var LinkedList = /** @class */ (function () {
|
|
|
13
13
|
this._FIRST_POSITION = 0;
|
|
14
14
|
this._head = null;
|
|
15
15
|
this._size = 0;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
nodes[i].next = nodes[i + 1];
|
|
20
|
-
}
|
|
21
|
-
this._head = nodes[0];
|
|
22
|
-
this._size = nodes.length;
|
|
16
|
+
var nodes = inputs.map(function (input) { return new Node_1.default(input); });
|
|
17
|
+
for (var i = 0; i < inputs.length - 1; i++) {
|
|
18
|
+
nodes[i].next = nodes[i + 1];
|
|
23
19
|
}
|
|
20
|
+
this._head = nodes[0];
|
|
21
|
+
this._size = nodes.length;
|
|
24
22
|
}
|
|
25
23
|
Object.defineProperty(LinkedList.prototype, "data", {
|
|
26
24
|
get: function () {
|
|
@@ -153,16 +151,15 @@ var LinkedList = /** @class */ (function () {
|
|
|
153
151
|
return node || undefined;
|
|
154
152
|
};
|
|
155
153
|
LinkedList.prototype[Symbol.toPrimitive] = function (type) {
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
var primitives = {
|
|
155
|
+
default: true,
|
|
156
|
+
number: this.size,
|
|
157
|
+
string: "[Head] ".concat(this.data.map(function (_a) {
|
|
158
158
|
var value = _a.value;
|
|
159
159
|
return value;
|
|
160
|
-
}).join(' => '))
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return this.size;
|
|
164
|
-
}
|
|
165
|
-
return null;
|
|
160
|
+
}).join(' => ')),
|
|
161
|
+
};
|
|
162
|
+
return primitives[type];
|
|
166
163
|
};
|
|
167
164
|
return LinkedList;
|
|
168
165
|
}());
|
package/build/MaxHeap/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
var MaxHeap = /** @class */ (function () {
|
|
13
13
|
function MaxHeap(_a) {
|
|
14
|
-
var _b = _a === void 0 ? {
|
|
14
|
+
var _b = _a === void 0 ? {} : _a, greaterThanOrEqualTo = _b.greaterThanOrEqualTo, _c = _b.inputs, inputs = _c === void 0 ? [] : _c;
|
|
15
15
|
this._data = [];
|
|
16
16
|
this._greaterThanOrEqualTo = function (value1, value2) { return value1 >= value2; };
|
|
17
17
|
this._getLeftIndex = function (index) { return (2 * index) + 1; };
|
|
@@ -89,13 +89,12 @@ var MaxHeap = /** @class */ (function () {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
MaxHeap.prototype[Symbol.toPrimitive] = function (type) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return null;
|
|
92
|
+
var primitives = {
|
|
93
|
+
default: true,
|
|
94
|
+
number: this.size,
|
|
95
|
+
string: this.data.join(', '),
|
|
96
|
+
};
|
|
97
|
+
return primitives[type];
|
|
99
98
|
};
|
|
100
99
|
return MaxHeap;
|
|
101
100
|
}());
|
package/build/MinHeap/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
var MinHeap = /** @class */ (function () {
|
|
13
13
|
function MinHeap(_a) {
|
|
14
|
-
var _b = _a === void 0 ? {
|
|
14
|
+
var _b = _a === void 0 ? {} : _a, lessThanOrEqualTo = _b.lessThanOrEqualTo, _c = _b.inputs, inputs = _c === void 0 ? [] : _c;
|
|
15
15
|
this._data = [];
|
|
16
16
|
this._lessThanOrEqualTo = function (value1, value2) { return value1 <= value2; };
|
|
17
17
|
this._getLeftIndex = function (index) { return (2 * index) + 1; };
|
|
@@ -89,13 +89,12 @@ var MinHeap = /** @class */ (function () {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
MinHeap.prototype[Symbol.toPrimitive] = function (type) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return null;
|
|
92
|
+
var primitives = {
|
|
93
|
+
default: true,
|
|
94
|
+
number: this.size,
|
|
95
|
+
string: this.data.join(', '),
|
|
96
|
+
};
|
|
97
|
+
return primitives[type];
|
|
99
98
|
};
|
|
100
99
|
return MinHeap;
|
|
101
100
|
}());
|