@raikuxq/alg-ds 1.1.7 → 1.2.2
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 +71 -88
- package/lib/{algorithms → app/algorithms}/binary-search.d.ts +0 -0
- package/lib/app/algorithms/binary-search.js +27 -0
- package/lib/{algorithms → app/algorithms}/factorial.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/factorial.js +1 -1
- package/lib/{algorithms → app/algorithms}/fibonacci.d.ts +0 -0
- package/lib/app/algorithms/fibonacci.js +17 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/AbstractGraphIterator.d.ts +4 -0
- package/lib/app/algorithms/graph/iterator/AbstractGraphIterator.js +87 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorBFS.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorBFS.js +2 -2
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDFS.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDFS.js +2 -2
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDijkstra.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDijkstra.js +3 -5
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/BFSIterationStrategy.d.ts +0 -0
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/BFSIterationStrategy.js +1 -1
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/DFSIterationStrategy.d.ts +0 -0
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/DFSIterationStrategy.js +1 -1
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/DijkstraIterationStrategy.d.ts +0 -0
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/DijkstraIterationStrategy.js +1 -1
- package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyLists.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyLists.js +1 -1
- package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyMatrix.d.ts +2 -2
- package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyMatrix.js +1 -1
- package/lib/{data-structures/Graph → app/algorithms/graph}/searching/hasPath.d.ts +3 -3
- package/lib/app/algorithms/graph/searching/hasPath.js +30 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/searching/shortestPath.d.ts +3 -3
- package/lib/app/algorithms/graph/searching/shortestPath.js +30 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/transposing/transposeDirectedGraph.d.ts +0 -0
- package/lib/app/algorithms/graph/transposing/transposeDirectedGraph.js +14 -0
- package/lib/{algorithms → app/algorithms}/memoize.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/memoize.js +1 -1
- package/lib/{algorithms → app/algorithms}/sorts/bubble-sort.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/sorts/bubble-sort.js +1 -1
- package/lib/{algorithms → app/algorithms}/sorts/insertion-sort.d.ts +0 -0
- package/lib/app/algorithms/sorts/insertion-sort.js +25 -0
- package/lib/{algorithms → app/algorithms}/sorts/merge-sort.d.ts +0 -0
- package/lib/app/algorithms/sorts/merge-sort.js +61 -0
- package/lib/{algorithms → app/algorithms}/sorts/quick-sort.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/sorts/quick-sort.js +1 -1
- package/lib/{algorithms → app/algorithms}/sorts/select-sort.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/sorts/select-sort.js +1 -1
- package/lib/app/algorithms/transpose-matrix.d.ts +6 -0
- package/lib/{algorithms → app/algorithms}/transpose-matrix.js +2 -1
- package/lib/{constants.d.ts → app/constants.d.ts} +0 -0
- package/lib/{constants.js → app/constants.js} +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.d.ts +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.js +1 -2
- package/lib/{data-structures → app/data-structures}/BinaryTree/BinarySearchTree/BinarySearchNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/BinarySearchTree/BinarySearchNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/BinarySearchTree/BinarySearchTree.d.ts +6 -1
- package/lib/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.js +276 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.d.ts +1 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.js +2 -1
- package/lib/app/data-structures/BinaryTree/_helpers/createBinaryTree.d.ts +6 -0
- package/lib/app/data-structures/BinaryTree/_helpers/createBinaryTree.js +22 -0
- package/lib/{data-structures → app/data-structures}/Graph/AbstractGraph.d.ts +3 -3
- package/lib/{data-structures → app/data-structures}/Graph/AbstractGraph.js +4 -4
- package/lib/{data-structures → app/data-structures}/Graph/DirectedGraph.d.ts +3 -0
- package/lib/{data-structures → app/data-structures}/Graph/DirectedGraph.js +4 -1
- package/lib/{data-structures → app/data-structures}/Graph/GraphEdge.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/Graph/GraphEdge.js +1 -1
- package/lib/{data-structures → app/data-structures}/Graph/UndirectedGraph.d.ts +3 -0
- package/lib/{data-structures → app/data-structures}/Graph/UndirectedGraph.js +4 -1
- package/lib/app/data-structures/Graph/_helpers/createGraph.d.ts +6 -0
- package/lib/app/data-structures/Graph/_helpers/createGraph.js +22 -0
- package/lib/app/data-structures/Graph/_helpers/createGraphFromMatrix.d.ts +7 -0
- package/lib/app/data-structures/Graph/_helpers/createGraphFromMatrix.js +42 -0
- package/lib/{data-structures/Graph/demo → app/data-structures/Graph/_helpers}/generateRandomGraph.d.ts +0 -0
- package/lib/app/data-structures/Graph/_helpers/generateRandomGraph.js +67 -0
- package/lib/{data-structures → app/data-structures}/HashTable/HashTable.d.ts +4 -4
- package/lib/app/data-structures/HashTable/HashTable.js +171 -0
- package/lib/{data-structures → app/data-structures}/HashTable/HashTableNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/HashTable/HashTableNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/LinkedList/AbstractLinkedList/AbstractLinkedList.d.ts +17 -8
- package/lib/app/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.js +247 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/AbstractLinkedList/AbstractLinkedNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/AbstractLinkedList/AbstractLinkedNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/LinkedList/DoubleLinkedList/DoubleLinkedList.d.ts +2 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/DoubleLinkedList/DoubleLinkedList.js +5 -3
- package/lib/{data-structures → app/data-structures}/LinkedList/DoubleLinkedList/DoubleLinkedNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/DoubleLinkedList/DoubleLinkedNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/LinkedList/SingleLinkedList/SingleLinkedList.d.ts +2 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/SingleLinkedList/SingleLinkedList.js +4 -2
- package/lib/{data-structures → app/data-structures}/LinkedList/SingleLinkedList/SingleLinkedNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/SingleLinkedList/SingleLinkedNode.js +1 -1
- package/lib/app/data-structures/LinkedList/_helpers/createLinkedList.d.ts +3 -0
- package/lib/app/data-structures/LinkedList/_helpers/createLinkedList.js +19 -0
- package/lib/{data-structures → app/data-structures}/LoopedArray/LoopedArray.d.ts +3 -0
- package/lib/app/data-structures/LoopedArray/LoopedArray.js +165 -0
- package/lib/{data-structures → app/data-structures}/Queue/Queue.d.ts +3 -3
- package/lib/app/data-structures/Queue/Queue.js +85 -0
- package/lib/{data-structures → app/data-structures}/Stack/Stack.d.ts +3 -3
- package/lib/app/data-structures/Stack/Stack.js +85 -0
- package/lib/{exceptions/IsEmptyException.d.ts → app/exceptions/CollectionIsEmptyException.d.ts} +1 -1
- package/lib/{exceptions/IsFullException.js → app/exceptions/CollectionIsEmptyException.js} +7 -7
- package/lib/{exceptions/IsFullException.d.ts → app/exceptions/CollectionIsFullException.d.ts} +1 -1
- package/lib/{exceptions/IsEmptyException.js → app/exceptions/CollectionIsFullException.js} +7 -7
- package/lib/{exceptions → app/exceptions}/IndexOutOfBoundsException.d.ts +0 -0
- package/lib/{exceptions → app/exceptions}/IndexOutOfBoundsException.js +1 -1
- package/lib/{exceptions → app/exceptions}/IsAlreadyExistsException.d.ts +0 -0
- package/lib/{exceptions → app/exceptions}/IsAlreadyExistsException.js +1 -1
- package/lib/{exceptions → app/exceptions}/IsNotFoundException.d.ts +0 -0
- package/lib/{exceptions → app/exceptions}/IsNotFoundException.js +1 -1
- package/lib/{exceptions/IllegalCapacityException.d.ts → app/exceptions/ValueOutOfRangeException.d.ts} +1 -1
- package/lib/{exceptions/IllegalCapacityException.js → app/exceptions/ValueOutOfRangeException.js} +7 -7
- package/lib/{exceptions → app/exceptions}/base/IllegalArgumentException.d.ts +0 -0
- package/lib/{exceptions → app/exceptions}/base/IllegalArgumentException.js +1 -1
- package/lib/{exceptions → app/exceptions}/base/IllegalStateException.d.ts +0 -0
- package/lib/{exceptions → app/exceptions}/base/IllegalStateException.js +1 -1
- package/lib/{types → app/types}/EnumBinarySearchTreeType.d.ts +0 -0
- package/lib/{types → app/types}/EnumBinarySearchTreeType.js +1 -1
- package/lib/app/types/EnumGraphTraversalType.d.ts +5 -0
- package/lib/app/types/EnumGraphTraversalType.js +10 -0
- package/lib/app/types/EnumGraphType.d.ts +4 -0
- package/lib/{types → app/types}/EnumGraphType.js +3 -3
- package/lib/{types → app/types}/EnumLinkedListType.d.ts +0 -0
- package/lib/{types → app/types}/EnumLinkedListType.js +1 -1
- package/lib/{types → app/types}/EnumRandomGenerationFormat.d.ts +2 -2
- package/lib/{types → app/types}/EnumRandomGenerationFormat.js +3 -3
- package/lib/app/types/EnumSortType.d.ts +7 -0
- package/lib/app/types/EnumSortType.js +12 -0
- package/lib/app/types/EnumTreeTraversalType.d.ts +5 -0
- package/lib/app/types/EnumTreeTraversalType.js +10 -0
- package/lib/{types → app/types}/FnCompareTwo.d.ts +0 -0
- package/lib/{types → app/types}/FnCompareTwo.js +1 -1
- package/lib/{types → app/types}/FnToMemoize.d.ts +0 -0
- package/lib/{types → app/types}/FnToMemoize.js +1 -1
- package/lib/{types → app/types}/IArrayFacade.d.ts +0 -0
- package/lib/{types → app/types}/IArrayFacade.js +1 -1
- package/lib/{types → app/types}/IBiDirectIterable.d.ts +0 -0
- package/lib/{types → app/types}/IBiDirectIterable.js +1 -1
- package/lib/{types → app/types}/IBiDirectIterator.d.ts +0 -0
- package/lib/{types → app/types}/IBiDirectIterator.js +1 -1
- package/lib/{types → app/types}/IBinaryTree.d.ts +0 -0
- package/lib/{types → app/types}/IBinaryTree.js +1 -1
- package/lib/{types → app/types}/IConvertableToArray.d.ts +0 -0
- package/lib/{types → app/types}/IConvertableToArray.js +1 -1
- package/lib/{types → app/types}/IGraph.d.ts +0 -0
- package/lib/{types → app/types}/IGraph.js +1 -1
- package/lib/{types → app/types}/IGraphIterationStrategy.d.ts +0 -0
- package/lib/{types → app/types}/IGraphIterationStrategy.js +1 -1
- package/lib/{types → app/types}/IGraphIterator.d.ts +0 -0
- package/lib/{types → app/types}/IGraphIterator.js +1 -1
- package/lib/{types → app/types}/IIterable.d.ts +0 -0
- package/lib/{types → app/types}/IIterable.js +1 -1
- package/lib/{types → app/types}/IIterator.d.ts +0 -0
- package/lib/{types → app/types}/IIterator.js +1 -1
- package/lib/{types → app/types}/IKeyValueStorage.d.ts +0 -0
- package/lib/{types → app/types}/IKeyValueStorage.js +1 -1
- package/lib/{types → app/types}/ILinearStorage.d.ts +0 -0
- package/lib/{types → app/types}/ILinearStorage.js +1 -1
- package/lib/{types → app/types}/ILinearStorageRA.d.ts +0 -0
- package/lib/{types → app/types}/ILinearStorageRA.js +1 -1
- package/lib/{types → app/types}/ILinkedList.d.ts +0 -0
- package/lib/{types → app/types}/ILinkedList.js +1 -1
- package/lib/app/types/TypeArrayMatrix.d.ts +1 -0
- package/lib/app/types/TypeArrayMatrix.js +3 -0
- package/lib/{utils.d.ts → app/utils.d.ts} +6 -2
- package/lib/{utils.js → app/utils.js} +12 -5
- package/lib/exports/algorithms.d.ts +15 -15
- package/lib/exports/algorithms.js +16 -16
- package/lib/exports/constants.d.ts +1 -1
- package/lib/exports/constants.js +2 -2
- package/lib/exports/data-structures.d.ts +10 -10
- package/lib/exports/data-structures.js +11 -11
- package/lib/exports/helpers.d.ts +5 -5
- package/lib/exports/helpers.js +6 -6
- package/lib/exports/sorts.d.ts +5 -5
- package/lib/exports/sorts.js +6 -6
- package/lib/exports/types.d.ts +16 -0
- package/lib/exports/types.js +34 -0
- package/lib/exports/utils.d.ts +2 -2
- package/lib/exports/utils.js +3 -3
- package/lib/exports.d.ts +47 -46
- package/lib/exports.js +51 -49
- package/lib/index.js +1 -2
- package/package.json +11 -6
- package/lib/algorithms/binary-search.js +0 -27
- package/lib/algorithms/fibonacci.js +0 -17
- package/lib/algorithms/sorts/insertion-sort.js +0 -25
- package/lib/algorithms/sorts/merge-sort.js +0 -61
- package/lib/algorithms/transpose-matrix.d.ts +0 -5
- package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.js +0 -271
- package/lib/data-structures/Graph/demo/generateRandomGraph.js +0 -66
- package/lib/data-structures/Graph/iterator/AbstractGraphIterator.js +0 -90
- package/lib/data-structures/Graph/searching/hasPath.js +0 -30
- package/lib/data-structures/Graph/searching/shortestPath.js +0 -30
- package/lib/data-structures/Graph/transposing/transposeDirectedGraph.js +0 -14
- package/lib/data-structures/HashTable/HashTable.js +0 -171
- package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.js +0 -241
- package/lib/data-structures/LoopedArray/LoopedArray.js +0 -169
- package/lib/data-structures/Queue/Queue.js +0 -85
- package/lib/data-structures/Stack/Stack.js +0 -85
- 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 -42
- package/lib/helpers/createLinkedList.d.ts +0 -3
- package/lib/helpers/createLinkedList.js +0 -21
- package/lib/types/ArrayMatrix.d.ts +0 -1
- package/lib/types/ArrayMatrix.js +0 -3
- package/lib/types/EnumGraphType.d.ts +0 -4
- package/lib/types/EnumTreeTraversalType.d.ts +0 -5
- package/lib/types/EnumTreeTraversalType.js +0 -10
package/README.md
CHANGED
|
@@ -2,50 +2,31 @@ Common algorithms and data structures.
|
|
|
2
2
|
|
|
3
3
|
Written in TypeScript, tested with Jest.
|
|
4
4
|
|
|
5
|
+
# Documentation
|
|
6
|
+
Documentation app: [raikuxq-algorithms.netlify.app/guide](https://raikuxq-algorithms.netlify.app/guide)
|
|
7
|
+
|
|
5
8
|
|
|
6
9
|
# Usage as package
|
|
7
10
|
Install by using any of these commands:
|
|
8
11
|
+ `yarn add @raikuxq/alg-ds`
|
|
9
12
|
+ `npm install @raikuxq/alg-ds --save`
|
|
10
13
|
|
|
11
|
-
## Import from root
|
|
12
|
-
`import { <anything> } from '@raikuxq/alg-ds'`
|
|
13
|
-
|
|
14
|
-
## Import from sub-paths
|
|
15
|
-
### Data structures
|
|
16
|
-
`import {Stack, Queue, SingleLinkedList, DoubleLinkedList, RandBinarySearchTree, BinarySearchTree, DirectedGraph, UndirectedGraph, LoopedArray, HashTable, } from '@raikuxq/alg-ds/lib/exports/data-structures'`
|
|
17
|
-
### Sorting algorithms
|
|
18
|
-
`import {bubbleSort, insertionSort, mergeSort, selectSort, quickSort} from '@raikuxq/alg-ds/lib/exports/data-structures `
|
|
19
|
-
### Other algorithms
|
|
20
|
-
`import {binarySearch, factorial, memoizedFactorial, memoizedFibonacci, fibonacci, transposeMatrix, GraphIteratorDFS, presenterAdjacencyLists, presenterAdjacencyMatrix, hasPath, shortestPath, DijkstraIterationStrategy, DFSIterationStrategy, BFSIterationStrategy, GraphIteratorBFS, GraphIteratorDijkstra, transposeDirectedGraph} from '@raikuxq/alg-ds/lib/exports/algorithms'`
|
|
21
|
-
### Helpers
|
|
22
|
-
`import {createGraph, createGraphFromMatrix, createBinaryTree, createLinkedList, generateRandomGraph} from '@raikuxq/alg-ds/lib/exports/helpers`
|
|
23
|
-
### Utils
|
|
24
|
-
`import {perf, getMinIndex, getMinIndexFromIndex, memoize, perfAsync, roundNumber, randomizeNumberInRange, swapArrayItems} from '@raikuxq/alg-ds/lib/exports/utils'`
|
|
25
|
-
### Constants
|
|
26
|
-
`import {EDGE_NOT_EXISTS_STATE, EDGE_EXISTS_STATE} from '@raikuxq/alg-ds/lib/exports/constants'`
|
|
27
|
-
|
|
28
|
-
|
|
29
14
|
|
|
30
15
|
# Usage as repository
|
|
31
16
|
|
|
32
17
|
Clone this repository and install dependencies by using `yarn` command.
|
|
33
|
-
|
|
34
|
-
+ `yarn test` - run all tests via jest
|
|
35
|
-
|
|
18
|
+
+ `yarn test` - run all tests via jest
|
|
36
19
|
+ `yarn dev` - run in dev mode via nodemon (src/index.ts is an entrypoint)
|
|
37
|
-
|
|
38
20
|
+ `yarn build` - compile ts sources into js files
|
|
39
|
-
|
|
40
21
|
+ `yarn start` - build and run in production mode
|
|
41
|
-
|
|
42
22
|
+ `yarn lint` - lint check via eslint
|
|
43
|
-
|
|
44
23
|
+ `yarn lint:fix` - fix source files via eslint
|
|
45
24
|
|
|
46
25
|
|
|
47
26
|
# Navigation
|
|
48
27
|
+ [Algorithms](#algorithms)
|
|
28
|
+
+ [Utils](#utils)
|
|
29
|
+
+ [Math](#math)
|
|
49
30
|
+ [Sorting algorithms](#sorting-algorithms)
|
|
50
31
|
+ [Linear data structures](#linear-data-structures)
|
|
51
32
|
+ [Linked list](#linked-list)
|
|
@@ -53,35 +34,37 @@ Clone this repository and install dependencies by using `yarn` command.
|
|
|
53
34
|
+ [Stack](#stack)
|
|
54
35
|
+ [Queue](#queue)
|
|
55
36
|
+ [Non-linear data structures](#non-linear-data-structures)
|
|
56
|
-
+ [
|
|
37
|
+
+ [HASH table](#hash-table)
|
|
57
38
|
+ [Graph](#graph)
|
|
58
39
|
+ [Binary tree](#binary-trees)
|
|
59
40
|
|
|
60
41
|
|
|
61
42
|
# Algorithms
|
|
62
43
|
|
|
63
|
-
##
|
|
64
|
-
[memoize](src/algorithms/memoize.ts) — Memoization util function.
|
|
44
|
+
## Utils
|
|
45
|
+
[memoize](src/app/algorithms/memoize.ts) — Memoization util function.
|
|
65
46
|
|
|
66
|
-
|
|
47
|
+
## Searching
|
|
48
|
+
[binary-search](src/app/algorithms/binary-search.ts) [[ tests ](test/unit/algorithms/binary-search.test.ts)] — Binary searching algorithm. Time: O(log(n)).
|
|
67
49
|
|
|
68
|
-
|
|
50
|
+
## Math
|
|
51
|
+
[factorial](src/app/algorithms/factorial.ts) [[ tests ](test/unit/algorithms/factorial.test.ts)] — Recursive O(n!) and memoized O(n) factorial implementation.
|
|
69
52
|
|
|
70
|
-
[fibonacci](src/algorithms/fibonacci.ts) [[ tests ](test/unit/algorithms/fibonacci.test.ts)] — Recursive O(n!) and memoized O(n) factorial implementation.
|
|
53
|
+
[fibonacci](src/app/algorithms/fibonacci.ts) [[ tests ](test/unit/algorithms/fibonacci.test.ts)] — Recursive O(n!) and memoized O(n) factorial implementation.
|
|
71
54
|
|
|
72
|
-
[transpose-matrix](src/algorithms/transpose-matrix.ts) [[ tests ](test/unit/algorithms/transpose-matrix.test.ts)] — Transpose N*N matrix util function.
|
|
55
|
+
[transpose-matrix](src/app/algorithms/transpose-matrix.ts) [[ tests ](test/unit/algorithms/transpose-matrix.test.ts)] — Transpose N*N matrix util function.
|
|
73
56
|
|
|
74
57
|
|
|
75
58
|
## Sorting algorithms
|
|
76
|
-
[bubble-sort](src/algorithms/sorts/bubble-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n) best. Memory: O(1) worst.
|
|
59
|
+
[bubble-sort](src/app/algorithms/sorts/bubble-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n) best. Memory: O(1) worst.
|
|
77
60
|
|
|
78
|
-
[selection-sort](src/algorithms/sorts/select-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n^2) best. Memory: O(1) worst.
|
|
61
|
+
[selection-sort](src/app/algorithms/sorts/select-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n^2) best. Memory: O(1) worst.
|
|
79
62
|
|
|
80
|
-
[insertion-sort](src/algorithms/sorts/insertion-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n) best. Memory: O(1) worst.
|
|
63
|
+
[insertion-sort](src/app/algorithms/sorts/insertion-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n) best. Memory: O(1) worst.
|
|
81
64
|
|
|
82
|
-
[merge-sort](src/algorithms/sorts/merge-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n*log(n)) worst, O(n*log(n)) avg, O(n*log(n)) best. Memory: O(n) worst.
|
|
65
|
+
[merge-sort](src/app/algorithms/sorts/merge-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n*log(n)) worst, O(n*log(n)) avg, O(n*log(n)) best. Memory: O(n) worst.
|
|
83
66
|
|
|
84
|
-
[quick-sort](src/algorithms/sorts/quick-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n*log(n)) avg, O(n*log(n)) best. Memory: O(1) worst.
|
|
67
|
+
[quick-sort](src/app/algorithms/sorts/quick-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n*log(n)) avg, O(n*log(n)) best. Memory: O(1) worst.
|
|
85
68
|
|
|
86
69
|
|
|
87
70
|
|
|
@@ -90,154 +73,154 @@ Clone this repository and install dependencies by using `yarn` command.
|
|
|
90
73
|
# Linear data structures
|
|
91
74
|
|
|
92
75
|
### Interfaces
|
|
93
|
-
[ILinearStorage](src/types/ILinearStorage.ts) — Contains common methods of linear data structures.
|
|
76
|
+
[ILinearStorage](src/app/types/ILinearStorage.ts) — Contains common methods of linear data structures.
|
|
94
77
|
|
|
95
|
-
[ILinearStorageRA](src/types/ILinearStorageRA.ts) — Allows random access (from end, from start, by index).
|
|
96
|
-
Extends [ILinearStorage](src/types/ILinearStorage.ts) interface.
|
|
78
|
+
[ILinearStorageRA](src/app/types/ILinearStorageRA.ts) — Allows random access (from end, from start, by index).
|
|
79
|
+
Extends [ILinearStorage](src/app/types/ILinearStorage.ts) interface.
|
|
97
80
|
|
|
98
|
-
[IConvertableToArray](src/types/IConvertableToArray.ts) — Contain methods for converting from/into array.
|
|
81
|
+
[IConvertableToArray](src/app/types/IConvertableToArray.ts) — Contain methods for converting from/into array.
|
|
99
82
|
|
|
100
83
|
|
|
101
84
|
## Linked List
|
|
102
85
|
|
|
103
86
|
### Interfaces
|
|
104
|
-
[ILinkedList](src/types/ILinkedList.ts) — Contains basic linked lists operations.
|
|
105
|
-
Extends [ILinearStorageRA](src/types/ILinearStorageRA.ts) and [IConvertableToArray](src/types/IConvertableToArray.ts) interface.
|
|
87
|
+
[ILinkedList](src/app/types/ILinkedList.ts) — Contains basic linked lists operations.
|
|
88
|
+
Extends [ILinearStorageRA](src/app/types/ILinearStorageRA.ts) and [IConvertableToArray](src/app/types/IConvertableToArray.ts) interface.
|
|
106
89
|
|
|
107
90
|
### Implementation
|
|
108
|
-
[AbstractLinkedList](src/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.ts) — Common logic for both single and double linked lists.
|
|
109
|
-
Implements [ILinearStorageRA](src/types/ILinearStorageRA.ts) interface.
|
|
91
|
+
[AbstractLinkedList](src/app/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.ts) — Common logic for both single and double linked lists.
|
|
92
|
+
Implements [ILinearStorageRA](src/app/types/ILinearStorageRA.ts) interface.
|
|
110
93
|
|
|
111
|
-
[SingleLinkedList](src/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.ts)
|
|
94
|
+
[SingleLinkedList](src/app/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.ts)
|
|
112
95
|
[ [ tests ] ](test/unit/data-structures/linked-list/linked-list.test.ts)
|
|
113
96
|
— Extends abstract linked list with implementation of one-way linking.
|
|
114
|
-
Implements [IIterable](src/types/IIterable.ts) interface.
|
|
97
|
+
Implements [IIterable](src/app/types/IIterable.ts) interface.
|
|
115
98
|
|
|
116
|
-
[DoubleLinkedList](src/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.ts)
|
|
99
|
+
[DoubleLinkedList](src/app/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.ts)
|
|
117
100
|
[ [ tests ] ](test/unit/data-structures/linked-list/linked-list.test.ts)
|
|
118
101
|
— Extends abstract linked list with implementation of two-way linking.
|
|
119
|
-
Implements [IBiDirectIterable](src/types/IBiDirectIterable.ts) interface.
|
|
102
|
+
Implements [IBiDirectIterable](src/app/types/IBiDirectIterable.ts) interface.
|
|
120
103
|
|
|
121
104
|
|
|
122
105
|
## Looped Array
|
|
123
106
|
|
|
124
107
|
### Interfaces
|
|
125
|
-
[IArrayFacade](src/types/IArrayFacade.ts) — Contains basic array operations.
|
|
126
|
-
Extends [ILinearStorageRA](src/types/ILinearStorageRA.ts) interface.
|
|
127
|
-
Extends [IConvertableToArray](src/types/IConvertableToArray.ts) interface.
|
|
108
|
+
[IArrayFacade](src/app/types/IArrayFacade.ts) — Contains basic array operations.
|
|
109
|
+
Extends [ILinearStorageRA](src/app/types/ILinearStorageRA.ts) interface.
|
|
110
|
+
Extends [IConvertableToArray](src/app/types/IConvertableToArray.ts) interface.
|
|
128
111
|
|
|
129
112
|
### Implementation
|
|
130
|
-
[LoopedArray](src/data-structures/LoopedArray/LoopedArray.ts)[ [ tests ]](test/unit/data-structures/looped-array/looped-array.test.ts)
|
|
113
|
+
[LoopedArray](src/app/data-structures/LoopedArray/LoopedArray.ts)[ [ tests ]](test/unit/data-structures/looped-array/looped-array.test.ts)
|
|
131
114
|
— Overwrites data on capacity overflow.
|
|
132
115
|
|
|
133
116
|
## Stack
|
|
134
117
|
|
|
135
118
|
### Implementation
|
|
136
|
-
[Stack](src/data-structures/Stack/Stack.ts) [[ tests ](test/unit/data-structures/stack/stack.test.ts)]
|
|
137
|
-
— LIFO data structure. Implements [ILinearStorage](src/types/ILinearStorage.ts) interface.
|
|
119
|
+
[Stack](src/app/data-structures/Stack/Stack.ts) [[ tests ](test/unit/data-structures/stack/stack.test.ts)]
|
|
120
|
+
— LIFO data structure. Implements [ILinearStorage](src/app/types/ILinearStorage.ts) interface.
|
|
138
121
|
|
|
139
122
|
## Queue
|
|
140
123
|
|
|
141
124
|
### Implementation
|
|
142
|
-
[Queue](src/data-structures/Queue/Queue.ts) [[ tests ](test/unit/data-structures/queue/queue.test.ts)]
|
|
143
|
-
— FIFO data structure. Implements [ILinearStorage](src/types/ILinearStorage.ts) interface.
|
|
125
|
+
[Queue](src/app/data-structures/Queue/Queue.ts) [[ tests ](test/unit/data-structures/queue/queue.test.ts)]
|
|
126
|
+
— FIFO data structure. Implements [ILinearStorage](src/app/types/ILinearStorage.ts) interface.
|
|
144
127
|
|
|
145
128
|
|
|
146
129
|
|
|
147
130
|
# Non linear data structures
|
|
148
131
|
|
|
149
|
-
##
|
|
132
|
+
## HASH Table
|
|
150
133
|
### Interfaces
|
|
151
|
-
[IKeyValueStorage](src/types/IKeyValueStorage.ts) — Contains basic key-value storages operations.
|
|
134
|
+
[IKeyValueStorage](src/app/types/IKeyValueStorage.ts) — Contains basic key-value storages operations.
|
|
152
135
|
|
|
153
136
|
### Implementation
|
|
154
|
-
[HashTableNode](src/data-structures/HashTable/HashTableNode.ts) — Contains key, data and isDeleted properties.
|
|
137
|
+
[HashTableNode](src/app/data-structures/HashTable/HashTableNode.ts) — Contains key, data and isDeleted properties.
|
|
155
138
|
|
|
156
|
-
[HashTable](src/data-structures/HashTable/HashTable.ts) [ [ tests ] ](test/unit/data-structures/hash-table/hash-table.test.ts) — Implementation of open addressing hash table using quadratic probing
|
|
139
|
+
[HashTable](src/app/data-structures/HashTable/HashTable.ts) [ [ tests ] ](test/unit/data-structures/hash-table/hash-table.test.ts) — Implementation of open addressing hash table using quadratic probing
|
|
157
140
|
|
|
158
141
|
|
|
159
142
|
|
|
160
143
|
## Graph
|
|
161
144
|
### Interfaces
|
|
162
|
-
[IGraph](src/types/IGraph.ts) — Contains basic graph operations.
|
|
145
|
+
[IGraph](src/app/types/IGraph.ts) — Contains basic graph operations.
|
|
163
146
|
|
|
164
|
-
[IGraphIterator](src/types/IGraphIterator.ts) — Extends default iterator with init and getPath methods.
|
|
147
|
+
[IGraphIterator](src/app/types/IGraphIterator.ts) — Extends default iterator with init and getPath methods.
|
|
165
148
|
|
|
166
|
-
[IGraphIterationStrategy](src/types/IGraphIterationStrategy.ts) — Iteration strategies which are used in shortest-path, has-path.
|
|
149
|
+
[IGraphIterationStrategy](src/app/types/IGraphIterationStrategy.ts) — Iteration strategies which are used in shortest-path, has-path.
|
|
167
150
|
|
|
168
151
|
### Implementation
|
|
169
|
-
[GraphEdge](src/data-structures/Graph/GraphEdge.ts) — Contains from/to links and edge weight.
|
|
152
|
+
[GraphEdge](src/app/data-structures/Graph/GraphEdge.ts) — Contains from/to links and edge weight.
|
|
170
153
|
|
|
171
|
-
[AbstractGraph](src/data-structures/Graph/AbstractGraph.ts) — Common logic for both directed and undirected graphs.
|
|
154
|
+
[AbstractGraph](src/app/data-structures/Graph/AbstractGraph.ts) — Common logic for both directed and undirected graphs.
|
|
172
155
|
|
|
173
156
|
|
|
174
|
-
[DirectedGraph](src/data-structures/Graph/DirectedGraph.ts) [ [ tests ] ](test/unit/data-structures/graph/graph.test.ts)
|
|
157
|
+
[DirectedGraph](src/app/data-structures/Graph/DirectedGraph.ts) [ [ tests ] ](test/unit/data-structures/graph/graph.test.ts)
|
|
175
158
|
— In case of directed graph A->B and B->A edges are not the same.
|
|
176
159
|
|
|
177
|
-
[UndirectedGraph](src/data-structures/Graph/UndirectedGraph.ts) [ [ tests ] ](test/unit/data-structures/graph/graph.test.ts)
|
|
160
|
+
[UndirectedGraph](src/app/data-structures/Graph/UndirectedGraph.ts) [ [ tests ] ](test/unit/data-structures/graph/graph.test.ts)
|
|
178
161
|
— In case of undirected graph A->B and B->A are equal.
|
|
179
162
|
|
|
180
163
|
|
|
181
164
|
### Graph Iterators
|
|
182
165
|
|
|
183
|
-
[BreadthFirstSearchIterator](src/
|
|
166
|
+
[BreadthFirstSearchIterator](src/app/algorithms/graph/iterator/GraphIteratorBFS.ts)
|
|
184
167
|
— Traversal method for unweighted graphs, built on queue.
|
|
185
168
|
|
|
186
|
-
[DepthFirstSearchIterator](src/
|
|
169
|
+
[DepthFirstSearchIterator](src/app/algorithms/graph/iterator/GraphIteratorDFS.ts)
|
|
187
170
|
— Traversal method for unweighted graphs, built on stack.
|
|
188
171
|
|
|
189
|
-
[DijkstraMethodIterator](src/
|
|
172
|
+
[DijkstraMethodIterator](src/app/algorithms/graph/iterator/GraphIteratorDijkstra.ts)
|
|
190
173
|
— Traversal method for weighted graphs, built on finding the minimal cost.
|
|
191
174
|
|
|
192
175
|
|
|
193
176
|
### Graph Presenter
|
|
194
|
-
[presenter-adjacency-lists](src/
|
|
177
|
+
[presenter-adjacency-lists](src/app/algorithms/graph/presenter/presenterAdjacencyLists.ts) [[ tests ](test/unit/data-structures/graph/graph.presenter.lists.test.ts)]
|
|
195
178
|
— Representation of graph as an adjacency list (using Map).
|
|
196
179
|
|
|
197
|
-
[presenter-adjacency-matrix](src/
|
|
180
|
+
[presenter-adjacency-matrix](src/app/algorithms/graph/presenter/presenterAdjacencyMatrix.ts) [[ tests ](test/unit/data-structures/graph/graph.presenter.matrix.test.ts)]
|
|
198
181
|
— Representation of graph as an adjacency matrix (using Array N*N).
|
|
199
182
|
|
|
200
183
|
|
|
201
184
|
### Graph Searching
|
|
202
|
-
[has-path (BFS/DFS)](src/
|
|
185
|
+
[has-path (BFS/DFS)](src/app/algorithms/graph/searching/hasPath.ts) [[ tests ](test/unit/data-structures/graph/graph.has-path.test.ts)]
|
|
203
186
|
— Search for the existence of a path between two vertices.
|
|
204
187
|
|
|
205
|
-
[shortest-path (BFS/Dijkstra)](src/
|
|
188
|
+
[shortest-path (BFS/Dijkstra)](src/app/algorithms/graph/searching/shortestPath.ts) [[ tests ](test/unit/data-structures/graph/graph.shortest-path.test.ts)]
|
|
206
189
|
— Search for one of several shortest paths between two vertices.
|
|
207
190
|
|
|
208
191
|
### Graph Creators
|
|
209
|
-
[create-graph-from-matrix](src/
|
|
192
|
+
[create-graph-from-matrix](src/app/data-structures/Graph/_helpers/createGraphFromMatrix.ts) [[ tests ](test/unit/data-structures/graph/graph.create-from-matrix.test.ts)]
|
|
210
193
|
— Convert a matrix N*N into a graph instance.
|
|
211
194
|
|
|
212
195
|
|
|
213
196
|
### Graph Transposing
|
|
214
|
-
[transpose-directed-graph](src/
|
|
197
|
+
[transpose-directed-graph](src/app/algorithms/graph/transposing/transposeDirectedGraph.ts) [ [ tests ](test/unit/data-structures/graph/graph.transpose.test.ts)]
|
|
215
198
|
— Transpose a directed graph (undirected graphs are symmetrical already).
|
|
216
199
|
|
|
217
200
|
|
|
218
201
|
|
|
219
202
|
## Binary trees
|
|
220
|
-
[IBinaryTree](src/types/IBinaryTree.ts) — Contains basic binary tree operations.
|
|
203
|
+
[IBinaryTree](src/app/types/IBinaryTree.ts) — Contains basic binary tree operations.
|
|
221
204
|
|
|
222
205
|
### Implementation
|
|
223
206
|
|
|
224
|
-
[AbstractBinaryNode](src/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.ts) — Contains left/right/parent links and node data.
|
|
207
|
+
[AbstractBinaryNode](src/app/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.ts) — Contains left/right/parent links and node data.
|
|
225
208
|
|
|
226
|
-
[AbstractBinaryTree](src/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts) — Common logic for all types of binary trees.
|
|
209
|
+
[AbstractBinaryTree](src/app/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts) — Common logic for all types of binary trees.
|
|
227
210
|
|
|
228
211
|
|
|
229
|
-
[BinarySearchNode](src/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts) — Same as abstract binary node.
|
|
212
|
+
[BinarySearchNode](src/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts) — Same as abstract binary node.
|
|
230
213
|
|
|
231
|
-
[BinarySearchTree](src/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts) — Implementation of unbalanced binary search tree.
|
|
214
|
+
[BinarySearchTree](src/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts) — Implementation of unbalanced binary search tree.
|
|
232
215
|
Each node in left subtree is smaller and each node in right subtree is larger than the node data.
|
|
233
|
-
Extends [AbstractSearchTree](src/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts).
|
|
216
|
+
Extends [AbstractSearchTree](src/app/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts).
|
|
234
217
|
|
|
235
218
|
|
|
236
219
|
|
|
237
|
-
[RandBinarySearchNode](src/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.ts) — Have a rank attribute.
|
|
238
|
-
Extends [BinarySearchNode](src/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts).
|
|
220
|
+
[RandBinarySearchNode](src/app/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.ts) — Have a rank attribute.
|
|
221
|
+
Extends [BinarySearchNode](src/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts).
|
|
239
222
|
|
|
240
|
-
[RandBinarySearchTree](src/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.ts)
|
|
223
|
+
[RandBinarySearchTree](src/app/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.ts)
|
|
241
224
|
— Implementation of randomized binary search tree, which gives expected log(N) height.
|
|
242
|
-
|
|
243
|
-
Extends [BinarySearchTree](src/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts).
|
|
225
|
+
INSERTION have a 1/N+1 probability of inserting into root.
|
|
226
|
+
Extends [BinarySearchTree](src/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts).
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.binarySearch = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Find element's index in sorted array
|
|
6
|
+
* Time complexity: O(log(n))
|
|
7
|
+
*/
|
|
8
|
+
exports.binarySearch = function (elements, searchElement) {
|
|
9
|
+
var length = elements.length;
|
|
10
|
+
var leftIndex = 0;
|
|
11
|
+
var rightIndex = length - 1;
|
|
12
|
+
while (leftIndex <= rightIndex) {
|
|
13
|
+
var midIndex = Math.ceil((leftIndex + rightIndex) / 2);
|
|
14
|
+
var midEl = elements[midIndex];
|
|
15
|
+
if (searchElement == midEl) {
|
|
16
|
+
return midIndex;
|
|
17
|
+
}
|
|
18
|
+
else if (midEl > searchElement) {
|
|
19
|
+
rightIndex = midIndex - 1;
|
|
20
|
+
}
|
|
21
|
+
else if (midEl < searchElement) {
|
|
22
|
+
leftIndex = midIndex + 1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmluYXJ5LXNlYXJjaC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcHAvYWxnb3JpdGhtcy9iaW5hcnktc2VhcmNoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBOzs7R0FHRztBQUNVLFFBQUEsWUFBWSxHQUFHLFVBQzFCLFFBQXVCLEVBQ3ZCLGFBQXFCO0lBRXJCLElBQU0sTUFBTSxHQUFXLFFBQVEsQ0FBQyxNQUFNLENBQUM7SUFFdkMsSUFBSSxTQUFTLEdBQUcsQ0FBQyxDQUFDO0lBQ2xCLElBQUksVUFBVSxHQUFXLE1BQU0sR0FBRyxDQUFDLENBQUM7SUFFcEMsT0FBTyxTQUFTLElBQUksVUFBVSxFQUFFO1FBQzlCLElBQU0sUUFBUSxHQUFXLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxTQUFTLEdBQUcsVUFBVSxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUM7UUFDakUsSUFBTSxLQUFLLEdBQVcsUUFBUSxDQUFDLFFBQVEsQ0FBQyxDQUFDO1FBRXpDLElBQUksYUFBYSxJQUFJLEtBQUssRUFBRTtZQUMxQixPQUFPLFFBQVEsQ0FBQztTQUNqQjthQUFNLElBQUksS0FBSyxHQUFHLGFBQWEsRUFBRTtZQUNoQyxVQUFVLEdBQUcsUUFBUSxHQUFHLENBQUMsQ0FBQztTQUMzQjthQUFNLElBQUksS0FBSyxHQUFHLGFBQWEsRUFBRTtZQUNoQyxTQUFTLEdBQUcsUUFBUSxHQUFHLENBQUMsQ0FBQztTQUMxQjtLQUNGO0lBRUQsT0FBTyxJQUFJLENBQUM7QUFDZCxDQUFDLENBQUMifQ==
|
|
File without changes
|
|
@@ -14,4 +14,4 @@ exports.factorial = function (x) {
|
|
|
14
14
|
exports.memoizedFactorial = memoize_1.memoize(function (n) {
|
|
15
15
|
return n > 1 ? n * exports.memoizedFactorial(n - 1) : n;
|
|
16
16
|
});
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yaWFsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwcC9hbGdvcml0aG1zL2ZhY3RvcmlhbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxxQ0FBb0M7QUFHcEM7O0dBRUc7QUFDVSxRQUFBLFNBQVMsR0FBRyxVQUFDLENBQVM7SUFDakMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsaUJBQVMsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztBQUMxQyxDQUFDLENBQUM7QUFFRjs7R0FFRztBQUNVLFFBQUEsaUJBQWlCLEdBQWdDLGlCQUFPLENBQ25FLFVBQUMsQ0FBUztJQUNSLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLHlCQUFpQixDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQ2xELENBQUMsQ0FDRixDQUFDIn0=
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.memoizedFibonacci = exports.fibonacci = void 0;
|
|
4
|
+
var memoize_1 = require("./memoize");
|
|
5
|
+
/**
|
|
6
|
+
* Time complexity: O(n!)
|
|
7
|
+
*/
|
|
8
|
+
exports.fibonacci = function (n) {
|
|
9
|
+
return n > 1 ? exports.fibonacci(n - 1) + exports.fibonacci(n - 2) : n;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Time complexity: O(n) - due to caching
|
|
13
|
+
*/
|
|
14
|
+
exports.memoizedFibonacci = memoize_1.memoize(function (n) {
|
|
15
|
+
return n > 1 ? exports.memoizedFibonacci(n - 1) + exports.memoizedFibonacci(n - 2) : n;
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlib25hY2NpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwcC9hbGdvcml0aG1zL2ZpYm9uYWNjaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFDQSxxQ0FBb0M7QUFFcEM7O0dBRUc7QUFDVSxRQUFBLFNBQVMsR0FBRyxVQUFDLENBQVM7SUFDakMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxpQkFBUyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsR0FBRyxpQkFBUyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQ3pELENBQUMsQ0FBQztBQUVGOztHQUVHO0FBQ1UsUUFBQSxpQkFBaUIsR0FBZ0MsaUJBQU8sQ0FDbkUsVUFBQyxDQUFTO0lBQ1IsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyx5QkFBaUIsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLEdBQUcseUJBQWlCLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7QUFDekUsQ0FBQyxDQUNGLENBQUMifQ==
|
package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/AbstractGraphIterator.d.ts
RENAMED
|
@@ -14,6 +14,7 @@ export default abstract class AbstractGraphIterator<T> implements IGraphIterator
|
|
|
14
14
|
protected abstract hasNextImpl(): boolean;
|
|
15
15
|
/**
|
|
16
16
|
* @inheritDoc
|
|
17
|
+
* @throws {IsNotFoundException} when start vertex was not found
|
|
17
18
|
*/
|
|
18
19
|
initIterator(from: T): void;
|
|
19
20
|
/**
|
|
@@ -22,14 +23,17 @@ export default abstract class AbstractGraphIterator<T> implements IGraphIterator
|
|
|
22
23
|
hasNext(): boolean;
|
|
23
24
|
/**
|
|
24
25
|
* @inheritDoc
|
|
26
|
+
* @throws {IllegalStateException} when next element does not exist
|
|
25
27
|
*/
|
|
26
28
|
next(): T;
|
|
27
29
|
/**
|
|
28
30
|
* @inheritDoc
|
|
31
|
+
* @throws {IllegalStateException} when current element does not exist
|
|
29
32
|
*/
|
|
30
33
|
current(): T;
|
|
31
34
|
/**
|
|
32
35
|
* @inheritDoc
|
|
36
|
+
* @throws {IllegalStateException} when there is no path between given vertices
|
|
33
37
|
*/
|
|
34
38
|
getPath(from: T, to: T): Array<T>;
|
|
35
39
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
3
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
4
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
5
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
6
|
+
r[k] = a[j];
|
|
7
|
+
return r;
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
var IsNotFoundException_1 = require("../../../exceptions/IsNotFoundException");
|
|
11
|
+
var IllegalStateException_1 = require("../../../exceptions/base/IllegalStateException");
|
|
12
|
+
var AbstractGraphIterator = /** @class */ (function () {
|
|
13
|
+
/**
|
|
14
|
+
* Creates empty instance
|
|
15
|
+
*/
|
|
16
|
+
function AbstractGraphIterator(graph) {
|
|
17
|
+
this.graph = graph;
|
|
18
|
+
this.visited = new Map();
|
|
19
|
+
this.parents = new Map();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
* @throws {IsNotFoundException} when start vertex was not found
|
|
24
|
+
*/
|
|
25
|
+
AbstractGraphIterator.prototype.initIterator = function (from) {
|
|
26
|
+
if (!this.graph.hasVertex(from)) {
|
|
27
|
+
throw new IsNotFoundException_1.default("Start vertex does not exist");
|
|
28
|
+
}
|
|
29
|
+
this.initIteratorImpl(from);
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
AbstractGraphIterator.prototype.hasNext = function () {
|
|
35
|
+
return this.hasNextImpl();
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* @inheritDoc
|
|
39
|
+
* @throws {IllegalStateException} when next element does not exist
|
|
40
|
+
*/
|
|
41
|
+
AbstractGraphIterator.prototype.next = function () {
|
|
42
|
+
if (!this.hasNext()) {
|
|
43
|
+
throw new IllegalStateException_1.default("Next element does not exist");
|
|
44
|
+
}
|
|
45
|
+
return this.nextImpl();
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* @inheritDoc
|
|
49
|
+
* @throws {IllegalStateException} when current element does not exist
|
|
50
|
+
*/
|
|
51
|
+
AbstractGraphIterator.prototype.current = function () {
|
|
52
|
+
try {
|
|
53
|
+
return this.currentImpl();
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
throw new IllegalStateException_1.default("Current element does not exist");
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* @inheritDoc
|
|
61
|
+
* @throws {IllegalStateException} when there is no path between given vertices
|
|
62
|
+
*/
|
|
63
|
+
AbstractGraphIterator.prototype.getPath = function (from, to) {
|
|
64
|
+
var path = new Array();
|
|
65
|
+
var isLinkedDirectly = this.graph.hasEdge(from, to);
|
|
66
|
+
var currentVertex = this.parents.get(to);
|
|
67
|
+
if (isLinkedDirectly) {
|
|
68
|
+
return [from, to];
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
while (currentVertex) {
|
|
72
|
+
if (currentVertex === from) {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
path.push(currentVertex);
|
|
76
|
+
currentVertex = this.parents.get(currentVertex);
|
|
77
|
+
}
|
|
78
|
+
if (path.length === 0) {
|
|
79
|
+
throw new IllegalStateException_1.default("There is no path found");
|
|
80
|
+
}
|
|
81
|
+
return __spreadArrays([from], path.reverse(), [to]);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
return AbstractGraphIterator;
|
|
85
|
+
}());
|
|
86
|
+
exports.default = AbstractGraphIterator;
|
|
87
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWJzdHJhY3RHcmFwaEl0ZXJhdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vc3JjL2FwcC9hbGdvcml0aG1zL2dyYXBoL2l0ZXJhdG9yL0Fic3RyYWN0R3JhcGhJdGVyYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFFQSwrRUF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QUNILENBQUM7SUFFRDs7O09BR0c7SUFDSSx1Q0FBTyxHQUFkLFVBQWUsSUFBTyxFQUFFLEVBQUs7UUFDM0IsSUFBTSxJQUFJLEdBQWEsSUFBSSxLQUFLLEVBQUssQ0FBQztRQUN0QyxJQUFNLGdCQUFnQixHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsT0FBTyxDQUFDLElBQUksRUFBRSxFQUFFLENBQUMsQ0FBQztRQUN0RCxJQUFJLGFBQWEsR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsQ0FBQztRQUV6QyxJQUFJLGdCQUFnQixFQUFFO1lBQ3BCLE9BQU8sQ0FBQyxJQUFJLEVBQUUsRUFBRSxDQUFDLENBQUM7U0FDbkI7YUFBTTtZQUNMLE9BQU8sYUFBYSxFQUFFO2dCQUNwQixJQUFJLGFBQWEsS0FBSyxJQUFJLEVBQUU7b0JBQzFCLE1BQU07aUJBQ1A7Z0JBRUQsSUFBSSxDQUFDLElBQUksQ0FBQyxhQUFhLENBQUMsQ0FBQztnQkFDekIsYUFBYSxHQUFHLElBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLGFBQWEsQ0FBQyxDQUFDO2FBQ2pEO1lBRUQsSUFBSSxJQUFJLENBQUMsTUFBTSxLQUFLLENBQUMsRUFBRTtnQkFDckIsTUFBTSxJQUFJLCtCQUFxQixDQUFDLHdCQUF3QixDQUFDLENBQUM7YUFDM0Q7WUFFRCx1QkFBUSxJQUFJLEdBQUssSUFBSSxDQUFDLE9BQU8sRUFBRSxHQUFFLEVBQUUsR0FBRTtTQUN0QztJQUNILENBQUM7SUFDSCw0QkFBQztBQUFELENBQUMsQUExRkQsSUEwRkMifQ==
|
|
File without changes
|
|
@@ -13,7 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
};
|
|
14
14
|
})();
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
var Queue_1 = require("
|
|
16
|
+
var Queue_1 = require("../../../data-structures/Queue/Queue");
|
|
17
17
|
var AbstractGraphIterator_1 = require("./AbstractGraphIterator");
|
|
18
18
|
/**
|
|
19
19
|
* Breadth first graph traversal
|
|
@@ -67,4 +67,4 @@ var GraphIteratorBFS = /** @class */ (function (_super) {
|
|
|
67
67
|
return GraphIteratorBFS;
|
|
68
68
|
}(AbstractGraphIterator_1.default));
|
|
69
69
|
exports.default = GraphIteratorBFS;
|
|
70
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
70
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiR3JhcGhJdGVyYXRvckJGUy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9hcHAvYWxnb3JpdGhtcy9ncmFwaC9pdGVyYXRvci9HcmFwaEl0ZXJhdG9yQkZTLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDhEQUF5RDtBQUV6RCxpRUFBNEQ7QUFFNUQ7O0dBRUc7QUFDSDtJQUFpRCxvQ0FBd0I7SUFHdkU7O09BRUc7SUFDSCwwQkFBbUIsS0FBZ0I7UUFBbkMsWUFDRSxrQkFBTSxLQUFLLENBQUMsU0FFYjtRQURDLEtBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxlQUFLLEVBQUUsQ0FBQzs7SUFDM0IsQ0FBQztJQUVEOztPQUVHO0lBQ08sc0NBQVcsR0FBckI7UUFDRSxPQUFPLElBQUksQ0FBQyxLQUFLLENBQUMsSUFBSSxFQUFFLENBQUM7SUFDM0IsQ0FBQztJQUVEOztPQUVHO0lBQ0ksMkNBQWdCLEdBQXZCLFVBQXdCLFdBQWM7UUFDcEMsSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUM7UUFDN0IsSUFBSSxD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object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
var Stack_1 = require("
|
|
16
|
+
var Stack_1 = require("../../../data-structures/Stack/Stack");
|
|
17
17
|
var AbstractGraphIterator_1 = require("./AbstractGraphIterator");
|
|
18
18
|
/**
|
|
19
19
|
* Deep first graph traversal
|
|
@@ -67,4 +67,4 @@ var GraphIteratorDFS = /** @class */ (function (_super) {
|
|
|
67
67
|
return GraphIteratorDFS;
|
|
68
68
|
}(AbstractGraphIterator_1.default));
|
|
69
69
|
exports.default = GraphIteratorDFS;
|
|
70
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
70
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiR3JhcGhJdGVyYXRvckRGUy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9hcHAvYWxnb3JpdGhtcy9ncmFwaC9pdGVyYXRvci9HcmFwaEl0ZXJhdG9yREZTLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDhEQUF5RDtBQUV6RCxpRUFBNEQ7QUFFNUQ7O0dBRUc7QUFDSDtJQUFpRCxvQ0FBd0I7SUFHdkU7O09BRUc7SUFDSCwwQkFBbUIsS0FBZ0I7UUFBbkMsWUFDRSxrQkFBTSxLQUFLLENBQUMsU0FFYjtRQURDLEtBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxlQUFLLEVBQUUsQ0FBQzs7SUFDM0IsQ0FBQztJQUVEOztPQUVHO0lBQ0ksc0NBQVcsR0FBbEI7UUFDRSxPQUFPLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxPQUFPLEVBQUUsQ0FBQztJQUMvQixDQUFDO0lBRUQ7O09BRUc7SUFDSSwyQ0FBZ0IsR0FBdkIsVUFBd0IsV0FBYztRQUNwQyxJQUFJLENBQUMsS0FBSyxDQUFDLElBQUks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RENAMED
|
File without changes
|
package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDijkstra.js
RENAMED
|
@@ -14,6 +14,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
})();
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
var AbstractGraphIterator_1 = require("./AbstractGraphIterator");
|
|
17
|
+
var IllegalStateException_1 = require("../../../exceptions/base/IllegalStateException");
|
|
17
18
|
/**
|
|
18
19
|
* Dijkstra method graph traversal
|
|
19
20
|
*/
|
|
@@ -41,7 +42,7 @@ var GraphIteratorDijkstra = /** @class */ (function (_super) {
|
|
|
41
42
|
return aCost - bCost;
|
|
42
43
|
});
|
|
43
44
|
if (priorityList[0] === undefined) {
|
|
44
|
-
throw new
|
|
45
|
+
throw new IllegalStateException_1.default("No more vertices found");
|
|
45
46
|
}
|
|
46
47
|
return priorityList[0];
|
|
47
48
|
};
|
|
@@ -50,9 +51,6 @@ var GraphIteratorDijkstra = /** @class */ (function (_super) {
|
|
|
50
51
|
*/
|
|
51
52
|
GraphIteratorDijkstra.prototype.initIteratorImpl = function (startVertex) {
|
|
52
53
|
var _this = this;
|
|
53
|
-
if (!this.graph.hasVertex(startVertex)) {
|
|
54
|
-
throw new Error("Start vertex does not exist");
|
|
55
|
-
}
|
|
56
54
|
this.visited.set(startVertex, true);
|
|
57
55
|
this.costs.set(startVertex, 0);
|
|
58
56
|
this.graph.getVertexNeighbors(startVertex).forEach(function (neighbor) {
|
|
@@ -96,4 +94,4 @@ var GraphIteratorDijkstra = /** @class */ (function (_super) {
|
|
|
96
94
|
return GraphIteratorDijkstra;
|
|
97
95
|
}(AbstractGraphIterator_1.default));
|
|
98
96
|
exports.default = GraphIteratorDijkstra;
|
|
99
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
97
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiR3JhcGhJdGVyYXRvckRpamtzdHJhLm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QztBQUFELENBQUMsQUFuRkQsQ0FBc0QsK0JBQXFCLEdBbUYxRSJ9
|
|
File without changes
|
|
@@ -10,4 +10,4 @@ var BFSIterationStrategy = /** @class */ (function () {
|
|
|
10
10
|
return BFSIterationStrategy;
|
|
11
11
|
}());
|
|
12
12
|
exports.default = BFSIterationStrategy;
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQkZTSXRlcmF0aW9uU3RyYXRlZ3kuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvYXBwL2FsZ29yaXRobXMvZ3JhcGgvaXRlcmF0b3Itc3RyYXRlZ3kvQkZTSXRlcmF0aW9uU3RyYXRlZ3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFHQSxpRUFBNEQ7QUFFNUQ7SUFBQTtJQUtBLENBQUM7SUFIUSw2Q0FBYyxHQUFyQixVQUFzQixLQUFnQjtRQUNwQyxPQUFPLElBQUksMEJBQWdCLENBQUksS0FBSyxDQUFDLENBQUM7SUFDeEMsQ0FBQztJQUNILDJCQUFDO0FBQUQsQ0FBQyxBQUxELElBS0MifQ==
|
|
File without changes
|
|
@@ -10,4 +10,4 @@ var DFSIterationStrategy = /** @class */ (function () {
|
|
|
10
10
|
return DFSIterationStrategy;
|
|
11
11
|
}());
|
|
12
12
|
exports.default = DFSIterationStrategy;
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiREZTSXRlcmF0aW9uU3RyYXRlZ3kuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvYXBwL2FsZ29yaXRobXMvZ3JhcGgvaXRlcmF0b3Itc3RyYXRlZ3kvREZTSXRlcmF0aW9uU3RyYXRlZ3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFHQSxpRUFBNEQ7QUFFNUQ7SUFBQTtJQUtBLENBQUM7SUFIUSw2Q0FBYyxHQUFyQixVQUFzQixLQUFnQjtRQUNwQyxPQUFPLElBQUksMEJBQWdCLENBQUMsS0FBSyxDQUFDLENBQUM7SUFDckMsQ0FBQztJQUNILDJCQUFDO0FBQUQsQ0FBQyxBQUxELElBS0MifQ==
|
|
File without changes
|