@gabrielrufino/cube 1.0.1 → 1.0.6
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/package.json +6 -6
- package/.github/workflows/cd.yml +0 -26
- package/.github/workflows/ci.yml +0 -23
- package/coverage/clover.xml +0 -706
- package/coverage/coverage-final.json +0 -19
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -327
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/Algorithms/index.html +0 -117
- package/coverage/lcov-report/src/Algorithms/index.ts.html +0 -149
- package/coverage/lcov-report/src/Array/index.html +0 -117
- package/coverage/lcov-report/src/Array/index.ts.html +0 -290
- package/coverage/lcov-report/src/DataStructure/index.html +0 -117
- package/coverage/lcov-report/src/DataStructure/index.ts.html +0 -131
- package/coverage/lcov-report/src/Deck/index.html +0 -117
- package/coverage/lcov-report/src/Deck/index.ts.html +0 -239
- package/coverage/lcov-report/src/Dictionary/index.html +0 -117
- package/coverage/lcov-report/src/Dictionary/index.ts.html +0 -350
- package/coverage/lcov-report/src/DoublyLinkedList/Node.ts.html +0 -113
- package/coverage/lcov-report/src/DoublyLinkedList/index.html +0 -132
- package/coverage/lcov-report/src/DoublyLinkedList/index.ts.html +0 -836
- package/coverage/lcov-report/src/HashTable/index.html +0 -117
- package/coverage/lcov-report/src/HashTable/index.ts.html +0 -320
- package/coverage/lcov-report/src/HashTableLinearProbing/index.html +0 -117
- package/coverage/lcov-report/src/HashTableLinearProbing/index.ts.html +0 -95
- package/coverage/lcov-report/src/HashTableSeparateChaining/HashTableSeparateChainingElement.ts.html +0 -149
- package/coverage/lcov-report/src/HashTableSeparateChaining/index.html +0 -132
- package/coverage/lcov-report/src/HashTableSeparateChaining/index.ts.html +0 -398
- package/coverage/lcov-report/src/LinkedList/Node.ts.html +0 -110
- package/coverage/lcov-report/src/LinkedList/index.html +0 -132
- package/coverage/lcov-report/src/LinkedList/index.ts.html +0 -641
- package/coverage/lcov-report/src/List/index.html +0 -117
- package/coverage/lcov-report/src/List/index.ts.html +0 -89
- package/coverage/lcov-report/src/Queue/index.html +0 -117
- package/coverage/lcov-report/src/Queue/index.ts.html +0 -218
- package/coverage/lcov-report/src/Set/index.html +0 -117
- package/coverage/lcov-report/src/Set/index.ts.html +0 -488
- package/coverage/lcov-report/src/Stack/index.html +0 -117
- package/coverage/lcov-report/src/Stack/index.ts.html +0 -215
- package/coverage/lcov-report/src/index.html +0 -117
- package/coverage/lcov-report/src/index.ts.html +0 -125
- package/coverage/lcov.info +0 -1346
- package/src/Algorithms/index.spec.ts +0 -15
- package/src/Algorithms/index.ts +0 -21
- package/src/Array/IArray.ts +0 -10
- package/src/Array/index.spec.ts +0 -151
- package/src/Array/index.ts +0 -68
- package/src/BinarySearchTree/BinarySearchTreeNode.spec.ts +0 -29
- package/src/BinarySearchTree/BinarySearchTreeNode.ts +0 -23
- package/src/BinarySearchTree/IBinarySearchNodeOptions.ts +0 -6
- package/src/BinarySearchTree/IBinarySearchTree.ts +0 -16
- package/src/BinarySearchTree/IBinarySearchTreeData.ts +0 -9
- package/src/BinarySearchTree/index.spec.ts +0 -486
- package/src/BinarySearchTree/index.ts +0 -198
- package/src/DataStructure/index.spec.ts +0 -25
- package/src/DataStructure/index.ts +0 -15
- package/src/Deck/IDeck.ts +0 -10
- package/src/Deck/index.spec.ts +0 -131
- package/src/Deck/index.ts +0 -51
- package/src/Dictionary/IDictionary.ts +0 -18
- package/src/Dictionary/IDictionaryData.ts +0 -5
- package/src/Dictionary/index.spec.ts +0 -310
- package/src/Dictionary/index.ts +0 -88
- package/src/DoublyLinkedList/IDoublyLinkedList.ts +0 -18
- package/src/DoublyLinkedList/Node.ts +0 -9
- package/src/DoublyLinkedList/index.spec.ts +0 -478
- package/src/DoublyLinkedList/index.ts +0 -250
- package/src/Graph/GraphNodeNotFoundError.ts +0 -7
- package/src/Graph/GraphSearchNodeStates.ts +0 -8
- package/src/Graph/IGraph.ts +0 -15
- package/src/Graph/IGraphOptions.ts +0 -6
- package/src/Graph/index.spec.ts +0 -318
- package/src/Graph/index.ts +0 -170
- package/src/HashTable/IHashTable.ts +0 -11
- package/src/HashTable/IHashTableData.ts +0 -5
- package/src/HashTable/IHashTableInputs.ts +0 -5
- package/src/HashTable/IHashTableOptions.ts +0 -5
- package/src/HashTable/index.spec.ts +0 -136
- package/src/HashTable/index.ts +0 -78
- package/src/HashTableLinearProbing/HashTableLinearProbingElement.spec.ts +0 -28
- package/src/HashTableLinearProbing/HashTableLinearProbingElement.ts +0 -18
- package/src/HashTableLinearProbing/IHashTableLinearProbing.ts +0 -11
- package/src/HashTableLinearProbing/IHashTableLinearProbingData.ts +0 -7
- package/src/HashTableLinearProbing/IHashTableLinearProbingInputs.ts +0 -5
- package/src/HashTableLinearProbing/IHashTableLinearProbingOptions.ts +0 -5
- package/src/HashTableLinearProbing/index.spec.ts +0 -266
- package/src/HashTableLinearProbing/index.ts +0 -128
- package/src/HashTableSeparateChaining/HashTableSeparateChainingElement.ts +0 -21
- package/src/HashTableSeparateChaining/IHashTableSeparateChaining.ts +0 -12
- package/src/HashTableSeparateChaining/IHashTableSeparateChainingData.ts +0 -7
- package/src/HashTableSeparateChaining/IHashTableSeparateChainingInputs.ts +0 -5
- package/src/HashTableSeparateChaining/IHashTableSeparateChainingOptions.ts +0 -5
- package/src/HashTableSeparateChaining/index.spec.ts +0 -173
- package/src/HashTableSeparateChaining/index.ts +0 -104
- package/src/LinkedList/ILinkedList.ts +0 -15
- package/src/LinkedList/ILinkedListItem.ts +0 -6
- package/src/LinkedList/Node.ts +0 -8
- package/src/LinkedList/index.spec.ts +0 -355
- package/src/LinkedList/index.ts +0 -185
- package/src/List/index.ts +0 -1
- package/src/MaxHeap/IMaxHeap.ts +0 -10
- package/src/MaxHeap/IMaxHeapOptions.ts +0 -6
- package/src/MaxHeap/index.spec.ts +0 -161
- package/src/MaxHeap/index.ts +0 -91
- package/src/MinHeap/IMinHeap.ts +0 -10
- package/src/MinHeap/IMinHeapOptions.ts +0 -6
- package/src/MinHeap/index.spec.ts +0 -161
- package/src/MinHeap/index.ts +0 -91
- package/src/Queue/IQueue.ts +0 -9
- package/src/Queue/index.spec.ts +0 -92
- package/src/Queue/index.ts +0 -44
- package/src/Set/ISet.ts +0 -17
- package/src/Set/index.spec.ts +0 -246
- package/src/Set/index.ts +0 -134
- package/src/Stack/IStack.ts +0 -9
- package/src/Stack/index.spec.ts +0 -108
- package/src/Stack/index.ts +0 -43
- package/src/index.ts +0 -17
package/src/Stack/index.spec.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import {describe, expect, it} from '@jest/globals';
|
|
2
|
-
import faker from 'faker';
|
|
3
|
-
|
|
4
|
-
import Stack from './';
|
|
5
|
-
|
|
6
|
-
describe('Stack', () => {
|
|
7
|
-
it('Should create an empty stack with no problems', () => {
|
|
8
|
-
const stack = new Stack();
|
|
9
|
-
|
|
10
|
-
expect(stack.data).toEqual([]);
|
|
11
|
-
expect(stack.size).toBe(0);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('Should create a filled stack with no problems', () => {
|
|
15
|
-
const stack = new Stack(1, 2, 3, 4, 5);
|
|
16
|
-
|
|
17
|
-
expect(stack.data).toEqual([1, 2, 3, 4, 5]);
|
|
18
|
-
expect(stack.size).toBe(5);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe('.push()', () => {
|
|
22
|
-
it('Should return the correct size of the stack', () => {
|
|
23
|
-
const size = faker.datatype.number(200);
|
|
24
|
-
const params = [];
|
|
25
|
-
|
|
26
|
-
for (let i = 0; i < size; i++) {
|
|
27
|
-
params.push(faker.datatype.number());
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const stack = new Stack(...params);
|
|
31
|
-
|
|
32
|
-
expect(stack.size).toBe(size);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('Should push a new element in the stack top', () => {
|
|
36
|
-
const stack = new Stack(1, 2, 3);
|
|
37
|
-
stack.push(4);
|
|
38
|
-
|
|
39
|
-
expect(stack.data).toEqual([1, 2, 3, 4]);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('.pop()', () => {
|
|
44
|
-
it('Should pop the top element from the stack', () => {
|
|
45
|
-
const stack = new Stack(1, 2, 3, 4);
|
|
46
|
-
const element = stack.pop();
|
|
47
|
-
|
|
48
|
-
expect(stack.data).toEqual([1, 2, 3]);
|
|
49
|
-
expect(element).toBe(4);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe('.peek()', () => {
|
|
54
|
-
it('Should peek the top element of the stack', () => {
|
|
55
|
-
const stack = new Stack(1, 2, 3, 4);
|
|
56
|
-
const element = stack.peek();
|
|
57
|
-
|
|
58
|
-
expect(element).toBe(4);
|
|
59
|
-
expect(stack.data).toEqual([1, 2, 3, 4]);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('Should peek undefined when the stack has no elements', () => {
|
|
63
|
-
const stack = new Stack();
|
|
64
|
-
const element = stack.peek();
|
|
65
|
-
|
|
66
|
-
expect(element).toBe(undefined);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
describe('.clear()', () => {
|
|
71
|
-
it('Should clear a stack', () => {
|
|
72
|
-
const stack = new Stack(1, 2, 3, 4);
|
|
73
|
-
stack.clear();
|
|
74
|
-
|
|
75
|
-
expect(stack.data).toEqual([]);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('.isEmpty', () => {
|
|
80
|
-
it('Should return true when the stack has no elements', () => {
|
|
81
|
-
const stack = new Stack();
|
|
82
|
-
|
|
83
|
-
expect(stack.isEmpty).toBe(true);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('Should return false when the stack at least one element', () => {
|
|
87
|
-
const stack = new Stack(1);
|
|
88
|
-
|
|
89
|
-
expect(stack.isEmpty).toBe(false);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe('Conversion to primitive', () => {
|
|
94
|
-
it('Should return comma-separated elements in string conversion', () => {
|
|
95
|
-
const stack = new Stack(1, 2, 3, 4);
|
|
96
|
-
const string = String(stack);
|
|
97
|
-
|
|
98
|
-
expect(string).toBe('1, 2, 3, 4 [Top]');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('Should return the stack size in number conversion', () => {
|
|
102
|
-
const stack = new Stack(1, 2, 3, 4);
|
|
103
|
-
const number = Number(stack);
|
|
104
|
-
|
|
105
|
-
expect(number).toBe(4);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
});
|
package/src/Stack/index.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import DataStructure from '../DataStructure';
|
|
2
|
-
import IStack from './IStack';
|
|
3
|
-
|
|
4
|
-
export default class Stack<T = number> extends DataStructure<T> implements IStack<T> {
|
|
5
|
-
constructor(...inputs: T[]) {
|
|
6
|
-
super(inputs);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
public push(element: T) {
|
|
10
|
-
this._data.push(element);
|
|
11
|
-
return element;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public pop(): T | undefined {
|
|
15
|
-
const element = this._data.pop();
|
|
16
|
-
return element;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public peek(): T | undefined {
|
|
20
|
-
const topPosition = this.data.length - 1;
|
|
21
|
-
return this.data[topPosition];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public clear(): void {
|
|
25
|
-
this._data = [];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public get isEmpty(): boolean {
|
|
29
|
-
return this.data.length === 0;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
private [Symbol.toPrimitive](type: string): string | number | null {
|
|
33
|
-
if (type === 'string') {
|
|
34
|
-
return `${this.data.join(', ')} [Top]`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (type === 'number') {
|
|
38
|
-
return this.size;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export {default as Algorithms} from './Algorithms';
|
|
2
|
-
export {default as Array} from './Array';
|
|
3
|
-
export {default as BinarySearchTree} from './BinarySearchTree';
|
|
4
|
-
export {default as Deck} from './Deck';
|
|
5
|
-
export {default as Dictionary} from './Dictionary';
|
|
6
|
-
export {default as DoublyLinkedList} from './DoublyLinkedList';
|
|
7
|
-
export {default as Graph} from './Graph';
|
|
8
|
-
export {default as HashTable} from './HashTable';
|
|
9
|
-
export {default as HashTableLinearProbing} from './HashTableLinearProbing';
|
|
10
|
-
export {default as HashTableSeparateChaining} from './HashTableSeparateChaining';
|
|
11
|
-
export {default as LinkedList} from './LinkedList';
|
|
12
|
-
export {default as List} from './List';
|
|
13
|
-
export {default as MaxHeap} from './MaxHeap';
|
|
14
|
-
export {default as MinHeap} from './MinHeap';
|
|
15
|
-
export {default as Queue} from './Queue';
|
|
16
|
-
export {default as Set} from './Set';
|
|
17
|
-
export {default as Stack} from './Stack';
|