@raikuxq/alg-ds 1.1.3 → 1.1.4
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/lib/algorithms/binary-search.d.ts +5 -0
- package/lib/algorithms/binary-search.js +27 -0
- package/lib/algorithms/factorial.d.ts +9 -0
- package/lib/algorithms/factorial.js +17 -0
- package/lib/algorithms/fibonacci.d.ts +9 -0
- package/lib/algorithms/fibonacci.js +17 -0
- package/lib/algorithms/memoize.d.ts +5 -0
- package/lib/algorithms/memoize.js +22 -0
- package/lib/algorithms/sorts/bubble-sort.d.ts +9 -0
- package/lib/algorithms/sorts/bubble-sort.js +23 -0
- package/lib/algorithms/sorts/insertion-sort.d.ts +9 -0
- package/lib/algorithms/sorts/insertion-sort.js +25 -0
- package/lib/algorithms/sorts/merge-sort.d.ts +9 -0
- package/lib/algorithms/sorts/merge-sort.js +61 -0
- package/lib/algorithms/sorts/quick-sort.d.ts +9 -0
- package/lib/algorithms/sorts/quick-sort.js +45 -0
- package/lib/algorithms/sorts/select-sort.d.ts +9 -0
- package/lib/algorithms/sorts/select-sort.js +20 -0
- package/lib/algorithms/transpose-matrix.d.ts +5 -0
- package/lib/algorithms/transpose-matrix.js +20 -0
- package/lib/constants.d.ts +2 -0
- package/lib/constants.js +6 -0
- package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.d.ts +15 -0
- package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.js +53 -0
- package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.d.ts +60 -0
- package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.js +36 -0
- package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.d.ts +13 -0
- package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.js +59 -0
- package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.d.ts +70 -0
- package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.js +268 -0
- package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.d.ts +16 -0
- package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.js +70 -0
- package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.d.ts +57 -0
- package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.js +234 -0
- package/lib/data-structures/Graph/AbstractGraph.d.ts +84 -0
- package/lib/data-structures/Graph/AbstractGraph.js +141 -0
- package/lib/data-structures/Graph/DirectedGraph.d.ts +24 -0
- package/lib/data-structures/Graph/DirectedGraph.js +85 -0
- package/lib/data-structures/Graph/GraphEdge.d.ts +16 -0
- package/lib/data-structures/Graph/GraphEdge.js +43 -0
- package/lib/data-structures/Graph/UndirectedGraph.d.ts +28 -0
- package/lib/data-structures/Graph/UndirectedGraph.js +102 -0
- package/lib/data-structures/Graph/demo/generateRandomGraph.d.ts +4 -0
- package/lib/data-structures/Graph/demo/generateRandomGraph.js +72 -0
- package/lib/data-structures/Graph/iterator/AbstractGraphIterator.d.ts +35 -0
- package/lib/data-structures/Graph/iterator/AbstractGraphIterator.js +90 -0
- package/lib/data-structures/Graph/iterator/GraphIteratorBFS.d.ts +28 -0
- package/lib/data-structures/Graph/iterator/GraphIteratorBFS.js +70 -0
- package/lib/data-structures/Graph/iterator/GraphIteratorDFS.d.ts +28 -0
- package/lib/data-structures/Graph/iterator/GraphIteratorDFS.js +70 -0
- package/lib/data-structures/Graph/iterator/GraphIteratorDijkstra.d.ts +32 -0
- package/lib/data-structures/Graph/iterator/GraphIteratorDijkstra.js +99 -0
- package/lib/data-structures/Graph/presenter/presenterAdjacencyLists.d.ts +19 -0
- package/lib/data-structures/Graph/presenter/presenterAdjacencyLists.js +28 -0
- package/lib/data-structures/Graph/presenter/presenterAdjacencyMatrix.d.ts +32 -0
- package/lib/data-structures/Graph/presenter/presenterAdjacencyMatrix.js +48 -0
- package/lib/data-structures/Graph/searching/hasPath.d.ts +9 -0
- package/lib/data-structures/Graph/searching/hasPath.js +29 -0
- package/lib/data-structures/Graph/searching/shortestPath.d.ts +9 -0
- package/lib/data-structures/Graph/searching/shortestPath.js +29 -0
- package/lib/data-structures/Graph/strategy/BFSIterationStrategy.d.ts +6 -0
- package/lib/data-structures/Graph/strategy/BFSIterationStrategy.js +13 -0
- package/lib/data-structures/Graph/strategy/DFSIterationStrategy.d.ts +6 -0
- package/lib/data-structures/Graph/strategy/DFSIterationStrategy.js +13 -0
- package/lib/data-structures/Graph/strategy/DijkstraIterationStrategy.d.ts +6 -0
- package/lib/data-structures/Graph/strategy/DijkstraIterationStrategy.js +13 -0
- package/lib/data-structures/Graph/transposing/transposeDirectedGraph.d.ts +2 -0
- package/lib/data-structures/Graph/transposing/transposeDirectedGraph.js +14 -0
- package/lib/data-structures/HashTable/HashTable.d.ts +73 -0
- package/lib/data-structures/HashTable/HashTable.js +169 -0
- package/lib/data-structures/HashTable/HashTableNode.d.ts +11 -0
- package/lib/data-structures/HashTable/HashTableNode.js +39 -0
- package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.d.ts +125 -0
- package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.js +236 -0
- package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedNode.d.ts +20 -0
- package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedNode.js +41 -0
- package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.d.ts +48 -0
- package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.js +150 -0
- package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedNode.d.ts +25 -0
- package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedNode.js +65 -0
- package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.d.ts +52 -0
- package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.js +137 -0
- package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedNode.d.ts +7 -0
- package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedNode.js +29 -0
- package/lib/data-structures/LoopedArray/LoopedArray.d.ts +86 -0
- package/lib/data-structures/LoopedArray/LoopedArray.js +161 -0
- package/lib/data-structures/Queue/Queue.d.ts +50 -0
- package/lib/data-structures/Queue/Queue.js +83 -0
- package/lib/data-structures/Stack/Stack.d.ts +50 -0
- package/lib/data-structures/Stack/Stack.js +83 -0
- package/lib/exports/algorithms.d.ts +16 -0
- package/lib/exports/algorithms.js +36 -0
- package/lib/exports/constants.d.ts +2 -0
- package/lib/exports/constants.js +7 -0
- package/lib/exports/data-structures.d.ts +11 -0
- package/lib/exports/data-structures.js +24 -0
- package/lib/exports/helpers.d.ts +6 -0
- package/lib/exports/helpers.js +14 -0
- package/lib/exports/sorts.d.ts +6 -0
- package/lib/exports/sorts.js +14 -0
- package/lib/exports/utils.d.ts +3 -0
- package/lib/exports/utils.js +14 -0
- package/lib/exports.d.ts +44 -0
- package/lib/exports.js +89 -0
- package/lib/helpers/createBinaryTree.d.ts +6 -0
- package/lib/helpers/createBinaryTree.js +22 -0
- package/lib/helpers/createGraph.d.ts +6 -0
- package/lib/helpers/createGraph.js +24 -0
- package/lib/helpers/createGraphFromMatrix.d.ts +7 -0
- package/lib/helpers/createGraphFromMatrix.js +37 -0
- package/lib/helpers/createLinkedList.d.ts +3 -0
- package/lib/helpers/createLinkedList.js +21 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +6 -0
- package/lib/types/ArrayMatrix.d.ts +1 -0
- package/lib/types/ArrayMatrix.js +3 -0
- package/lib/types/EnumBinarySearchTreeType.d.ts +4 -0
- package/lib/types/EnumBinarySearchTreeType.js +9 -0
- package/lib/types/EnumGraphType.d.ts +4 -0
- package/lib/types/EnumGraphType.js +9 -0
- package/lib/types/EnumLinkedListType.d.ts +4 -0
- package/lib/types/EnumLinkedListType.js +9 -0
- package/lib/types/EnumRandomGenerationFormat.d.ts +4 -0
- package/lib/types/EnumRandomGenerationFormat.js +9 -0
- package/lib/types/EnumTreeTraversalType.d.ts +5 -0
- package/lib/types/EnumTreeTraversalType.js +10 -0
- package/lib/types/FnCompareTwo.d.ts +1 -0
- package/lib/types/FnCompareTwo.js +3 -0
- package/lib/types/FnToMemoize.d.ts +1 -0
- package/lib/types/FnToMemoize.js +3 -0
- package/lib/types/IArrayFacade.d.ts +4 -0
- package/lib/types/IArrayFacade.js +3 -0
- package/lib/types/IBiDirectIterable.d.ts +5 -0
- package/lib/types/IBiDirectIterable.js +3 -0
- package/lib/types/IBiDirectIterator.d.ts +11 -0
- package/lib/types/IBiDirectIterator.js +3 -0
- package/lib/types/IBinaryTree.d.ts +12 -0
- package/lib/types/IBinaryTree.js +3 -0
- package/lib/types/IConvertableToArray.d.ts +4 -0
- package/lib/types/IConvertableToArray.js +3 -0
- package/lib/types/IGraph.d.ts +14 -0
- package/lib/types/IGraph.js +3 -0
- package/lib/types/IGraphIterationStrategy.d.ts +5 -0
- package/lib/types/IGraphIterationStrategy.js +3 -0
- package/lib/types/IGraphIterator.d.ts +11 -0
- package/lib/types/IGraphIterator.js +3 -0
- package/lib/types/IIterable.d.ts +4 -0
- package/lib/types/IIterable.js +3 -0
- package/lib/types/IIterator.d.ts +14 -0
- package/lib/types/IIterator.js +3 -0
- package/lib/types/IKeyValueStorage.d.ts +8 -0
- package/lib/types/IKeyValueStorage.js +3 -0
- package/lib/types/ILinearStorage.d.ts +11 -0
- package/lib/types/ILinearStorage.js +3 -0
- package/lib/types/ILinearStorageRA.d.ts +13 -0
- package/lib/types/ILinearStorageRA.js +3 -0
- package/lib/types/ILinkedList.d.ts +4 -0
- package/lib/types/ILinkedList.js +3 -0
- package/lib/utils.d.ts +29 -0
- package/lib/utils.js +95 -0
- package/package.json +1 -1
package/lib/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Write your code here
|
|
4
|
+
*/
|
|
5
|
+
console.log("Hello world");
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOztHQUVHO0FBRUgsT0FBTyxDQUFDLEdBQUcsQ0FBQyxhQUFhLENBQUMsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type ArrayMatrix = Array<Array<number>>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQXJyYXlNYXRyaXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvQXJyYXlNYXRyaXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnumBinarySearchTreeType = void 0;
|
|
4
|
+
var EnumBinarySearchTreeType;
|
|
5
|
+
(function (EnumBinarySearchTreeType) {
|
|
6
|
+
EnumBinarySearchTreeType["BST"] = "Binary Search Tree";
|
|
7
|
+
EnumBinarySearchTreeType["RANDOMIZED_BST"] = "Randomized Binary Search Tree";
|
|
8
|
+
})(EnumBinarySearchTreeType = exports.EnumBinarySearchTreeType || (exports.EnumBinarySearchTreeType = {}));
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRW51bUJpbmFyeVNlYXJjaFRyZWVUeXBlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL0VudW1CaW5hcnlTZWFyY2hUcmVlVHlwZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxJQUFZLHdCQUdYO0FBSEQsV0FBWSx3QkFBd0I7SUFDbEMsc0RBQTBCLENBQUE7SUFDMUIsNEVBQWdELENBQUE7QUFDbEQsQ0FBQyxFQUhXLHdCQUF3QixHQUF4QixnQ0FBd0IsS0FBeEIsZ0NBQXdCLFFBR25DIn0=
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnumGraphType = void 0;
|
|
4
|
+
var EnumGraphType;
|
|
5
|
+
(function (EnumGraphType) {
|
|
6
|
+
EnumGraphType["Directed"] = "Directed";
|
|
7
|
+
EnumGraphType["Undirected"] = "Undirected";
|
|
8
|
+
})(EnumGraphType = exports.EnumGraphType || (exports.EnumGraphType = {}));
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRW51bUdyYXBoVHlwZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eXBlcy9FbnVtR3JhcGhUeXBlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLElBQVksYUFHWDtBQUhELFdBQVksYUFBYTtJQUN2QixzQ0FBcUIsQ0FBQTtJQUNyQiwwQ0FBeUIsQ0FBQTtBQUMzQixDQUFDLEVBSFcsYUFBYSxHQUFiLHFCQUFhLEtBQWIscUJBQWEsUUFHeEIifQ==
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnumLinkedListType = void 0;
|
|
4
|
+
var EnumLinkedListType;
|
|
5
|
+
(function (EnumLinkedListType) {
|
|
6
|
+
EnumLinkedListType["DOUBLE"] = "Double linked list";
|
|
7
|
+
EnumLinkedListType["SINGLE"] = "Single linked list";
|
|
8
|
+
})(EnumLinkedListType = exports.EnumLinkedListType || (exports.EnumLinkedListType = {}));
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRW51bUxpbmtlZExpc3RUeXBlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL0VudW1MaW5rZWRMaXN0VHlwZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxJQUFZLGtCQUdYO0FBSEQsV0FBWSxrQkFBa0I7SUFDNUIsbURBQTZCLENBQUE7SUFDN0IsbURBQTZCLENBQUE7QUFDL0IsQ0FBQyxFQUhXLGtCQUFrQixHQUFsQiwwQkFBa0IsS0FBbEIsMEJBQWtCLFFBRzdCIn0=
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnumRandomGenerationFormat = void 0;
|
|
4
|
+
var EnumRandomGenerationFormat;
|
|
5
|
+
(function (EnumRandomGenerationFormat) {
|
|
6
|
+
EnumRandomGenerationFormat["Numbers"] = "NUMBERS";
|
|
7
|
+
EnumRandomGenerationFormat["Hash"] = "HASH";
|
|
8
|
+
})(EnumRandomGenerationFormat = exports.EnumRandomGenerationFormat || (exports.EnumRandomGenerationFormat = {}));
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRW51bVJhbmRvbUdlbmVyYXRpb25Gb3JtYXQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvRW51bVJhbmRvbUdlbmVyYXRpb25Gb3JtYXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsSUFBWSwwQkFHWDtBQUhELFdBQVksMEJBQTBCO0lBQ3BDLGlEQUFtQixDQUFBO0lBQ25CLDJDQUFhLENBQUE7QUFDZixDQUFDLEVBSFcsMEJBQTBCLEdBQTFCLGtDQUEwQixLQUExQixrQ0FBMEIsUUFHckMifQ==
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnumTreeTraversalType = void 0;
|
|
4
|
+
var EnumTreeTraversalType;
|
|
5
|
+
(function (EnumTreeTraversalType) {
|
|
6
|
+
EnumTreeTraversalType["InOrder"] = "InOrder";
|
|
7
|
+
EnumTreeTraversalType["PreOrder"] = "PreOrder";
|
|
8
|
+
EnumTreeTraversalType["PostOrder"] = "PostOrder";
|
|
9
|
+
})(EnumTreeTraversalType = exports.EnumTreeTraversalType || (exports.EnumTreeTraversalType = {}));
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRW51bVRyZWVUcmF2ZXJzYWxUeXBlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL0VudW1UcmVlVHJhdmVyc2FsVHlwZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxJQUFZLHFCQUlYO0FBSkQsV0FBWSxxQkFBcUI7SUFDL0IsNENBQW1CLENBQUE7SUFDbkIsOENBQXFCLENBQUE7SUFDckIsZ0RBQXVCLENBQUE7QUFDekIsQ0FBQyxFQUpXLHFCQUFxQixHQUFyQiw2QkFBcUIsS0FBckIsNkJBQXFCLFFBSWhDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type FnCompareTwo<T> = (firstItem: T, secondItem: T) => boolean;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRm5Db21wYXJlVHdvLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL0ZuQ29tcGFyZVR3by50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type FnToMemoize<Key, Value> = (...args: Array<Key>) => Value;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRm5Ub01lbW9pemUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvRm5Ub01lbW9pemUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUFycmF5RmFjYWRlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL0lBcnJheUZhY2FkZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUJpRGlyZWN0SXRlcmFibGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvSUJpRGlyZWN0SXRlcmFibGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import IIterator from "./IIterator";
|
|
2
|
+
export default interface IBiDirectIterator<T> extends IIterator<T> {
|
|
3
|
+
/**
|
|
4
|
+
* Will do one iteration back and returns prev item value
|
|
5
|
+
*/
|
|
6
|
+
prev(): T;
|
|
7
|
+
/**
|
|
8
|
+
* Check if next element exists
|
|
9
|
+
*/
|
|
10
|
+
hasPrev(): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUJpRGlyZWN0SXRlcmF0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvSUJpRGlyZWN0SXRlcmF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EnumTreeTraversalType } from "./EnumTreeTraversalType";
|
|
2
|
+
export default interface IBinaryTree<T> {
|
|
3
|
+
has(value: T): boolean;
|
|
4
|
+
insert(value: T): void;
|
|
5
|
+
delete(value: T): void;
|
|
6
|
+
subtree(value: T): IBinaryTree<T>;
|
|
7
|
+
max(): T;
|
|
8
|
+
min(): T;
|
|
9
|
+
length(): number;
|
|
10
|
+
height(): number;
|
|
11
|
+
traverse(type: EnumTreeTraversalType): Array<T>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUJpbmFyeVRyZWUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvSUJpbmFyeVRyZWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUNvbnZlcnRhYmxlVG9BcnJheS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eXBlcy9JQ29udmVydGFibGVUb0FycmF5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default interface IGraph<T> {
|
|
2
|
+
weight(): number;
|
|
3
|
+
vertices(): Array<T>;
|
|
4
|
+
verticesCount(): number;
|
|
5
|
+
edgesCount(): number;
|
|
6
|
+
addVertex(data: T): this;
|
|
7
|
+
removeVertex(data: T): this;
|
|
8
|
+
hasVertex(data: T): boolean;
|
|
9
|
+
getVertexNeighbors(data: T): Array<T>;
|
|
10
|
+
addEdge(from: T, to: T, weight?: number): this;
|
|
11
|
+
removeEdge(from: T, to: T): this;
|
|
12
|
+
hasEdge(from: T, to: T): boolean;
|
|
13
|
+
getEdgeWeight(from: T, to: T): number;
|
|
14
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUdyYXBoLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL0lHcmFwaC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUdyYXBoSXRlcmF0aW9uU3RyYXRlZ3kuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvSUdyYXBoSXRlcmF0aW9uU3RyYXRlZ3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import IIterator from "./IIterator";
|
|
2
|
+
export default interface IGraphIterator<T> extends IIterator<T> {
|
|
3
|
+
/**
|
|
4
|
+
* Get path which passed by iterator between two vertices
|
|
5
|
+
*/
|
|
6
|
+
getPath(from: T, to: T): Array<T>;
|
|
7
|
+
/**
|
|
8
|
+
* Initialize iterator by passing start vertex
|
|
9
|
+
*/
|
|
10
|
+
initIterator(from: T): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUdyYXBoSXRlcmF0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvSUdyYXBoSXRlcmF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUl0ZXJhYmxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL0lJdGVyYWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUl0ZXJhdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL0lJdGVyYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUtleVZhbHVlU3RvcmFnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eXBlcy9JS2V5VmFsdWVTdG9yYWdlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUxpbmVhclN0b3JhZ2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvSUxpbmVhclN0b3JhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import ILinearStorage from "./ILinearStorage";
|
|
2
|
+
/**
|
|
3
|
+
* Interface extends default linear storage with methods that allows read/write operations for all storage elements
|
|
4
|
+
* RA - randomly accessible
|
|
5
|
+
*/
|
|
6
|
+
export default interface ILinearStorageRA<T> extends ILinearStorage<T> {
|
|
7
|
+
peekFromStart(): T;
|
|
8
|
+
peekByIndex(index: number): T;
|
|
9
|
+
unshift(value: T): void;
|
|
10
|
+
pushFromIndex(value: T, fromIndex: number): void;
|
|
11
|
+
shift(): T;
|
|
12
|
+
deleteFromIndex(fromIndex: number): T;
|
|
13
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUxpbmVhclN0b3JhZ2VSQS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eXBlcy9JTGluZWFyU3RvcmFnZVJBLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUxpbmtlZExpc3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvSUxpbmtlZExpc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Will find min value in the whole array and return its index
|
|
3
|
+
*/
|
|
4
|
+
export declare const getMinIndex: (arr: Array<number>) => number;
|
|
5
|
+
/**
|
|
6
|
+
* Will find min value in range between fromIndex and end of array
|
|
7
|
+
*/
|
|
8
|
+
export declare const getMinIndexFromIndex: (arr: Array<number>, fromIndex: number) => number;
|
|
9
|
+
/**
|
|
10
|
+
* Will swap two items in array
|
|
11
|
+
* @example swapArrayItems([2,3,5], 1, 2) -> [2,5,3]
|
|
12
|
+
*/
|
|
13
|
+
export declare const swapArrayItems: <T>(arr: T[], leftIndex: number, rightIndex: number) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Get random number in range
|
|
16
|
+
*/
|
|
17
|
+
export declare const randomizeNumberInRange: (min: number, max: number) => number;
|
|
18
|
+
/**
|
|
19
|
+
* Round number to 3 digits after
|
|
20
|
+
*/
|
|
21
|
+
export declare const roundNumber: (num: number) => number;
|
|
22
|
+
/**
|
|
23
|
+
* Get time execution of function
|
|
24
|
+
*/
|
|
25
|
+
export declare const perf: (fn: () => void) => number;
|
|
26
|
+
/**
|
|
27
|
+
* Get time execution of function
|
|
28
|
+
*/
|
|
29
|
+
export declare const perfAsync: (fn: () => void) => Promise<number>;
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.perfAsync = exports.perf = exports.roundNumber = exports.randomizeNumberInRange = exports.swapArrayItems = exports.getMinIndexFromIndex = exports.getMinIndex = void 0;
|
|
40
|
+
var perf_hooks_1 = require("perf_hooks");
|
|
41
|
+
/**
|
|
42
|
+
* Will find min value in the whole array and return its index
|
|
43
|
+
*/
|
|
44
|
+
exports.getMinIndex = function (arr) {
|
|
45
|
+
return arr.reduce(function (minIndex, item, index) {
|
|
46
|
+
return item < arr[minIndex] ? index : minIndex;
|
|
47
|
+
}, 0);
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Will find min value in range between fromIndex and end of array
|
|
51
|
+
*/
|
|
52
|
+
exports.getMinIndexFromIndex = function (arr, fromIndex) {
|
|
53
|
+
return fromIndex + exports.getMinIndex(arr.slice(fromIndex));
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Will swap two items in array
|
|
57
|
+
* @example swapArrayItems([2,3,5], 1, 2) -> [2,5,3]
|
|
58
|
+
*/
|
|
59
|
+
exports.swapArrayItems = function (arr, leftIndex, rightIndex) {
|
|
60
|
+
if (leftIndex !== rightIndex) {
|
|
61
|
+
var temp = arr[leftIndex];
|
|
62
|
+
arr[leftIndex] = arr[rightIndex];
|
|
63
|
+
arr[rightIndex] = temp;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Get random number in range
|
|
68
|
+
*/
|
|
69
|
+
exports.randomizeNumberInRange = function (min, max) {
|
|
70
|
+
return Math.floor(Math.random() * (max - min)) + min;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Round number to 3 digits after
|
|
74
|
+
*/
|
|
75
|
+
exports.roundNumber = function (num) {
|
|
76
|
+
return Math.round(num * 1000) / 1000;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Get time execution of function
|
|
80
|
+
*/
|
|
81
|
+
exports.perf = function (fn) {
|
|
82
|
+
var perfStart = perf_hooks_1.performance.now();
|
|
83
|
+
fn();
|
|
84
|
+
var perfEnd = perf_hooks_1.performance.now();
|
|
85
|
+
return perfEnd - perfStart;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Get time execution of function
|
|
89
|
+
*/
|
|
90
|
+
exports.perfAsync = function (fn) { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
return [2 /*return*/, Promise.resolve(exports.perf(fn))];
|
|
93
|
+
});
|
|
94
|
+
}); };
|
|
95
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEseUNBQXlDO0FBRXpDOztHQUVHO0FBQ1UsUUFBQSxXQUFXLEdBQUcsVUFBQyxHQUFrQjtJQUM1QyxPQUFPLEdBQUcsQ0FBQyxNQUFNLENBQUMsVUFBQyxRQUFRLEVBQUUsSUFBSSxFQUFFLEtBQUs7UUFDdEMsT0FBTyxJQUFJLEdBQUcsR0FBRyxDQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLFFBQVEsQ0FBQztJQUNqRCxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUM7QUFDUixDQUFDLENBQUM7QUFFRjs7R0FFRztBQUNVLFFBQUEsb0JBQW9CLEdBQUcsVUFDbEMsR0FBa0IsRUFDbEIsU0FBaUI7SUFFakIsT0FBTyxTQUFTLEdBQUcsbUJBQVcsQ0FBQyxHQUFHLENBQUMsS0FBSyxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUM7QUFDdkQsQ0FBQyxDQUFDO0FBRUY7OztHQUdHO0FBQ1UsUUFBQSxjQUFjLEdBQUcsVUFDNUIsR0FBYSxFQUNiLFNBQWlCLEVBQ2pCLFVBQWtCO0lBRWxCLElBQUksU0FBUyxLQUFLLFVBQVUsRUFBRTtRQUM1QixJQUFNLElBQUksR0FBTSxHQUFHLENBQUMsU0FBUyxDQUFDLENBQUM7UUFDL0IsR0FBRyxDQUFDLFNBQVMsQ0FBQyxHQUFHLEdBQUcsQ0FBQyxVQUFVLENBQUMsQ0FBQztRQUNqQyxHQUFHLENBQUMsVUFBVSxDQUFDLEdBQUcsSUFBSSxDQUFDO0tBQ3hCO0FBQ0gsQ0FBQyxDQUFDO0FBRUY7O0dBRUc7QUFDVSxRQUFBLHNCQUFzQixHQUFHLFVBQUMsR0FBVyxFQUFFLEdBQVc7SUFDN0QsT0FBQSxJQUFJLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxNQUFNLEVBQUUsR0FBRyxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUMsQ0FBQyxHQUFHLEdBQUc7QUFBN0MsQ0FBNkMsQ0FBQztBQUVoRDs7R0FFRztBQUNVLFFBQUEsV0FBVyxHQUFHLFVBQUMsR0FBVztJQUNyQyxPQUFBLElBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxHQUFHLElBQUksQ0FBQyxHQUFHLElBQUk7QUFBN0IsQ0FBNkIsQ0FBQztBQUVoQzs7R0FFRztBQUNVLFFBQUEsSUFBSSxHQUFHLFVBQUMsRUFBYztJQUNqQyxJQUFNLFNBQVMsR0FBRyx3QkFBVyxDQUFDLEdBQUcsRUFBRSxDQUFDO0lBQ3BDLEVBQUUsRUFBRSxDQUFDO0lBQ0wsSUFBTSxPQUFPLEdBQUcsd0JBQVcsQ0FBQyxHQUFHLEVBQUUsQ0FBQztJQUNsQyxPQUFPLE9BQU8sR0FBRyxTQUFTLENBQUM7QUFDN0IsQ0FBQyxDQUFDO0FBRUY7O0dBRUc7QUFDVSxRQUFBLFNBQVMsR0FBRyxVQUFPLEVBQWM7O1FBQzVDLHNCQUFPLE9BQU8sQ0FBQyxPQUFPLENBQUMsWUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLEVBQUM7O0tBQ2xDLENBQUMifQ==
|
package/package.json
CHANGED