@gabrielrufino/cube 2.0.9 → 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/Array/IArray.d.ts +6 -6
- package/dist/Array/index.d.ts +1 -1
- package/dist/BinarySearchTree/IBinarySearchTree.d.ts +7 -7
- package/dist/BinarySearchTree/IBinarySearchTreeData.d.ts +1 -1
- package/dist/BinarySearchTree/index.d.ts +3 -3
- package/dist/BinarySearchTree/index.js +6 -4
- package/dist/Deck/IDeck.d.ts +6 -6
- package/dist/Deck/index.d.ts +1 -1
- package/dist/Dictionary/IDictionary.d.ts +7 -7
- package/dist/Dictionary/index.d.ts +2 -2
- package/dist/DoublyLinkedList/IDoublyLinkedList.d.ts +6 -6
- package/dist/DoublyLinkedList/index.d.ts +2 -1
- package/dist/DoublyLinkedList/index.js +10 -10
- package/dist/Graph/GraphSearchNodeStates.js +0 -1
- package/dist/Graph/IGraph.d.ts +4 -4
- package/dist/Graph/index.d.ts +3 -3
- package/dist/Graph/index.js +2 -2
- package/dist/HashTable/IHashTable.d.ts +4 -4
- package/dist/HashTable/index.d.ts +5 -5
- package/dist/HashTable/index.js +2 -8
- package/dist/HashTableLinearProbing/HashTableLinearProbingElement.js +0 -2
- package/dist/HashTableLinearProbing/IHashTableLinearProbing.d.ts +4 -4
- package/dist/HashTableLinearProbing/IHashTableLinearProbingData.d.ts +1 -1
- package/dist/HashTableLinearProbing/index.d.ts +4 -4
- package/dist/HashTableSeparateChaining/HashTableSeparateChainingElement.js +0 -2
- package/dist/HashTableSeparateChaining/IHashTableSeparateChaining.d.ts +5 -5
- package/dist/HashTableSeparateChaining/IHashTableSeparateChainingData.d.ts +1 -1
- package/dist/HashTableSeparateChaining/index.d.ts +4 -4
- package/dist/HashTableSeparateChaining/index.js +3 -9
- package/dist/LinkedList/ILinkedList.d.ts +7 -7
- package/dist/LinkedList/index.d.ts +2 -2
- package/dist/LinkedList/index.js +5 -5
- package/dist/MaxHeap/IMaxHeap.d.ts +2 -2
- package/dist/MaxHeap/index.d.ts +6 -6
- package/dist/MinHeap/IMinHeap.d.ts +2 -2
- package/dist/MinHeap/index.d.ts +6 -6
- package/dist/Queue/IQueue.d.ts +4 -4
- package/dist/Queue/index.d.ts +1 -1
- package/dist/Set/ISet.d.ts +10 -10
- package/dist/Set/index.d.ts +2 -2
- package/dist/Stack/IStack.d.ts +4 -4
- package/dist/Stack/index.d.ts +1 -1
- package/eslint.config.mjs +3 -0
- package/package.json +24 -25
- package/stryker.config.json +1 -1
package/dist/Array/IArray.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
interface IArray<T> {
|
|
2
|
-
insertInLastPosition(_element: T)
|
|
3
|
-
insertInFirstPosition(_element: T)
|
|
4
|
-
insertInPosition(_position: number, _element: T)
|
|
5
|
-
removeFromLastPosition()
|
|
6
|
-
removeFromFirstPosition()
|
|
7
|
-
removeFromPosition(_position: number)
|
|
2
|
+
insertInLastPosition: (_element: T) => T;
|
|
3
|
+
insertInFirstPosition: (_element: T) => T;
|
|
4
|
+
insertInPosition: (_position: number, _element: T) => T;
|
|
5
|
+
removeFromLastPosition: () => T | undefined;
|
|
6
|
+
removeFromFirstPosition: () => T | undefined;
|
|
7
|
+
removeFromPosition: (_position: number) => T | undefined;
|
|
8
8
|
}
|
|
9
9
|
export default IArray;
|
package/dist/Array/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type IArray from './IArray';
|
|
1
2
|
import DataStructure from '../DataStructure';
|
|
2
|
-
import IArray from './IArray';
|
|
3
3
|
export default class Array<T = number> extends DataStructure<T> implements IArray<T> {
|
|
4
4
|
constructor(...inputs: Readonly<T[]>);
|
|
5
5
|
insertInLastPosition(element: T): T;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import IBinarySearchTreeData from './IBinarySearchTreeData';
|
|
1
|
+
import type IBinarySearchTreeData from './IBinarySearchTreeData';
|
|
2
2
|
interface IBinarySearchTree<T> {
|
|
3
3
|
get data(): IBinarySearchTreeData<T>;
|
|
4
4
|
get size(): number;
|
|
5
5
|
get min(): T | null;
|
|
6
6
|
get max(): T | null;
|
|
7
|
-
insert(_value: T)
|
|
8
|
-
walkInOrder(_callback: (_value: T) => any)
|
|
9
|
-
walkPreOrder(_callback: (_value: T) => any)
|
|
10
|
-
walkPostOrder(_callback: (_value: T) => any)
|
|
11
|
-
search(_value: T)
|
|
12
|
-
remove(_value: T)
|
|
7
|
+
insert: (_value: T) => T;
|
|
8
|
+
walkInOrder: (_callback: (_value: T) => any) => void;
|
|
9
|
+
walkPreOrder: (_callback: (_value: T) => any) => void;
|
|
10
|
+
walkPostOrder: (_callback: (_value: T) => any) => void;
|
|
11
|
+
search: (_value: T) => boolean;
|
|
12
|
+
remove: (_value: T) => T | null;
|
|
13
13
|
}
|
|
14
14
|
export default IBinarySearchTree;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import IBinarySearchNodeOptions from './IBinarySearchNodeOptions';
|
|
2
|
-
import IBinarySearchTree from './IBinarySearchTree';
|
|
3
|
-
import IBinarySearchTreeData from './IBinarySearchTreeData';
|
|
1
|
+
import type IBinarySearchNodeOptions from './IBinarySearchNodeOptions';
|
|
2
|
+
import type IBinarySearchTree from './IBinarySearchTree';
|
|
3
|
+
import type IBinarySearchTreeData from './IBinarySearchTreeData';
|
|
4
4
|
export default class BinarySearchTree<T = number> implements IBinarySearchTree<T> {
|
|
5
5
|
private _root;
|
|
6
6
|
private _size;
|
|
@@ -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;
|
|
@@ -99,6 +100,7 @@ var BinarySearchTree = /** @class */ (function () {
|
|
|
99
100
|
return Boolean(current);
|
|
100
101
|
};
|
|
101
102
|
BinarySearchTree.prototype.remove = function (value) {
|
|
103
|
+
var _a;
|
|
102
104
|
var current = this._root;
|
|
103
105
|
var path = [];
|
|
104
106
|
while (current && current.value !== value) {
|
|
@@ -114,7 +116,7 @@ var BinarySearchTree = /** @class */ (function () {
|
|
|
114
116
|
var found = __assign({}, current);
|
|
115
117
|
var parent = path
|
|
116
118
|
.slice(0, path.length - 1)
|
|
117
|
-
.reduce(function (accumulator, current) { return accumulator
|
|
119
|
+
.reduce(function (accumulator, current) { return accumulator[current]; }, this._root);
|
|
118
120
|
var child = path[path.length - 1];
|
|
119
121
|
if ((current === null || current === void 0 ? void 0 : current.left) && current.right && parent) {
|
|
120
122
|
var head = current.right;
|
|
@@ -136,7 +138,7 @@ var BinarySearchTree = /** @class */ (function () {
|
|
|
136
138
|
parent[child] = null;
|
|
137
139
|
this._size -= 1;
|
|
138
140
|
}
|
|
139
|
-
return found.value
|
|
141
|
+
return (_a = found.value) !== null && _a !== void 0 ? _a : null;
|
|
140
142
|
};
|
|
141
143
|
BinarySearchTree.prototype._lessThanOrEqualTo = function (value1, value2) {
|
|
142
144
|
if (value1 <= value2) {
|
package/dist/Deck/IDeck.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
interface IDeck<T> {
|
|
2
|
-
addFront(_element: T)
|
|
3
|
-
addBack(_element: T)
|
|
4
|
-
removeFront()
|
|
5
|
-
removeBack()
|
|
6
|
-
peekFront()
|
|
7
|
-
peekBack()
|
|
2
|
+
addFront: (_element: T) => T;
|
|
3
|
+
addBack: (_element: T) => T;
|
|
4
|
+
removeFront: () => T | undefined;
|
|
5
|
+
removeBack: () => T | undefined;
|
|
6
|
+
peekFront: () => T | undefined;
|
|
7
|
+
peekBack: () => T | undefined;
|
|
8
8
|
}
|
|
9
9
|
export default IDeck;
|
package/dist/Deck/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import IDictionaryData from './IDictionaryData';
|
|
1
|
+
import type IDictionaryData from './IDictionaryData';
|
|
2
2
|
interface IDictionary<T> {
|
|
3
3
|
get data(): IDictionaryData<T>;
|
|
4
4
|
get size(): number;
|
|
@@ -6,11 +6,11 @@ interface IDictionary<T> {
|
|
|
6
6
|
get keys(): string[];
|
|
7
7
|
get values(): T[];
|
|
8
8
|
get pairs(): [string, T][];
|
|
9
|
-
set(_key: string, _value: T)
|
|
10
|
-
remove(_key: string)
|
|
11
|
-
hasKey(_key: string)
|
|
12
|
-
get(_key: string)
|
|
13
|
-
clear()
|
|
14
|
-
forEach(_func: (_key: string, _value: T) => any)
|
|
9
|
+
set: (_key: string, _value: T) => [string, T];
|
|
10
|
+
remove: (_key: string) => [string, T] | null;
|
|
11
|
+
hasKey: (_key: string) => boolean;
|
|
12
|
+
get: (_key: string) => T | null;
|
|
13
|
+
clear: () => IDictionaryData<T>;
|
|
14
|
+
forEach: (_func: (_key: string, _value: T) => any) => void;
|
|
15
15
|
}
|
|
16
16
|
export default IDictionary;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import IDictionary from './IDictionary';
|
|
2
|
-
import IDictionaryData from './IDictionaryData';
|
|
1
|
+
import type IDictionary from './IDictionary';
|
|
2
|
+
import type IDictionaryData from './IDictionaryData';
|
|
3
3
|
export default class Dictionary<T = number> implements IDictionary<T> {
|
|
4
4
|
private _data;
|
|
5
5
|
constructor(inputs?: Readonly<{
|
|
@@ -6,11 +6,11 @@ export interface IDoublyLinkedListItem<T> {
|
|
|
6
6
|
interface IDoublyLinkedList<T> {
|
|
7
7
|
get data(): IDoublyLinkedListItem<T>[];
|
|
8
8
|
get size(): number;
|
|
9
|
-
push(_element: T)
|
|
10
|
-
getFromPosition(_position: number)
|
|
11
|
-
positionOf(_element: T)
|
|
12
|
-
insertInPosition(_element: T, _position: number)
|
|
13
|
-
remove(_element: T)
|
|
14
|
-
removeFromPosition(_position: number)
|
|
9
|
+
push: (_element: T) => T;
|
|
10
|
+
getFromPosition: (_position: number) => IDoublyLinkedListItem<T> | undefined;
|
|
11
|
+
positionOf: (_element: T) => number | undefined;
|
|
12
|
+
insertInPosition: (_element: T, _position: number) => T | undefined;
|
|
13
|
+
remove: (_element: T) => T | undefined;
|
|
14
|
+
removeFromPosition: (_position: number) => T | undefined;
|
|
15
15
|
}
|
|
16
16
|
export default IDoublyLinkedList;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { IDoublyLinkedListItem } from './IDoublyLinkedList';
|
|
2
|
+
import type IDoublyLinkedList from './IDoublyLinkedList';
|
|
2
3
|
export default class DoublyLinkedList<T = number> implements IDoublyLinkedList<T> {
|
|
3
4
|
private _head;
|
|
4
5
|
private _tail;
|
|
@@ -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;
|
package/dist/Graph/IGraph.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ interface IGraph {
|
|
|
6
6
|
get size(): number;
|
|
7
7
|
get nodes(): string[];
|
|
8
8
|
get edges(): [string, string][];
|
|
9
|
-
insert(_node: string)
|
|
10
|
-
connect(_node1: string, _node2: string)
|
|
11
|
-
breadthFirstSearch(_startNode: string, _callback: (_node: string) => void)
|
|
12
|
-
getDistancesFrom(_node: string)
|
|
9
|
+
insert: (_node: string) => string | null;
|
|
10
|
+
connect: (_node1: string, _node2: string) => [string, string];
|
|
11
|
+
breadthFirstSearch: (_startNode: string, _callback: (_node: string) => void) => void;
|
|
12
|
+
getDistancesFrom: (_node: string) => {
|
|
13
13
|
[key: string]: number;
|
|
14
14
|
};
|
|
15
15
|
}
|
package/dist/Graph/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import type { Edge } from './Edge';
|
|
2
|
+
import type IGraph from './IGraph';
|
|
3
|
+
import type IGraphOptions from './IGraphOptions';
|
|
4
4
|
export default class Graph implements IGraph {
|
|
5
5
|
private readonly _isDirected;
|
|
6
6
|
private readonly _data;
|
package/dist/Graph/index.js
CHANGED
|
@@ -23,11 +23,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
var GraphNodeNotFoundError_1 = __importDefault(require("./GraphNodeNotFoundError"));
|
|
27
|
-
var GraphSearchNodeStates_1 = __importDefault(require("./GraphSearchNodeStates"));
|
|
28
26
|
var Dictionary_1 = __importDefault(require("../Dictionary"));
|
|
29
27
|
var Queue_1 = __importDefault(require("../Queue"));
|
|
30
28
|
var Set_1 = __importDefault(require("../Set"));
|
|
29
|
+
var GraphNodeNotFoundError_1 = __importDefault(require("./GraphNodeNotFoundError"));
|
|
30
|
+
var GraphSearchNodeStates_1 = __importDefault(require("./GraphSearchNodeStates"));
|
|
31
31
|
var Graph = /** @class */ (function () {
|
|
32
32
|
function Graph(_a) {
|
|
33
33
|
var _b = _a === void 0 ? {} : _a, _c = _b.inputs, inputs = _c === void 0 ? {} : _c, _d = _b.isDirected, isDirected = _d === void 0 ? false : _d;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import IHashTableData from './IHashTableData';
|
|
1
|
+
import type IHashTableData from './IHashTableData';
|
|
2
2
|
interface IHashTable<T> {
|
|
3
3
|
get data(): IHashTableData<T>;
|
|
4
4
|
get size(): number;
|
|
5
5
|
get maxSize(): number;
|
|
6
|
-
put(_key: string, _value: T)
|
|
7
|
-
get(_key: string)
|
|
8
|
-
remove(_key: string)
|
|
6
|
+
put: (_key: string, _value: T) => T;
|
|
7
|
+
get: (_key: string) => T | null;
|
|
8
|
+
remove: (_key: string) => T | null;
|
|
9
9
|
}
|
|
10
10
|
export default IHashTable;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import IHashTable from './IHashTable';
|
|
2
|
-
import IHashTableData from './IHashTableData';
|
|
3
|
-
import IHashTableInputs from './IHashTableInputs';
|
|
4
|
-
import IHashTableOptions from './IHashTableOptions';
|
|
1
|
+
import type IHashTable from './IHashTable';
|
|
2
|
+
import type IHashTableData from './IHashTableData';
|
|
3
|
+
import type IHashTableInputs from './IHashTableInputs';
|
|
4
|
+
import type IHashTableOptions from './IHashTableOptions';
|
|
5
5
|
export default class HashTable<T = number> implements IHashTable<T> {
|
|
6
|
+
readonly maxSize: number;
|
|
6
7
|
private _data;
|
|
7
8
|
constructor(inputs?: Readonly<IHashTableInputs<T>>, { maxSize }?: IHashTableOptions);
|
|
8
9
|
get data(): IHashTableData<T>;
|
|
9
10
|
get size(): number;
|
|
10
|
-
get maxSize(): number;
|
|
11
11
|
put(key: string, value: T): T;
|
|
12
12
|
get(key: string): T | null;
|
|
13
13
|
remove(key: string): T | null;
|
package/dist/HashTable/index.js
CHANGED
|
@@ -15,7 +15,8 @@ var HashTable = /** @class */ (function () {
|
|
|
15
15
|
function HashTable(inputs, _a) {
|
|
16
16
|
if (inputs === void 0) { inputs = {}; }
|
|
17
17
|
var _b = _a === void 0 ? {} : _a, _c = _b.maxSize, maxSize = _c === void 0 ? 100 : _c;
|
|
18
|
-
this._data =
|
|
18
|
+
this._data = [];
|
|
19
|
+
this.maxSize = maxSize;
|
|
19
20
|
for (var _i = 0, _d = Object.entries(inputs); _i < _d.length; _i++) {
|
|
20
21
|
var _e = _d[_i], key = _e[0], value = _e[1];
|
|
21
22
|
this.put(key, value);
|
|
@@ -40,13 +41,6 @@ var HashTable = /** @class */ (function () {
|
|
|
40
41
|
enumerable: false,
|
|
41
42
|
configurable: true
|
|
42
43
|
});
|
|
43
|
-
Object.defineProperty(HashTable.prototype, "maxSize", {
|
|
44
|
-
get: function () {
|
|
45
|
-
return this._data.length;
|
|
46
|
-
},
|
|
47
|
-
enumerable: false,
|
|
48
|
-
configurable: true
|
|
49
|
-
});
|
|
50
44
|
HashTable.prototype.put = function (key, value) {
|
|
51
45
|
var position = this._hashCode(key);
|
|
52
46
|
this._data[position] = value;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable no-unused-vars */
|
|
3
|
-
/* eslint-disable no-useless-constructor */
|
|
4
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
3
|
var HashTableLinearProbingElement = /** @class */ (function () {
|
|
6
4
|
function HashTableLinearProbingElement(key, value) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import IHashTableLinearProbingData from './IHashTableLinearProbingData';
|
|
1
|
+
import type IHashTableLinearProbingData from './IHashTableLinearProbingData';
|
|
2
2
|
interface IHashTableLinearProbing<T> {
|
|
3
3
|
get data(): IHashTableLinearProbingData<T>;
|
|
4
4
|
get size(): number;
|
|
5
|
-
put(_key: string, _value: T)
|
|
6
|
-
get(_key: string)
|
|
7
|
-
remove(_key: string)
|
|
5
|
+
put: (_key: string, _value: T) => T | null;
|
|
6
|
+
get: (_key: string) => T | null;
|
|
7
|
+
remove: (_key: string) => T | null;
|
|
8
8
|
}
|
|
9
9
|
export default IHashTableLinearProbing;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type IHashTableLinearProbing from './IHashTableLinearProbing';
|
|
2
|
+
import type IHashTableLinearProbingInputs from './IHashTableLinearProbingInputs';
|
|
3
|
+
import type IHashTableLinearProbingOptions from './IHashTableLinearProbingOptions';
|
|
1
4
|
import HashTableLinearProbingElement from './HashTableLinearProbingElement';
|
|
2
|
-
import IHashTableLinearProbing from './IHashTableLinearProbing';
|
|
3
|
-
import IHashTableLinearProbingInputs from './IHashTableLinearProbingInputs';
|
|
4
|
-
import IHashTableLinearProbingOptions from './IHashTableLinearProbingOptions';
|
|
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(): {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable no-useless-constructor */
|
|
3
|
-
/* eslint-disable no-unused-vars */
|
|
4
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
3
|
var HashTableSeparateChainingElement = /** @class */ (function () {
|
|
6
4
|
function HashTableSeparateChainingElement(key, value) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import HashTableSeparateChainingElement from './HashTableSeparateChainingElement';
|
|
2
|
-
import IHashTableSeparateChainingData from './IHashTableSeparateChainingData';
|
|
1
|
+
import type HashTableSeparateChainingElement from './HashTableSeparateChainingElement';
|
|
2
|
+
import type IHashTableSeparateChainingData from './IHashTableSeparateChainingData';
|
|
3
3
|
interface IHashTableSeparateChaining<T> {
|
|
4
4
|
get data(): IHashTableSeparateChainingData<T>;
|
|
5
5
|
get size(): number;
|
|
6
6
|
get maxSize(): number;
|
|
7
|
-
put(_key: string, _value: T)
|
|
8
|
-
get(_key: string)
|
|
9
|
-
remove(_key: string)
|
|
7
|
+
put: (_key: string, _value: T) => T;
|
|
8
|
+
get: (_key: string) => HashTableSeparateChainingElement<T> | null;
|
|
9
|
+
remove: (_key: string) => HashTableSeparateChainingElement<T> | null;
|
|
10
10
|
}
|
|
11
11
|
export default IHashTableSeparateChaining;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import type IHashTableSeparateChaining from './IHashTableSeparateChaining';
|
|
2
|
+
import type IHashTableSeparateChainingData from './IHashTableSeparateChainingData';
|
|
3
|
+
import type IHashTableSeparateChainingInputs from './IHashTableSeparateChainingInputs';
|
|
1
4
|
import HashTableSeparateChainingElement from './HashTableSeparateChainingElement';
|
|
2
|
-
import IHashTableSeparateChaining from './IHashTableSeparateChaining';
|
|
3
|
-
import IHashTableSeparateChainingData from './IHashTableSeparateChainingData';
|
|
4
|
-
import IHashTableSeparateChainingInputs from './IHashTableSeparateChainingInputs';
|
|
5
5
|
export default class HashTableSeparateChaining<T = number> implements IHashTableSeparateChaining<T> {
|
|
6
6
|
private _data;
|
|
7
|
+
readonly maxSize: number;
|
|
7
8
|
constructor(inputs?: Readonly<IHashTableSeparateChainingInputs<T>>, { maxSize }?: {
|
|
8
9
|
maxSize: number;
|
|
9
10
|
});
|
|
10
11
|
get data(): IHashTableSeparateChainingData<T>;
|
|
11
12
|
get size(): number;
|
|
12
|
-
get maxSize(): number;
|
|
13
13
|
put(key: string, value: T): T;
|
|
14
14
|
get(key: string): HashTableSeparateChainingElement<T> | null;
|
|
15
15
|
remove(key: string): HashTableSeparateChainingElement<T> | null;
|
|
@@ -14,13 +14,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
var HashTableSeparateChainingElement_1 = __importDefault(require("./HashTableSeparateChainingElement"));
|
|
18
17
|
var LinkedList_1 = __importDefault(require("../LinkedList"));
|
|
18
|
+
var HashTableSeparateChainingElement_1 = __importDefault(require("./HashTableSeparateChainingElement"));
|
|
19
19
|
var HashTableSeparateChaining = /** @class */ (function () {
|
|
20
20
|
function HashTableSeparateChaining(inputs, _a) {
|
|
21
21
|
if (inputs === void 0) { inputs = {}; }
|
|
22
22
|
var _b = _a === void 0 ? { maxSize: 100 } : _a, maxSize = _b.maxSize;
|
|
23
|
-
this._data =
|
|
23
|
+
this._data = [];
|
|
24
|
+
this.maxSize = maxSize;
|
|
24
25
|
for (var _i = 0, _c = Object.entries(inputs); _i < _c.length; _i++) {
|
|
25
26
|
var _d = _c[_i], key = _d[0], value = _d[1];
|
|
26
27
|
this.put(key, value);
|
|
@@ -45,13 +46,6 @@ var HashTableSeparateChaining = /** @class */ (function () {
|
|
|
45
46
|
enumerable: false,
|
|
46
47
|
configurable: true
|
|
47
48
|
});
|
|
48
|
-
Object.defineProperty(HashTableSeparateChaining.prototype, "maxSize", {
|
|
49
|
-
get: function () {
|
|
50
|
-
return this._data.length;
|
|
51
|
-
},
|
|
52
|
-
enumerable: false,
|
|
53
|
-
configurable: true
|
|
54
|
-
});
|
|
55
49
|
HashTableSeparateChaining.prototype.put = function (key, value) {
|
|
56
50
|
var linkedList = this._getLinkedListByKey(key);
|
|
57
51
|
var element = new HashTableSeparateChainingElement_1.default(key, value);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import ILinkedListItem from './ILinkedListItem';
|
|
1
|
+
import type ILinkedListItem from './ILinkedListItem';
|
|
2
2
|
interface ILinkedList<T> {
|
|
3
3
|
get data(): ILinkedListItem<T>[];
|
|
4
4
|
get size(): number;
|
|
5
5
|
get isEmpty(): boolean;
|
|
6
|
-
push(_element: T)
|
|
7
|
-
getFromPosition(_position: number)
|
|
8
|
-
positionOf(_element: T)
|
|
9
|
-
insertInPosition(_element: T, _position: number)
|
|
10
|
-
remove(_element: T)
|
|
11
|
-
removeFromPosition(_position: number)
|
|
6
|
+
push: (_element: T) => T;
|
|
7
|
+
getFromPosition: (_position: number) => ILinkedListItem<T> | null;
|
|
8
|
+
positionOf: (_element: T) => number | undefined;
|
|
9
|
+
insertInPosition: (_element: T, _position: number) => T | undefined;
|
|
10
|
+
remove: (_element: T) => T | null;
|
|
11
|
+
removeFromPosition: (_position: number) => T | null;
|
|
12
12
|
}
|
|
13
13
|
export default ILinkedList;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ILinkedList from './ILinkedList';
|
|
2
|
-
import ILinkedListItem from './ILinkedListItem';
|
|
1
|
+
import type ILinkedList from './ILinkedList';
|
|
2
|
+
import type ILinkedListItem from './ILinkedListItem';
|
|
3
3
|
export default class LinkedList<T = number> implements ILinkedList<T> {
|
|
4
4
|
private readonly _FIRST_POSITION;
|
|
5
5
|
private _head;
|
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
|
}
|
|
@@ -94,7 +94,7 @@ var LinkedList = /** @class */ (function () {
|
|
|
94
94
|
}
|
|
95
95
|
else {
|
|
96
96
|
var before = this._getNodeFromPosition(position - 1);
|
|
97
|
-
var after = (before
|
|
97
|
+
var after = (before === null || before === void 0 ? void 0 : before.next) || null;
|
|
98
98
|
if (before) {
|
|
99
99
|
before.next = node;
|
|
100
100
|
}
|
|
@@ -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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import IMaxHeap from './IMaxHeap';
|
|
2
|
-
import IMaxHeapOptions from './IMaxHeapOptions';
|
|
1
|
+
import type IMaxHeap from './IMaxHeap';
|
|
2
|
+
import type IMaxHeapOptions from './IMaxHeapOptions';
|
|
3
3
|
export default class MaxHeap<T = number> implements IMaxHeap<T> {
|
|
4
4
|
private _data;
|
|
5
5
|
constructor({ greaterThanOrEqualTo, inputs }?: IMaxHeapOptions<T>);
|
|
@@ -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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import IMinHeap from './IMinHeap';
|
|
2
|
-
import IMinHeapOptions from './IMinHeapOptions';
|
|
1
|
+
import type IMinHeap from './IMinHeap';
|
|
2
|
+
import type IMinHeapOptions from './IMinHeapOptions';
|
|
3
3
|
export default class MinHeap<T = number> implements IMinHeap<T> {
|
|
4
4
|
private _data;
|
|
5
5
|
constructor({ lessThanOrEqualTo, inputs }?: IMinHeapOptions<T>);
|
|
@@ -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/Queue/IQueue.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
interface IQueue<T> {
|
|
2
|
-
enqueue(_element: T)
|
|
3
|
-
dequeue()
|
|
4
|
-
peek()
|
|
5
|
-
clear()
|
|
2
|
+
enqueue: (_element: T) => T;
|
|
3
|
+
dequeue: () => T | undefined;
|
|
4
|
+
peek: () => T | undefined;
|
|
5
|
+
clear: () => void;
|
|
6
6
|
get isEmpty(): boolean;
|
|
7
7
|
}
|
|
8
8
|
export default IQueue;
|
package/dist/Queue/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type IQueue from './IQueue';
|
|
1
2
|
import DataStructure from '../DataStructure';
|
|
2
|
-
import IQueue from './IQueue';
|
|
3
3
|
export default class Queue<T = number> extends DataStructure<T> implements IQueue<T> {
|
|
4
4
|
constructor(...inputs: Readonly<T[]>);
|
|
5
5
|
get isEmpty(): boolean;
|
package/dist/Set/ISet.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import Set from './';
|
|
1
|
+
import type Set from './';
|
|
2
2
|
interface ISet<T> {
|
|
3
3
|
get data(): T[];
|
|
4
4
|
get size(): number;
|
|
5
|
-
has(_elemet: T)
|
|
6
|
-
add(_element: T)
|
|
7
|
-
delete(_element: T)
|
|
8
|
-
clear(_element: T)
|
|
9
|
-
union(_set: Set<T>)
|
|
10
|
-
intersection(_set: Set<T>)
|
|
11
|
-
difference(_set: Set<T>)
|
|
12
|
-
isSubsetOf(_set: Set<T>)
|
|
13
|
-
contains(_set: Set<T>)
|
|
5
|
+
has: (_elemet: T) => boolean;
|
|
6
|
+
add: (_element: T) => T | null;
|
|
7
|
+
delete: (_element: T) => T | null;
|
|
8
|
+
clear: (_element: T) => T[];
|
|
9
|
+
union: (_set: Set<T>) => Set<T>;
|
|
10
|
+
intersection: (_set: Set<T>) => Set<T>;
|
|
11
|
+
difference: (_set: Set<T>) => Set<T>;
|
|
12
|
+
isSubsetOf: (_set: Set<T>) => boolean;
|
|
13
|
+
contains: (_set: Set<T>) => boolean;
|
|
14
14
|
}
|
|
15
15
|
export default ISet;
|
package/dist/Set/index.d.ts
CHANGED
package/dist/Stack/IStack.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
interface IStack<T> {
|
|
2
|
-
push(_element: T)
|
|
3
|
-
pop()
|
|
4
|
-
peek()
|
|
5
|
-
clear()
|
|
2
|
+
push: (_element: T) => T;
|
|
3
|
+
pop: () => T | undefined;
|
|
4
|
+
peek: () => T | undefined;
|
|
5
|
+
clear: () => void;
|
|
6
6
|
get isEmpty(): boolean;
|
|
7
7
|
}
|
|
8
8
|
export default IStack;
|
package/dist/Stack/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,42 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gabrielrufino/cube",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"description": "Data structures made in Typescript",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"lint": "eslint src/**/*.ts",
|
|
10
|
-
"test": "vitest run",
|
|
11
|
-
"test:cov": "npm t -- --coverage",
|
|
12
|
-
"test:mutation": "npx stryker run",
|
|
13
|
-
"test:watch": "vitest"
|
|
14
|
-
},
|
|
5
|
+
"author": "Gabriel Rufino <contato@gabrielrufino.com>",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"funding": "https://github.com/sponsors/gabrielrufino",
|
|
8
|
+
"homepage": "https://github.com/gabrielrufino/cube#readme",
|
|
15
9
|
"repository": {
|
|
16
10
|
"type": "git",
|
|
17
11
|
"url": "git+https://github.com/gabrielrufino/cube.git"
|
|
18
12
|
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/gabrielrufino/cube/issues"
|
|
15
|
+
},
|
|
19
16
|
"keywords": [
|
|
20
17
|
"Data",
|
|
21
18
|
"Structures"
|
|
22
19
|
],
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"build:watch": "npm run build -- --watch",
|
|
24
|
+
"lint": "eslint",
|
|
25
|
+
"lint:fix": "npm run lint -- --fix",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:cov": "npm t -- --coverage",
|
|
28
|
+
"test:mutation": "npx stryker run",
|
|
29
|
+
"test:watch": "vitest"
|
|
28
30
|
},
|
|
29
|
-
"homepage": "https://github.com/gabrielrufino/cube#readme",
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@commitlint/
|
|
33
|
-
"@
|
|
32
|
+
"@antfu/eslint-config": "^4.13.0",
|
|
33
|
+
"@commitlint/cli": "^19.8.1",
|
|
34
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
35
|
+
"@faker-js/faker": "^9.7.0",
|
|
34
36
|
"@stryker-mutator/vitest-runner": "^8.7.1",
|
|
35
|
-
"@
|
|
36
|
-
"
|
|
37
|
-
"@vitest/coverage-v8": "^3.1.1",
|
|
38
|
-
"eslint": "^8.57.1",
|
|
39
|
-
"eslint-config-xo": "^0.43.1",
|
|
37
|
+
"@vitest/coverage-v8": "^3.1.3",
|
|
38
|
+
"eslint": "^9.26.0",
|
|
40
39
|
"husky": "^9.1.7",
|
|
41
40
|
"typescript": "^5.8.3",
|
|
42
41
|
"vitest": "^3.0.4"
|
package/stryker.config.json
CHANGED