@gabrielrufino/cube 2.0.8 → 2.0.10
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/README.md +0 -4
- 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 +3 -2
- 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/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 +3 -3
- 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 +1 -1
- package/dist/MaxHeap/IMaxHeap.d.ts +2 -2
- package/dist/MaxHeap/index.d.ts +2 -2
- package/dist/MinHeap/IMinHeap.d.ts +2 -2
- package/dist/MinHeap/index.d.ts +2 -2
- 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 +1 -1
- 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 +25 -26
- package/stryker.config.json +1 -1
package/README.md
CHANGED
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;
|
|
@@ -99,6 +99,7 @@ var BinarySearchTree = /** @class */ (function () {
|
|
|
99
99
|
return Boolean(current);
|
|
100
100
|
};
|
|
101
101
|
BinarySearchTree.prototype.remove = function (value) {
|
|
102
|
+
var _a;
|
|
102
103
|
var current = this._root;
|
|
103
104
|
var path = [];
|
|
104
105
|
while (current && current.value !== value) {
|
|
@@ -114,7 +115,7 @@ var BinarySearchTree = /** @class */ (function () {
|
|
|
114
115
|
var found = __assign({}, current);
|
|
115
116
|
var parent = path
|
|
116
117
|
.slice(0, path.length - 1)
|
|
117
|
-
.reduce(function (accumulator, current) { return accumulator
|
|
118
|
+
.reduce(function (accumulator, current) { return accumulator[current]; }, this._root);
|
|
118
119
|
var child = path[path.length - 1];
|
|
119
120
|
if ((current === null || current === void 0 ? void 0 : current.left) && current.right && parent) {
|
|
120
121
|
var head = current.right;
|
|
@@ -136,7 +137,7 @@ var BinarySearchTree = /** @class */ (function () {
|
|
|
136
137
|
parent[child] = null;
|
|
137
138
|
this._size -= 1;
|
|
138
139
|
}
|
|
139
|
-
return found.value
|
|
140
|
+
return (_a = found.value) !== null && _a !== void 0 ? _a : null;
|
|
140
141
|
};
|
|
141
142
|
BinarySearchTree.prototype._lessThanOrEqualTo = function (value1, value2) {
|
|
142
143
|
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;
|
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,7 +1,7 @@
|
|
|
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
6
|
private _maxSize;
|
|
7
7
|
private _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
|
@@ -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
|
}
|
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>);
|
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>);
|
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,44 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gabrielrufino/cube",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
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.0.8",
|
|
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
|
-
"typescript": "^5.8.
|
|
40
|
+
"typescript": "^5.8.3",
|
|
42
41
|
"vitest": "^3.0.4"
|
|
43
42
|
}
|
|
44
43
|
}
|
package/stryker.config.json
CHANGED