@raikuxq/alg-ds 1.1.5 → 1.1.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/README.md +0 -14
- package/package.json +1 -1
- package/lib/algorithms/binary-search.d.ts +0 -5
- package/lib/algorithms/binary-search.js +0 -27
- package/lib/algorithms/factorial.d.ts +0 -9
- package/lib/algorithms/factorial.js +0 -17
- package/lib/algorithms/fibonacci.d.ts +0 -9
- package/lib/algorithms/fibonacci.js +0 -17
- package/lib/algorithms/memoize.d.ts +0 -5
- package/lib/algorithms/memoize.js +0 -22
- package/lib/algorithms/sorts/bubble-sort.d.ts +0 -9
- package/lib/algorithms/sorts/bubble-sort.js +0 -23
- package/lib/algorithms/sorts/insertion-sort.d.ts +0 -9
- package/lib/algorithms/sorts/insertion-sort.js +0 -25
- package/lib/algorithms/sorts/merge-sort.d.ts +0 -9
- package/lib/algorithms/sorts/merge-sort.js +0 -61
- package/lib/algorithms/sorts/quick-sort.d.ts +0 -9
- package/lib/algorithms/sorts/quick-sort.js +0 -45
- package/lib/algorithms/sorts/select-sort.d.ts +0 -9
- package/lib/algorithms/sorts/select-sort.js +0 -20
- package/lib/algorithms/transpose-matrix.d.ts +0 -5
- package/lib/algorithms/transpose-matrix.js +0 -20
- package/lib/constants.d.ts +0 -2
- package/lib/constants.js +0 -6
- package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.d.ts +0 -15
- package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.js +0 -53
- package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.d.ts +0 -60
- package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.js +0 -36
- package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.d.ts +0 -13
- package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.js +0 -59
- package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.d.ts +0 -70
- package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.js +0 -268
- package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.d.ts +0 -16
- package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.js +0 -70
- package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.d.ts +0 -57
- package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.js +0 -234
- package/lib/data-structures/Graph/AbstractGraph.d.ts +0 -84
- package/lib/data-structures/Graph/AbstractGraph.js +0 -141
- package/lib/data-structures/Graph/DirectedGraph.d.ts +0 -24
- package/lib/data-structures/Graph/DirectedGraph.js +0 -85
- package/lib/data-structures/Graph/GraphEdge.d.ts +0 -16
- package/lib/data-structures/Graph/GraphEdge.js +0 -43
- package/lib/data-structures/Graph/UndirectedGraph.d.ts +0 -28
- package/lib/data-structures/Graph/UndirectedGraph.js +0 -102
- package/lib/data-structures/Graph/demo/generateRandomGraph.d.ts +0 -4
- package/lib/data-structures/Graph/demo/generateRandomGraph.js +0 -72
- package/lib/data-structures/Graph/iterator/AbstractGraphIterator.d.ts +0 -35
- package/lib/data-structures/Graph/iterator/AbstractGraphIterator.js +0 -90
- package/lib/data-structures/Graph/iterator/GraphIteratorBFS.d.ts +0 -28
- package/lib/data-structures/Graph/iterator/GraphIteratorBFS.js +0 -70
- package/lib/data-structures/Graph/iterator/GraphIteratorDFS.d.ts +0 -28
- package/lib/data-structures/Graph/iterator/GraphIteratorDFS.js +0 -70
- package/lib/data-structures/Graph/iterator/GraphIteratorDijkstra.d.ts +0 -32
- package/lib/data-structures/Graph/iterator/GraphIteratorDijkstra.js +0 -99
- package/lib/data-structures/Graph/presenter/presenterAdjacencyLists.d.ts +0 -19
- package/lib/data-structures/Graph/presenter/presenterAdjacencyLists.js +0 -28
- package/lib/data-structures/Graph/presenter/presenterAdjacencyMatrix.d.ts +0 -32
- package/lib/data-structures/Graph/presenter/presenterAdjacencyMatrix.js +0 -48
- package/lib/data-structures/Graph/searching/hasPath.d.ts +0 -9
- package/lib/data-structures/Graph/searching/hasPath.js +0 -29
- package/lib/data-structures/Graph/searching/shortestPath.d.ts +0 -9
- package/lib/data-structures/Graph/searching/shortestPath.js +0 -29
- package/lib/data-structures/Graph/strategy/BFSIterationStrategy.d.ts +0 -6
- package/lib/data-structures/Graph/strategy/BFSIterationStrategy.js +0 -13
- package/lib/data-structures/Graph/strategy/DFSIterationStrategy.d.ts +0 -6
- package/lib/data-structures/Graph/strategy/DFSIterationStrategy.js +0 -13
- package/lib/data-structures/Graph/strategy/DijkstraIterationStrategy.d.ts +0 -6
- package/lib/data-structures/Graph/strategy/DijkstraIterationStrategy.js +0 -13
- package/lib/data-structures/Graph/transposing/transposeDirectedGraph.d.ts +0 -2
- package/lib/data-structures/Graph/transposing/transposeDirectedGraph.js +0 -14
- package/lib/data-structures/HashTable/HashTable.d.ts +0 -73
- package/lib/data-structures/HashTable/HashTable.js +0 -169
- package/lib/data-structures/HashTable/HashTableNode.d.ts +0 -11
- package/lib/data-structures/HashTable/HashTableNode.js +0 -39
- package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.d.ts +0 -125
- package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.js +0 -236
- package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedNode.d.ts +0 -20
- package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedNode.js +0 -41
- package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.d.ts +0 -48
- package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.js +0 -150
- package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedNode.d.ts +0 -25
- package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedNode.js +0 -65
- package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.d.ts +0 -52
- package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.js +0 -137
- package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedNode.d.ts +0 -7
- package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedNode.js +0 -29
- package/lib/data-structures/LoopedArray/LoopedArray.d.ts +0 -86
- package/lib/data-structures/LoopedArray/LoopedArray.js +0 -161
- package/lib/data-structures/Queue/Queue.d.ts +0 -50
- package/lib/data-structures/Queue/Queue.js +0 -83
- package/lib/data-structures/Stack/Stack.d.ts +0 -50
- package/lib/data-structures/Stack/Stack.js +0 -83
- package/lib/exports/algorithms.d.ts +0 -16
- package/lib/exports/algorithms.js +0 -36
- package/lib/exports/constants.d.ts +0 -2
- package/lib/exports/constants.js +0 -7
- package/lib/exports/data-structures.d.ts +0 -11
- package/lib/exports/data-structures.js +0 -24
- package/lib/exports/helpers.d.ts +0 -6
- package/lib/exports/helpers.js +0 -14
- package/lib/exports/sorts.d.ts +0 -6
- package/lib/exports/sorts.js +0 -14
- package/lib/exports/utils.d.ts +0 -3
- package/lib/exports/utils.js +0 -14
- package/lib/exports.d.ts +0 -44
- package/lib/exports.js +0 -89
- package/lib/helpers/createBinaryTree.d.ts +0 -6
- package/lib/helpers/createBinaryTree.js +0 -22
- package/lib/helpers/createGraph.d.ts +0 -6
- package/lib/helpers/createGraph.js +0 -24
- package/lib/helpers/createGraphFromMatrix.d.ts +0 -7
- package/lib/helpers/createGraphFromMatrix.js +0 -37
- package/lib/helpers/createLinkedList.d.ts +0 -3
- package/lib/helpers/createLinkedList.js +0 -21
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -6
- package/lib/types/ArrayMatrix.d.ts +0 -1
- package/lib/types/ArrayMatrix.js +0 -3
- package/lib/types/EnumBinarySearchTreeType.d.ts +0 -4
- package/lib/types/EnumBinarySearchTreeType.js +0 -9
- package/lib/types/EnumGraphType.d.ts +0 -4
- package/lib/types/EnumGraphType.js +0 -9
- package/lib/types/EnumLinkedListType.d.ts +0 -4
- package/lib/types/EnumLinkedListType.js +0 -9
- package/lib/types/EnumRandomGenerationFormat.d.ts +0 -4
- package/lib/types/EnumRandomGenerationFormat.js +0 -9
- package/lib/types/EnumTreeTraversalType.d.ts +0 -5
- package/lib/types/EnumTreeTraversalType.js +0 -10
- package/lib/types/FnCompareTwo.d.ts +0 -1
- package/lib/types/FnCompareTwo.js +0 -3
- package/lib/types/FnToMemoize.d.ts +0 -1
- package/lib/types/FnToMemoize.js +0 -3
- package/lib/types/IArrayFacade.d.ts +0 -4
- package/lib/types/IArrayFacade.js +0 -3
- package/lib/types/IBiDirectIterable.d.ts +0 -5
- package/lib/types/IBiDirectIterable.js +0 -3
- package/lib/types/IBiDirectIterator.d.ts +0 -11
- package/lib/types/IBiDirectIterator.js +0 -3
- package/lib/types/IBinaryTree.d.ts +0 -12
- package/lib/types/IBinaryTree.js +0 -3
- package/lib/types/IConvertableToArray.d.ts +0 -4
- package/lib/types/IConvertableToArray.js +0 -3
- package/lib/types/IGraph.d.ts +0 -14
- package/lib/types/IGraph.js +0 -3
- package/lib/types/IGraphIterationStrategy.d.ts +0 -5
- package/lib/types/IGraphIterationStrategy.js +0 -3
- package/lib/types/IGraphIterator.d.ts +0 -11
- package/lib/types/IGraphIterator.js +0 -3
- package/lib/types/IIterable.d.ts +0 -4
- package/lib/types/IIterable.js +0 -3
- package/lib/types/IIterator.d.ts +0 -14
- package/lib/types/IIterator.js +0 -3
- package/lib/types/IKeyValueStorage.d.ts +0 -8
- package/lib/types/IKeyValueStorage.js +0 -3
- package/lib/types/ILinearStorage.d.ts +0 -11
- package/lib/types/ILinearStorage.js +0 -3
- package/lib/types/ILinearStorageRA.d.ts +0 -13
- package/lib/types/ILinearStorageRA.js +0 -3
- package/lib/types/ILinkedList.d.ts +0 -4
- package/lib/types/ILinkedList.js +0 -3
- package/lib/utils.d.ts +0 -29
- package/lib/utils.js +0 -95
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
var AbstractLinkedNode_1 = require("../AbstractLinkedList/AbstractLinkedNode");
|
|
17
|
-
var DoubleLinkedNode = /** @class */ (function (_super) {
|
|
18
|
-
__extends(DoubleLinkedNode, _super);
|
|
19
|
-
/**
|
|
20
|
-
* Will create empty node
|
|
21
|
-
*/
|
|
22
|
-
function DoubleLinkedNode(data, next, prev) {
|
|
23
|
-
if (next === void 0) { next = null; }
|
|
24
|
-
if (prev === void 0) { prev = null; }
|
|
25
|
-
var _this = _super.call(this, data) || this;
|
|
26
|
-
_this._prev = prev;
|
|
27
|
-
_this._next = next;
|
|
28
|
-
return _this;
|
|
29
|
-
}
|
|
30
|
-
Object.defineProperty(DoubleLinkedNode.prototype, "prev", {
|
|
31
|
-
/**
|
|
32
|
-
* Get previous node link
|
|
33
|
-
*/
|
|
34
|
-
get: function () {
|
|
35
|
-
return this._prev;
|
|
36
|
-
},
|
|
37
|
-
/**
|
|
38
|
-
* Set previous node link
|
|
39
|
-
*/
|
|
40
|
-
set: function (value) {
|
|
41
|
-
this._prev = value;
|
|
42
|
-
},
|
|
43
|
-
enumerable: false,
|
|
44
|
-
configurable: true
|
|
45
|
-
});
|
|
46
|
-
Object.defineProperty(DoubleLinkedNode.prototype, "next", {
|
|
47
|
-
/**
|
|
48
|
-
* @inheritDoc
|
|
49
|
-
*/
|
|
50
|
-
get: function () {
|
|
51
|
-
return this._next;
|
|
52
|
-
},
|
|
53
|
-
/**
|
|
54
|
-
* @inheritDoc
|
|
55
|
-
*/
|
|
56
|
-
set: function (value) {
|
|
57
|
-
this._next = value;
|
|
58
|
-
},
|
|
59
|
-
enumerable: false,
|
|
60
|
-
configurable: true
|
|
61
|
-
});
|
|
62
|
-
return DoubleLinkedNode;
|
|
63
|
-
}(AbstractLinkedNode_1.default));
|
|
64
|
-
exports.default = DoubleLinkedNode;
|
|
65
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRG91YmxlTGlua2VkTm9kZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9kYXRhLXN0cnVjdHVyZXMvTGlua2VkTGlzdC9Eb3VibGVMaW5rZWRMaXN0L0RvdWJsZUxpbmtlZE5vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsK0VBQTBFO0FBRTFFO0lBQWlELG9DQUFxQjtJQUlwRTs7T0FFRztJQUNILDBCQUNFLElBQU8sRUFDUCxJQUF1QyxFQUN2QyxJQUF1QztRQUR2QyxxQkFBQSxFQUFBLFdBQXVDO1FBQ3ZDLHFCQUFBLEVBQUEsV0FBdUM7UUFIekMsWUFLRSxrQkFBTSxJQUFJLENBQUMsU0FHWjtRQUZDLEtBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDO1FBQ2xCLEtBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDOztJQUNwQixDQUFDO0lBS0Qsc0JBQVcsa0NBQUk7UUFJZjs7V0FFRzthQUNIO1lBQ0UsT0FBTyxJQUFJLENBQUMsS0FBSyxDQUFDO1FBQ3BCLENBQUM7UUFaRDs7V0FFRzthQUNILFVBQWdCLEtBQWlDO1lBQy9DLElBQUksQ0FBQyxLQUFLLEdBQUcsS0FBSyxDQUFDO1FBQ3JCLENBQUM7OztPQUFBO0lBWUQsc0JBQVcsa0NBQUk7UUFJZjs7V0FFRzthQUNIO1lBQ0UsT0FBTyxJQUFJLENBQUMsS0FBSyxDQUFDO1FBQ3BCLENBQUM7UUFaRDs7V0FFRzthQUNILFVBQWdCLEtBQWlDO1lBQy9DLElBQUksQ0FBQyxLQUFLLEdBQUcsS0FBSyxDQUFDO1FBQ3JCLENBQUM7OztPQUFBO0lBUUgsdUJBQUM7QUFBRCxDQUFDLEFBNUNELENBQWlELDRCQUFrQixHQTRDbEUifQ==
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import IIterator from "../../../types/IIterator";
|
|
2
|
-
import IIterable from "../../../types/IIterable";
|
|
3
|
-
import AbstractLinkedList from "../AbstractLinkedList/AbstractLinkedList";
|
|
4
|
-
import SingleLinkedNode from "./SingleLinkedNode";
|
|
5
|
-
/**
|
|
6
|
-
* Linear data structure
|
|
7
|
-
* Each node has next
|
|
8
|
-
* Head's next node is tail
|
|
9
|
-
*/
|
|
10
|
-
export default class SingleLinkedList<T> extends AbstractLinkedList<T> implements IIterable<T> {
|
|
11
|
-
/**
|
|
12
|
-
* Override types
|
|
13
|
-
*/
|
|
14
|
-
protected _head: SingleLinkedNode<T> | null;
|
|
15
|
-
protected _tail: SingleLinkedNode<T> | null;
|
|
16
|
-
/**
|
|
17
|
-
* @inheritDoc
|
|
18
|
-
*/
|
|
19
|
-
constructor(capacity?: number);
|
|
20
|
-
/**
|
|
21
|
-
* Find previous sibling of given node
|
|
22
|
-
*/
|
|
23
|
-
private getPrevNode;
|
|
24
|
-
/**
|
|
25
|
-
* @inheritDoc
|
|
26
|
-
*/
|
|
27
|
-
protected createNode(value: T): SingleLinkedNode<T>;
|
|
28
|
-
/**
|
|
29
|
-
* @inheritDoc
|
|
30
|
-
*/
|
|
31
|
-
protected insertNodeBetweenTwoNodesImpl(targetNode: SingleLinkedNode<T>, leftNode: SingleLinkedNode<T>, rightNode: SingleLinkedNode<T>): void;
|
|
32
|
-
/**
|
|
33
|
-
* @inheritDoc
|
|
34
|
-
*/
|
|
35
|
-
protected deleteNodeImpl(node: SingleLinkedNode<T>): void;
|
|
36
|
-
/**
|
|
37
|
-
* @inheritDoc
|
|
38
|
-
*/
|
|
39
|
-
protected popImpl(): void;
|
|
40
|
-
/**
|
|
41
|
-
* @inheritDoc
|
|
42
|
-
*/
|
|
43
|
-
protected shiftImpl(): void;
|
|
44
|
-
/**
|
|
45
|
-
* @inheritDoc
|
|
46
|
-
*/
|
|
47
|
-
reverse(): void;
|
|
48
|
-
/**
|
|
49
|
-
* List iterator
|
|
50
|
-
*/
|
|
51
|
-
iterator(fromIndex?: number): IIterator<T>;
|
|
52
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
var AbstractLinkedList_1 = require("../AbstractLinkedList/AbstractLinkedList");
|
|
17
|
-
var SingleLinkedNode_1 = require("./SingleLinkedNode");
|
|
18
|
-
/**
|
|
19
|
-
* Linear data structure
|
|
20
|
-
* Each node has next
|
|
21
|
-
* Head's next node is tail
|
|
22
|
-
*/
|
|
23
|
-
var SingleLinkedList = /** @class */ (function (_super) {
|
|
24
|
-
__extends(SingleLinkedList, _super);
|
|
25
|
-
/**
|
|
26
|
-
* @inheritDoc
|
|
27
|
-
*/
|
|
28
|
-
function SingleLinkedList(capacity) {
|
|
29
|
-
var _this = _super.call(this, capacity) || this;
|
|
30
|
-
_this._head = null;
|
|
31
|
-
_this._tail = null;
|
|
32
|
-
return _this;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Find previous sibling of given node
|
|
36
|
-
*/
|
|
37
|
-
SingleLinkedList.prototype.getPrevNode = function (node) {
|
|
38
|
-
var currentNode = this._tail;
|
|
39
|
-
while ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.next) !== node) {
|
|
40
|
-
currentNode = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.next) || null;
|
|
41
|
-
}
|
|
42
|
-
return currentNode;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* @inheritDoc
|
|
46
|
-
*/
|
|
47
|
-
SingleLinkedList.prototype.createNode = function (value) {
|
|
48
|
-
return new SingleLinkedNode_1.default(value);
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* @inheritDoc
|
|
52
|
-
*/
|
|
53
|
-
SingleLinkedList.prototype.insertNodeBetweenTwoNodesImpl = function (targetNode, leftNode, rightNode) {
|
|
54
|
-
targetNode.next = rightNode;
|
|
55
|
-
if (leftNode) {
|
|
56
|
-
leftNode.next = targetNode;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* @inheritDoc
|
|
61
|
-
*/
|
|
62
|
-
SingleLinkedList.prototype.deleteNodeImpl = function (node) {
|
|
63
|
-
this.getPrevNode(node).next = node.next;
|
|
64
|
-
node.next = null;
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* @inheritDoc
|
|
68
|
-
*/
|
|
69
|
-
SingleLinkedList.prototype.popImpl = function () {
|
|
70
|
-
this._head = this.getPrevNode(this._tail);
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* @inheritDoc
|
|
74
|
-
*/
|
|
75
|
-
SingleLinkedList.prototype.shiftImpl = function () {
|
|
76
|
-
var _a;
|
|
77
|
-
this._tail = ((_a = this._head) === null || _a === void 0 ? void 0 : _a.next) || null;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* @inheritDoc
|
|
81
|
-
*/
|
|
82
|
-
SingleLinkedList.prototype.reverse = function () {
|
|
83
|
-
var currentNode = this._tail;
|
|
84
|
-
var prevNode = this._head;
|
|
85
|
-
var index = 0;
|
|
86
|
-
while (index < this._length) {
|
|
87
|
-
var next = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.next) || null;
|
|
88
|
-
if (currentNode) {
|
|
89
|
-
currentNode.next = prevNode;
|
|
90
|
-
}
|
|
91
|
-
index++;
|
|
92
|
-
prevNode = currentNode;
|
|
93
|
-
currentNode = next;
|
|
94
|
-
}
|
|
95
|
-
if (currentNode) {
|
|
96
|
-
this._head = currentNode;
|
|
97
|
-
this._tail = currentNode.next;
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* List iterator
|
|
102
|
-
*/
|
|
103
|
-
SingleLinkedList.prototype.iterator = function (fromIndex) {
|
|
104
|
-
if (fromIndex === void 0) { fromIndex = 0; }
|
|
105
|
-
var head = this._head;
|
|
106
|
-
var activeNode = this.getNodeByIndex(fromIndex);
|
|
107
|
-
var iterator = {
|
|
108
|
-
/**
|
|
109
|
-
* @inheritDoc
|
|
110
|
-
*/
|
|
111
|
-
current: function () {
|
|
112
|
-
return activeNode.data;
|
|
113
|
-
},
|
|
114
|
-
/**
|
|
115
|
-
* @inheritDoc
|
|
116
|
-
*/
|
|
117
|
-
hasNext: function () {
|
|
118
|
-
return Boolean(activeNode.next) && activeNode !== head;
|
|
119
|
-
},
|
|
120
|
-
/**
|
|
121
|
-
* @inheritDoc
|
|
122
|
-
* @throws when next element does not exist
|
|
123
|
-
*/
|
|
124
|
-
next: function () {
|
|
125
|
-
if (!iterator.hasNext()) {
|
|
126
|
-
throw new Error("Next element does not exist");
|
|
127
|
-
}
|
|
128
|
-
activeNode = activeNode.next;
|
|
129
|
-
return activeNode.data;
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
return iterator;
|
|
133
|
-
};
|
|
134
|
-
return SingleLinkedList;
|
|
135
|
-
}(AbstractLinkedList_1.default));
|
|
136
|
-
exports.default = SingleLinkedList;
|
|
137
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2luZ2xlTGlua2VkTGlzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9kYXRhLXN0cnVjdHVyZXMvTGlua2VkTGlzdC9TaW5nbGVMaW5rZWRMaXN0L1NpbmdsZUxpbmtlZExpc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7O0FBRUEsK0VBQTBFO0FBQzFFLHVEQUFrRDtBQUVsRDs7OztHQUlHO0FBQ0g7SUFDVSxvQ0FBcUI7SUFRN0I7O09BRUc7SUFDSCwwQkFBbUIsUUFBaUI7UUFBcEMsWUFDRSxrQkFBTSxRQUFRLENBQUMsU0FHaEI7UUFGQyxLQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQztRQUNsQixLQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQzs7SUFDcEIsQ0FBQztJQUVEOztPQUVHO0lBQ0ssc0NBQVcsR0FBbkIsVUFDRSxJQUFnQztRQUVoQyxJQUFJLFdBQVcsR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDO1FBQzdCLE9BQU8sQ0FBQSxXQUFXLGFBQVgsV0FBVyx1QkFBWCxXQUFXLENBQUUsSUFBSSxNQUFLLElBQUksRUFBRTtZQUNqQyxXQUFXLEdBQUcsQ0FBQSxXQUFXLGFBQVgsV0FBVyx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ELENBQUM7WUFDRDs7O2VBR0c7WUFDSCxJQUFJLEVBQUU7Z0JBQ0osSUFBSSxDQUFDLFFBQVEsQ0FBQyxPQUFPLEVBQUUsRUFBRTtvQkFDdkIsTUFBTSxJQUFJLEtBQUssQ0FBQyw2QkFBNkIsQ0FBQyxDQUFDO2lCQUNoRDtnQkFDRCxVQUFVLEdBQUcsVUFBVSxDQUFDLElBQUssQ0FBQztnQkFDOUIsT0FBTyxVQUFVLENBQUMsSUFBSSxDQUFDO1lBQ3pCLENBQUM7U0FDRixDQUFDO1FBRUYsT0FBTyxRQUFRLENBQUM7SUFDbEIsQ0FBQztJQUNILHVCQUFDO0FBQUQsQ0FBQyxBQXhJRCxDQUNVLDRCQUFrQixHQXVJM0IifQ==
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
var AbstractLinkedNode_1 = require("../AbstractLinkedList/AbstractLinkedNode");
|
|
17
|
-
var SingleLinkedNode = /** @class */ (function (_super) {
|
|
18
|
-
__extends(SingleLinkedNode, _super);
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
function SingleLinkedNode(data, next) {
|
|
23
|
-
if (next === void 0) { next = null; }
|
|
24
|
-
return _super.call(this, data, next) || this;
|
|
25
|
-
}
|
|
26
|
-
return SingleLinkedNode;
|
|
27
|
-
}(AbstractLinkedNode_1.default));
|
|
28
|
-
exports.default = SingleLinkedNode;
|
|
29
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2luZ2xlTGlua2VkTm9kZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9kYXRhLXN0cnVjdHVyZXMvTGlua2VkTGlzdC9TaW5nbGVMaW5rZWRMaXN0L1NpbmdsZUxpbmtlZE5vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsK0VBQTBFO0FBRTFFO0lBQWlELG9DQUFxQjtJQUNwRTs7T0FFRztJQUNILDBCQUFtQixJQUFPLEVBQUUsSUFBdUM7UUFBdkMscUJBQUEsRUFBQSxXQUF1QztlQUNqRSxrQkFBTSxJQUFJLEVBQUUsSUFBSSxDQUFDO0lBQ25CLENBQUM7SUFDSCx1QkFBQztBQUFELENBQUMsQUFQRCxDQUFpRCw0QkFBa0IsR0FPbEUifQ==
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import IArrayFacade from "../../types/IArrayFacade";
|
|
2
|
-
/**
|
|
3
|
-
* Linear data structure
|
|
4
|
-
* Facade above array
|
|
5
|
-
* After reaching full array new pushed elements will be overwritten over old elements
|
|
6
|
-
*/
|
|
7
|
-
export default class LoopedArray<T> implements IArrayFacade<T> {
|
|
8
|
-
private readonly _capacity;
|
|
9
|
-
private _realLength;
|
|
10
|
-
private _array;
|
|
11
|
-
/**
|
|
12
|
-
* Create empty instance
|
|
13
|
-
*/
|
|
14
|
-
constructor(capacity: number);
|
|
15
|
-
/**
|
|
16
|
-
* Push into end
|
|
17
|
-
*/
|
|
18
|
-
push(value: T): void;
|
|
19
|
-
/**
|
|
20
|
-
* Push into start
|
|
21
|
-
*/
|
|
22
|
-
unshift(value: T): void;
|
|
23
|
-
/**
|
|
24
|
-
* Delete node from array's end
|
|
25
|
-
*/
|
|
26
|
-
pop(): T;
|
|
27
|
-
/**
|
|
28
|
-
* Delete node from array's start
|
|
29
|
-
*/
|
|
30
|
-
shift(): T;
|
|
31
|
-
/**
|
|
32
|
-
* Get head element data
|
|
33
|
-
* @throws Error when head does not exists
|
|
34
|
-
*/
|
|
35
|
-
peek(): T;
|
|
36
|
-
/**
|
|
37
|
-
* Get tail element data
|
|
38
|
-
* @throws Error when head does not exists
|
|
39
|
-
*/
|
|
40
|
-
peekFromStart(): T;
|
|
41
|
-
/**
|
|
42
|
-
* Get array element by index from start
|
|
43
|
-
* @throws when element does not exists
|
|
44
|
-
*/
|
|
45
|
-
peekByIndex(index: number): T;
|
|
46
|
-
/**
|
|
47
|
-
* Push from index
|
|
48
|
-
*/
|
|
49
|
-
pushFromIndex(value: T, fromIndex: number): void;
|
|
50
|
-
/**
|
|
51
|
-
* Get elements as array
|
|
52
|
-
*/
|
|
53
|
-
getAsArray(): Array<T>;
|
|
54
|
-
/**
|
|
55
|
-
* Check if element exists in array
|
|
56
|
-
*/
|
|
57
|
-
has(item: T): boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Is array empty
|
|
60
|
-
*/
|
|
61
|
-
isEmpty(): boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Is array full
|
|
64
|
-
*/
|
|
65
|
-
isFull(): boolean;
|
|
66
|
-
/**
|
|
67
|
-
* List length
|
|
68
|
-
*/
|
|
69
|
-
length(): number;
|
|
70
|
-
/**
|
|
71
|
-
* Remove all elements from array
|
|
72
|
-
*/
|
|
73
|
-
clear(): void;
|
|
74
|
-
/**
|
|
75
|
-
* Delete node from array by index from start
|
|
76
|
-
*/
|
|
77
|
-
deleteFromIndex(fromIndex: number): T;
|
|
78
|
-
/**
|
|
79
|
-
* Add elements to array from array
|
|
80
|
-
* */
|
|
81
|
-
pushFromArray(elements: Array<T>): void;
|
|
82
|
-
/**
|
|
83
|
-
* Reverse array nodes links and swap head with tail
|
|
84
|
-
*/
|
|
85
|
-
reverse(): void;
|
|
86
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Linear data structure
|
|
5
|
-
* Facade above array
|
|
6
|
-
* After reaching full array new pushed elements will be overwritten over old elements
|
|
7
|
-
*/
|
|
8
|
-
var LoopedArray = /** @class */ (function () {
|
|
9
|
-
/**
|
|
10
|
-
* Create empty instance
|
|
11
|
-
*/
|
|
12
|
-
function LoopedArray(capacity) {
|
|
13
|
-
this._realLength = 0;
|
|
14
|
-
if (capacity <= 0) {
|
|
15
|
-
throw new Error("Capacity must be larger than 0");
|
|
16
|
-
}
|
|
17
|
-
this._capacity = capacity;
|
|
18
|
-
this._array = new Array(0);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Push into end
|
|
22
|
-
*/
|
|
23
|
-
LoopedArray.prototype.push = function (value) {
|
|
24
|
-
if (this._realLength % this._capacity === 0) {
|
|
25
|
-
this._array = new Array(0);
|
|
26
|
-
}
|
|
27
|
-
this._realLength++;
|
|
28
|
-
if (!this.isFull()) {
|
|
29
|
-
this._array.push(value);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
var indexToPush = (this._realLength % this._capacity) - 1;
|
|
33
|
-
this._array.splice(indexToPush, 1, value);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Push into start
|
|
38
|
-
*/
|
|
39
|
-
LoopedArray.prototype.unshift = function (value) {
|
|
40
|
-
if (this._realLength % this._capacity === 0) {
|
|
41
|
-
this._array = new Array(0);
|
|
42
|
-
}
|
|
43
|
-
this._realLength++;
|
|
44
|
-
if (!this.isFull()) {
|
|
45
|
-
this._array.unshift(value);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
this._array.splice(this._capacity - 1);
|
|
49
|
-
this._array.unshift(value);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Delete node from array's end
|
|
54
|
-
*/
|
|
55
|
-
LoopedArray.prototype.pop = function () {
|
|
56
|
-
this._realLength--;
|
|
57
|
-
var deletedItem = this._array.pop();
|
|
58
|
-
if (deletedItem === undefined)
|
|
59
|
-
throw new Error("cannot delete last element because of it does not exists");
|
|
60
|
-
return deletedItem;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Delete node from array's start
|
|
64
|
-
*/
|
|
65
|
-
LoopedArray.prototype.shift = function () {
|
|
66
|
-
this._realLength--;
|
|
67
|
-
var deletedItem = this._array.shift();
|
|
68
|
-
if (deletedItem === undefined)
|
|
69
|
-
throw new Error("cannot delete first element because of it does not exists");
|
|
70
|
-
return deletedItem;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Get head element data
|
|
74
|
-
* @throws Error when head does not exists
|
|
75
|
-
*/
|
|
76
|
-
LoopedArray.prototype.peek = function () {
|
|
77
|
-
return this._array[this._array.length - 1];
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Get tail element data
|
|
81
|
-
* @throws Error when head does not exists
|
|
82
|
-
*/
|
|
83
|
-
LoopedArray.prototype.peekFromStart = function () {
|
|
84
|
-
return this._array[0];
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Get array element by index from start
|
|
88
|
-
* @throws when element does not exists
|
|
89
|
-
*/
|
|
90
|
-
LoopedArray.prototype.peekByIndex = function (index) {
|
|
91
|
-
return this._array[index];
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* Push from index
|
|
95
|
-
*/
|
|
96
|
-
LoopedArray.prototype.pushFromIndex = function (value, fromIndex) {
|
|
97
|
-
this._array[fromIndex] = value;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Get elements as array
|
|
101
|
-
*/
|
|
102
|
-
LoopedArray.prototype.getAsArray = function () {
|
|
103
|
-
return this._array;
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Check if element exists in array
|
|
107
|
-
*/
|
|
108
|
-
LoopedArray.prototype.has = function (item) {
|
|
109
|
-
return this._array.includes(item);
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* Is array empty
|
|
113
|
-
*/
|
|
114
|
-
LoopedArray.prototype.isEmpty = function () {
|
|
115
|
-
return this._array.length === 0;
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Is array full
|
|
119
|
-
*/
|
|
120
|
-
LoopedArray.prototype.isFull = function () {
|
|
121
|
-
return this._array.length >= this._capacity;
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* List length
|
|
125
|
-
*/
|
|
126
|
-
LoopedArray.prototype.length = function () {
|
|
127
|
-
return this._array.length;
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Remove all elements from array
|
|
131
|
-
*/
|
|
132
|
-
LoopedArray.prototype.clear = function () {
|
|
133
|
-
this._array = new Array(0);
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* Delete node from array by index from start
|
|
137
|
-
*/
|
|
138
|
-
LoopedArray.prototype.deleteFromIndex = function (fromIndex) {
|
|
139
|
-
var deletedElement = this._array[fromIndex];
|
|
140
|
-
delete this._array[fromIndex];
|
|
141
|
-
return deletedElement;
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* Add elements to array from array
|
|
145
|
-
* */
|
|
146
|
-
LoopedArray.prototype.pushFromArray = function (elements) {
|
|
147
|
-
var _this = this;
|
|
148
|
-
elements.forEach(function (element) {
|
|
149
|
-
_this.push(element);
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* Reverse array nodes links and swap head with tail
|
|
154
|
-
*/
|
|
155
|
-
LoopedArray.prototype.reverse = function () {
|
|
156
|
-
this._array = this._array.reverse();
|
|
157
|
-
};
|
|
158
|
-
return LoopedArray;
|
|
159
|
-
}());
|
|
160
|
-
exports.default = LoopedArray;
|
|
161
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTG9vcGVkQXJyYXkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZGF0YS1zdHJ1Y3R1cmVzL0xvb3BlZEFycmF5L0xvb3BlZEFycmF5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBRUE7Ozs7R0FJRztBQUNIO0lBS0U7O09BRUc7SUFDSCxxQkFBWSxRQUFnQjtRQU5wQixnQkFBVyxHQUFHLENBQUMsQ0FBQztRQU90QixJQUFJLFFBQVEsSUFBSSxDQUFDLEVBQUU7WUFDakIsTUFBTSxJQUFJLEtBQUssQ0FBQyxnQ0FBZ0MsQ0FBQyxDQUFDO1NBQ25EO1FBQ0QsSUFBSSxDQUFDLFNBQVMsR0FBRyxRQUFRLENBQUM7UUFDMUIsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLEtBQUssQ0FBSSxDQUFDLENBQUMsQ0FBQztJQUNoQyxDQUFDO0lBRUQ7O09BRUc7SUFDSSwwQkFBSSxHQUFYLFVBQVksS0FBUTtRQUNsQixJQUFJLElBQUksQ0FBQyxXQUFXLEdBQUcsSUFBSSxDQUFDLFNBQVMsS0FBSyxDQUFDLEVBQUU7WUFDM0MsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLEtBQUssQ0FBSSxDQUFDLENBQUMsQ0FBQztTQUMvQjtRQUVELElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBQztRQUVuQixJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sRUFBRSxFQUFFO1lBQ2xCLElBQUksQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDO1NBQ3pCO2FBQU07WUFDT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yxFQUFFLENBQUM7SUFDdEMsQ0FBQztJQUNILGtCQUFDO0FBQUQsQ0FBQyxBQTlLRCxJQThLQyJ9
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import ILinearStorage from "../../types/ILinearStorage";
|
|
2
|
-
/**
|
|
3
|
-
* FIFO data structure
|
|
4
|
-
*/
|
|
5
|
-
export default class Queue<T> implements ILinearStorage<T> {
|
|
6
|
-
private readonly _list;
|
|
7
|
-
/**
|
|
8
|
-
* Create a queue instance
|
|
9
|
-
*/
|
|
10
|
-
constructor(capacity?: number);
|
|
11
|
-
/**
|
|
12
|
-
* Get first element in queue (without deleting)
|
|
13
|
-
* @throws when list is empty
|
|
14
|
-
*/
|
|
15
|
-
peek(): T;
|
|
16
|
-
/**
|
|
17
|
-
* Add element to queue
|
|
18
|
-
* @throws when list is full
|
|
19
|
-
*/
|
|
20
|
-
push(item: T): void;
|
|
21
|
-
/**
|
|
22
|
-
* Delete first element in queue
|
|
23
|
-
* @throws when list is empty
|
|
24
|
-
*/
|
|
25
|
-
pop(): T;
|
|
26
|
-
/**
|
|
27
|
-
* Check if element exists in list
|
|
28
|
-
*/
|
|
29
|
-
has(item: T): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Is queue empty
|
|
32
|
-
*/
|
|
33
|
-
isEmpty(): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Is stack full
|
|
36
|
-
*/
|
|
37
|
-
isFull(): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Remove all elements in queue
|
|
40
|
-
*/
|
|
41
|
-
clear(): void;
|
|
42
|
-
/**
|
|
43
|
-
* Queue length
|
|
44
|
-
*/
|
|
45
|
-
length(): number;
|
|
46
|
-
/**
|
|
47
|
-
* Reverse queue
|
|
48
|
-
*/
|
|
49
|
-
reverse(): void;
|
|
50
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var DoubleLinkedList_1 = require("../LinkedList/DoubleLinkedList/DoubleLinkedList");
|
|
4
|
-
/**
|
|
5
|
-
* FIFO data structure
|
|
6
|
-
*/
|
|
7
|
-
var Queue = /** @class */ (function () {
|
|
8
|
-
/**
|
|
9
|
-
* Create a queue instance
|
|
10
|
-
*/
|
|
11
|
-
function Queue(capacity) {
|
|
12
|
-
this._list = new DoubleLinkedList_1.default(capacity);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Get first element in queue (without deleting)
|
|
16
|
-
* @throws when list is empty
|
|
17
|
-
*/
|
|
18
|
-
Queue.prototype.peek = function () {
|
|
19
|
-
if (this.isEmpty()) {
|
|
20
|
-
throw new Error("Cannot peek when list is empty");
|
|
21
|
-
}
|
|
22
|
-
return this._list.peek();
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Add element to queue
|
|
26
|
-
* @throws when list is full
|
|
27
|
-
*/
|
|
28
|
-
Queue.prototype.push = function (item) {
|
|
29
|
-
if (this._list.isFull()) {
|
|
30
|
-
throw new Error("Cannot push when queue is full");
|
|
31
|
-
}
|
|
32
|
-
this._list.unshift(item);
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Delete first element in queue
|
|
36
|
-
* @throws when list is empty
|
|
37
|
-
*/
|
|
38
|
-
Queue.prototype.pop = function () {
|
|
39
|
-
if (this.isEmpty()) {
|
|
40
|
-
throw new Error("Cannot pop when list is empty");
|
|
41
|
-
}
|
|
42
|
-
return this._list.pop();
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Check if element exists in list
|
|
46
|
-
*/
|
|
47
|
-
Queue.prototype.has = function (item) {
|
|
48
|
-
return this._list.has(item);
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Is queue empty
|
|
52
|
-
*/
|
|
53
|
-
Queue.prototype.isEmpty = function () {
|
|
54
|
-
return this._list.isEmpty();
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Is stack full
|
|
58
|
-
*/
|
|
59
|
-
Queue.prototype.isFull = function () {
|
|
60
|
-
return this._list.isFull();
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Remove all elements in queue
|
|
64
|
-
*/
|
|
65
|
-
Queue.prototype.clear = function () {
|
|
66
|
-
this._list.clear();
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Queue length
|
|
70
|
-
*/
|
|
71
|
-
Queue.prototype.length = function () {
|
|
72
|
-
return this._list.length();
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Reverse queue
|
|
76
|
-
*/
|
|
77
|
-
Queue.prototype.reverse = function () {
|
|
78
|
-
this._list.reverse();
|
|
79
|
-
};
|
|
80
|
-
return Queue;
|
|
81
|
-
}());
|
|
82
|
-
exports.default = Queue;
|
|
83
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUXVldWUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZGF0YS1zdHJ1Y3R1cmVzL1F1ZXVlL1F1ZXVlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsb0ZBQStFO0FBSS9FOztHQUVHO0FBQ0g7SUFHRTs7T0FFRztJQUNILGVBQW1CLFFBQWlCO1FBQ2xDLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSwwQkFBZ0IsQ0FBSSxRQUFRLENBQUMsQ0FBQztJQUNqRCxDQUFDO0lBRUQ7OztPQUdHO0lBQ0ksb0JBQUksR0FBWDtRQUNFLElBQUksSUFBSSxDQUFDLE9BQU8sRUFBRSxFQUFFO1lBQ2xCLE1BQU0sSUFBSSxLQUFLLENBQUMsZ0NBQWdDLENBQUMsQ0FBQztTQUNuRDtRQUNELE9BQU8sSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLEVBQUUsQ0FBQztJQUMzQixDQUFDO0lBRUQ7OztPQUdHO0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