@gabrielrufino/cube 2.0.10 → 2.0.11
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/dist/BinarySearchTree/index.js +3 -2
- package/dist/DoublyLinkedList/index.js +10 -10
- package/dist/HashTableLinearProbing/index.d.ts +1 -1
- package/dist/LinkedList/index.js +4 -4
- package/dist/MaxHeap/index.d.ts +4 -4
- package/dist/MinHeap/index.d.ts +4 -4
- package/dist/Set/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -46,11 +46,12 @@ var BinarySearchTree = /** @class */ (function () {
|
|
|
46
46
|
});
|
|
47
47
|
Object.defineProperty(BinarySearchTree.prototype, "min", {
|
|
48
48
|
get: function () {
|
|
49
|
+
var _a;
|
|
49
50
|
var current = this._root;
|
|
50
51
|
while (current && current.left) {
|
|
51
52
|
current = current.left;
|
|
52
53
|
}
|
|
53
|
-
return (current === null || current === void 0 ? void 0 : current.value)
|
|
54
|
+
return (_a = current === null || current === void 0 ? void 0 : current.value) !== null && _a !== void 0 ? _a : null;
|
|
54
55
|
},
|
|
55
56
|
enumerable: false,
|
|
56
57
|
configurable: true
|
|
@@ -58,7 +59,7 @@ var BinarySearchTree = /** @class */ (function () {
|
|
|
58
59
|
Object.defineProperty(BinarySearchTree.prototype, "max", {
|
|
59
60
|
get: function () {
|
|
60
61
|
var current = this._root;
|
|
61
|
-
while (current
|
|
62
|
+
while (current === null || current === void 0 ? void 0 : current.right) {
|
|
62
63
|
current = current.right;
|
|
63
64
|
}
|
|
64
65
|
return (current === null || current === void 0 ? void 0 : current.value) || null;
|
|
@@ -24,14 +24,14 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
24
24
|
}
|
|
25
25
|
Object.defineProperty(DoublyLinkedList.prototype, "data", {
|
|
26
26
|
get: function () {
|
|
27
|
-
var _a, _b;
|
|
27
|
+
var _a, _b, _c, _d;
|
|
28
28
|
var current = this._head;
|
|
29
29
|
var data = [];
|
|
30
30
|
while (current) {
|
|
31
31
|
data.push({
|
|
32
|
-
previous: ((_a = current.previous) === null || _a === void 0 ? void 0 : _a.value)
|
|
32
|
+
previous: (_b = (_a = current.previous) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null,
|
|
33
33
|
value: current.value,
|
|
34
|
-
next: ((
|
|
34
|
+
next: (_d = (_c = current.next) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : null,
|
|
35
35
|
});
|
|
36
36
|
current = current.next;
|
|
37
37
|
}
|
|
@@ -67,7 +67,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
67
67
|
* Complexity: O(n/2)
|
|
68
68
|
*/
|
|
69
69
|
DoublyLinkedList.prototype.getFromPosition = function (position) {
|
|
70
|
-
var _a, _b;
|
|
70
|
+
var _a, _b, _c, _d;
|
|
71
71
|
if (position < 0 || position >= this.size) {
|
|
72
72
|
return undefined;
|
|
73
73
|
}
|
|
@@ -88,9 +88,9 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
88
88
|
}
|
|
89
89
|
if (current === null || current === void 0 ? void 0 : current.value) {
|
|
90
90
|
return {
|
|
91
|
-
previous: ((_a = current.previous) === null || _a === void 0 ? void 0 : _a.value)
|
|
91
|
+
previous: (_b = (_a = current.previous) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null,
|
|
92
92
|
value: current.value,
|
|
93
|
-
next: ((
|
|
93
|
+
next: (_d = (_c = current.next) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : null,
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
};
|
|
@@ -107,7 +107,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
107
107
|
* Complexity: O(n)
|
|
108
108
|
*/
|
|
109
109
|
DoublyLinkedList.prototype.insertInPosition = function (element, position) {
|
|
110
|
-
var _a;
|
|
110
|
+
var _a, _b;
|
|
111
111
|
if (position < 0 || position > this.size) {
|
|
112
112
|
return undefined;
|
|
113
113
|
}
|
|
@@ -119,9 +119,9 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
119
119
|
this._size += 1;
|
|
120
120
|
return element;
|
|
121
121
|
}
|
|
122
|
-
if (position === this.size - 1 && this._tail
|
|
122
|
+
if (position === this.size - 1 && ((_a = this._tail) === null || _a === void 0 ? void 0 : _a.previous)) {
|
|
123
123
|
this._tail.previous.next = node;
|
|
124
|
-
node.previous = ((
|
|
124
|
+
node.previous = ((_b = this._tail) === null || _b === void 0 ? void 0 : _b.previous) || null;
|
|
125
125
|
node.next = this._tail;
|
|
126
126
|
this._tail.previous = node;
|
|
127
127
|
this._size += 1;
|
|
@@ -148,7 +148,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
148
148
|
current = (current === null || current === void 0 ? void 0 : current.previous) || null;
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
if (current
|
|
151
|
+
if (current === null || current === void 0 ? void 0 : current.previous) {
|
|
152
152
|
current.previous.next = node;
|
|
153
153
|
node.previous = current.previous;
|
|
154
154
|
node.next = current;
|
|
@@ -3,7 +3,7 @@ import type IHashTableLinearProbingInputs from './IHashTableLinearProbingInputs'
|
|
|
3
3
|
import type IHashTableLinearProbingOptions from './IHashTableLinearProbingOptions';
|
|
4
4
|
import HashTableLinearProbingElement from './HashTableLinearProbingElement';
|
|
5
5
|
export default class HashTableLinearProbing<T = number> implements IHashTableLinearProbing<T> {
|
|
6
|
-
private _maxSize;
|
|
6
|
+
private readonly _maxSize;
|
|
7
7
|
private _data;
|
|
8
8
|
constructor(inputs?: Readonly<IHashTableLinearProbingInputs<T>>, { maxSize }?: IHashTableLinearProbingOptions);
|
|
9
9
|
get data(): {
|
package/dist/LinkedList/index.js
CHANGED
|
@@ -22,13 +22,13 @@ var LinkedList = /** @class */ (function () {
|
|
|
22
22
|
}
|
|
23
23
|
Object.defineProperty(LinkedList.prototype, "data", {
|
|
24
24
|
get: function () {
|
|
25
|
-
var _a;
|
|
25
|
+
var _a, _b;
|
|
26
26
|
var data = [];
|
|
27
27
|
var current = this._head;
|
|
28
28
|
while (current) {
|
|
29
29
|
data.push({
|
|
30
30
|
value: current.value,
|
|
31
|
-
next: ((_a = current.next) === null || _a === void 0 ? void 0 : _a.value)
|
|
31
|
+
next: (_b = (_a = current.next) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null,
|
|
32
32
|
});
|
|
33
33
|
current = current.next;
|
|
34
34
|
}
|
|
@@ -104,14 +104,14 @@ var LinkedList = /** @class */ (function () {
|
|
|
104
104
|
return element;
|
|
105
105
|
};
|
|
106
106
|
LinkedList.prototype.getFromPosition = function (position) {
|
|
107
|
-
var _a;
|
|
107
|
+
var _a, _b;
|
|
108
108
|
var node = this._getNodeFromPosition(position);
|
|
109
109
|
if (!node) {
|
|
110
110
|
return null;
|
|
111
111
|
}
|
|
112
112
|
return {
|
|
113
113
|
value: node.value,
|
|
114
|
-
next: ((_a = node.next) === null || _a === void 0 ? void 0 : _a.value)
|
|
114
|
+
next: (_b = (_a = node.next) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null,
|
|
115
115
|
};
|
|
116
116
|
};
|
|
117
117
|
LinkedList.prototype.removeFromPosition = function (position) {
|
package/dist/MaxHeap/index.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ export default class MaxHeap<T = number> implements IMaxHeap<T> {
|
|
|
9
9
|
get max(): T | null;
|
|
10
10
|
insert(value: T): T;
|
|
11
11
|
extract(): T | null;
|
|
12
|
-
private _greaterThanOrEqualTo;
|
|
13
|
-
private _getLeftIndex;
|
|
14
|
-
private _getRightIndex;
|
|
15
|
-
private _getParentIndex;
|
|
12
|
+
private readonly _greaterThanOrEqualTo;
|
|
13
|
+
private readonly _getLeftIndex;
|
|
14
|
+
private readonly _getRightIndex;
|
|
15
|
+
private readonly _getParentIndex;
|
|
16
16
|
private _siftUp;
|
|
17
17
|
private _siftDown;
|
|
18
18
|
private [Symbol.toPrimitive];
|
package/dist/MinHeap/index.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ export default class MinHeap<T = number> implements IMinHeap<T> {
|
|
|
9
9
|
get min(): T | null;
|
|
10
10
|
insert(value: T): T;
|
|
11
11
|
extract(): T | null;
|
|
12
|
-
private _lessThanOrEqualTo;
|
|
13
|
-
private _getLeftIndex;
|
|
14
|
-
private _getRightIndex;
|
|
15
|
-
private _getParentIndex;
|
|
12
|
+
private readonly _lessThanOrEqualTo;
|
|
13
|
+
private readonly _getLeftIndex;
|
|
14
|
+
private readonly _getRightIndex;
|
|
15
|
+
private readonly _getParentIndex;
|
|
16
16
|
private _siftUp;
|
|
17
17
|
private _siftDown;
|
|
18
18
|
private [Symbol.toPrimitive];
|
package/dist/Set/index.d.ts
CHANGED