@raikuxq/alg-ds 1.2.4 → 2.0.0

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.
Files changed (189) hide show
  1. package/README.md +0 -25
  2. package/lib/index.d.ts +1216 -3
  3. package/lib/index.mjs +1 -0
  4. package/package.json +78 -72
  5. package/lib/app/algorithms/binary-search.d.ts +0 -5
  6. package/lib/app/algorithms/binary-search.js +0 -27
  7. package/lib/app/algorithms/factorial.d.ts +0 -9
  8. package/lib/app/algorithms/factorial.js +0 -17
  9. package/lib/app/algorithms/fibonacci.d.ts +0 -9
  10. package/lib/app/algorithms/fibonacci.js +0 -17
  11. package/lib/app/algorithms/graph/iterator/AbstractGraphIterator.d.ts +0 -39
  12. package/lib/app/algorithms/graph/iterator/AbstractGraphIterator.js +0 -87
  13. package/lib/app/algorithms/graph/iterator/GraphIteratorBFS.d.ts +0 -28
  14. package/lib/app/algorithms/graph/iterator/GraphIteratorBFS.js +0 -70
  15. package/lib/app/algorithms/graph/iterator/GraphIteratorDFS.d.ts +0 -28
  16. package/lib/app/algorithms/graph/iterator/GraphIteratorDFS.js +0 -70
  17. package/lib/app/algorithms/graph/iterator/GraphIteratorDijkstra.d.ts +0 -32
  18. package/lib/app/algorithms/graph/iterator/GraphIteratorDijkstra.js +0 -97
  19. package/lib/app/algorithms/graph/iterator-strategy/BFSIterationStrategy.d.ts +0 -6
  20. package/lib/app/algorithms/graph/iterator-strategy/BFSIterationStrategy.js +0 -13
  21. package/lib/app/algorithms/graph/iterator-strategy/DFSIterationStrategy.d.ts +0 -6
  22. package/lib/app/algorithms/graph/iterator-strategy/DFSIterationStrategy.js +0 -13
  23. package/lib/app/algorithms/graph/iterator-strategy/DijkstraIterationStrategy.d.ts +0 -6
  24. package/lib/app/algorithms/graph/iterator-strategy/DijkstraIterationStrategy.js +0 -13
  25. package/lib/app/algorithms/graph/presenter/presenterAdjacencyLists.d.ts +0 -19
  26. package/lib/app/algorithms/graph/presenter/presenterAdjacencyLists.js +0 -28
  27. package/lib/app/algorithms/graph/presenter/presenterAdjacencyMatrix.d.ts +0 -32
  28. package/lib/app/algorithms/graph/presenter/presenterAdjacencyMatrix.js +0 -48
  29. package/lib/app/algorithms/graph/searching/hasPath.d.ts +0 -9
  30. package/lib/app/algorithms/graph/searching/hasPath.js +0 -30
  31. package/lib/app/algorithms/graph/searching/shortestPath.d.ts +0 -9
  32. package/lib/app/algorithms/graph/searching/shortestPath.js +0 -30
  33. package/lib/app/algorithms/graph/transposing/transposeDirectedGraph.d.ts +0 -2
  34. package/lib/app/algorithms/graph/transposing/transposeDirectedGraph.js +0 -14
  35. package/lib/app/algorithms/memoize.d.ts +0 -5
  36. package/lib/app/algorithms/memoize.js +0 -22
  37. package/lib/app/algorithms/sorts/bubble-sort.d.ts +0 -9
  38. package/lib/app/algorithms/sorts/bubble-sort.js +0 -23
  39. package/lib/app/algorithms/sorts/insertion-sort.d.ts +0 -9
  40. package/lib/app/algorithms/sorts/insertion-sort.js +0 -25
  41. package/lib/app/algorithms/sorts/merge-sort.d.ts +0 -9
  42. package/lib/app/algorithms/sorts/merge-sort.js +0 -61
  43. package/lib/app/algorithms/sorts/quick-sort.d.ts +0 -9
  44. package/lib/app/algorithms/sorts/quick-sort.js +0 -45
  45. package/lib/app/algorithms/sorts/select-sort.d.ts +0 -9
  46. package/lib/app/algorithms/sorts/select-sort.js +0 -20
  47. package/lib/app/algorithms/transpose-matrix.d.ts +0 -6
  48. package/lib/app/algorithms/transpose-matrix.js +0 -19
  49. package/lib/app/constants.d.ts +0 -2
  50. package/lib/app/constants.js +0 -6
  51. package/lib/app/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.d.ts +0 -15
  52. package/lib/app/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.js +0 -53
  53. package/lib/app/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.d.ts +0 -60
  54. package/lib/app/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.js +0 -35
  55. package/lib/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.d.ts +0 -13
  56. package/lib/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.js +0 -59
  57. package/lib/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.d.ts +0 -75
  58. package/lib/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.js +0 -276
  59. package/lib/app/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.d.ts +0 -16
  60. package/lib/app/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.js +0 -70
  61. package/lib/app/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.d.ts +0 -58
  62. package/lib/app/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.js +0 -236
  63. package/lib/app/data-structures/BinaryTree/_helpers/createBinaryTree.d.ts +0 -6
  64. package/lib/app/data-structures/BinaryTree/_helpers/createBinaryTree.js +0 -22
  65. package/lib/app/data-structures/Graph/AbstractGraph.d.ts +0 -84
  66. package/lib/app/data-structures/Graph/AbstractGraph.js +0 -143
  67. package/lib/app/data-structures/Graph/DirectedGraph.d.ts +0 -27
  68. package/lib/app/data-structures/Graph/DirectedGraph.js +0 -89
  69. package/lib/app/data-structures/Graph/GraphEdge.d.ts +0 -16
  70. package/lib/app/data-structures/Graph/GraphEdge.js +0 -43
  71. package/lib/app/data-structures/Graph/UndirectedGraph.d.ts +0 -31
  72. package/lib/app/data-structures/Graph/UndirectedGraph.js +0 -106
  73. package/lib/app/data-structures/Graph/_helpers/createGraph.d.ts +0 -6
  74. package/lib/app/data-structures/Graph/_helpers/createGraph.js +0 -22
  75. package/lib/app/data-structures/Graph/_helpers/createGraphFromMatrix.d.ts +0 -7
  76. package/lib/app/data-structures/Graph/_helpers/createGraphFromMatrix.js +0 -42
  77. package/lib/app/data-structures/Graph/_helpers/generateRandomGraph.d.ts +0 -4
  78. package/lib/app/data-structures/Graph/_helpers/generateRandomGraph.js +0 -67
  79. package/lib/app/data-structures/HashTable/HashTable.d.ts +0 -73
  80. package/lib/app/data-structures/HashTable/HashTable.js +0 -171
  81. package/lib/app/data-structures/HashTable/HashTableNode.d.ts +0 -11
  82. package/lib/app/data-structures/HashTable/HashTableNode.js +0 -39
  83. package/lib/app/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.d.ts +0 -134
  84. package/lib/app/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.js +0 -247
  85. package/lib/app/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedNode.d.ts +0 -20
  86. package/lib/app/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedNode.js +0 -41
  87. package/lib/app/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.d.ts +0 -42
  88. package/lib/app/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.js +0 -98
  89. package/lib/app/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedNode.d.ts +0 -25
  90. package/lib/app/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedNode.js +0 -65
  91. package/lib/app/data-structures/LinkedList/DoubleLinkedList/IterableDoubleLinkedList.d.ts +0 -18
  92. package/lib/app/data-structures/LinkedList/DoubleLinkedList/IterableDoubleLinkedList.js +0 -86
  93. package/lib/app/data-structures/LinkedList/SingleLinkedList/IterableSingleLinkedList.d.ts +0 -18
  94. package/lib/app/data-structures/LinkedList/SingleLinkedList/IterableSingleLinkedList.js +0 -68
  95. package/lib/app/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.d.ts +0 -46
  96. package/lib/app/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.js +0 -103
  97. package/lib/app/data-structures/LinkedList/SingleLinkedList/SingleLinkedNode.d.ts +0 -7
  98. package/lib/app/data-structures/LinkedList/SingleLinkedList/SingleLinkedNode.js +0 -29
  99. package/lib/app/data-structures/LinkedList/_helpers/createLinkedList.d.ts +0 -3
  100. package/lib/app/data-structures/LinkedList/_helpers/createLinkedList.js +0 -34
  101. package/lib/app/data-structures/LoopedArray/LoopedArray.d.ts +0 -86
  102. package/lib/app/data-structures/LoopedArray/LoopedArray.js +0 -165
  103. package/lib/app/data-structures/Queue/Queue.d.ts +0 -50
  104. package/lib/app/data-structures/Queue/Queue.js +0 -85
  105. package/lib/app/data-structures/Stack/Stack.d.ts +0 -50
  106. package/lib/app/data-structures/Stack/Stack.js +0 -85
  107. package/lib/app/exceptions/CollectionIsEmptyException.d.ts +0 -4
  108. package/lib/app/exceptions/CollectionIsEmptyException.js +0 -28
  109. package/lib/app/exceptions/CollectionIsFullException.d.ts +0 -4
  110. package/lib/app/exceptions/CollectionIsFullException.js +0 -28
  111. package/lib/app/exceptions/IndexOutOfBoundsException.d.ts +0 -4
  112. package/lib/app/exceptions/IndexOutOfBoundsException.js +0 -28
  113. package/lib/app/exceptions/IsAlreadyExistsException.d.ts +0 -4
  114. package/lib/app/exceptions/IsAlreadyExistsException.js +0 -28
  115. package/lib/app/exceptions/IsNotFoundException.d.ts +0 -4
  116. package/lib/app/exceptions/IsNotFoundException.js +0 -28
  117. package/lib/app/exceptions/ValueOutOfRangeException.d.ts +0 -4
  118. package/lib/app/exceptions/ValueOutOfRangeException.js +0 -28
  119. package/lib/app/exceptions/base/IllegalArgumentException.d.ts +0 -3
  120. package/lib/app/exceptions/base/IllegalArgumentException.js +0 -27
  121. package/lib/app/exceptions/base/IllegalStateException.d.ts +0 -3
  122. package/lib/app/exceptions/base/IllegalStateException.js +0 -27
  123. package/lib/app/types/EnumBinarySearchTreeType.d.ts +0 -4
  124. package/lib/app/types/EnumBinarySearchTreeType.js +0 -9
  125. package/lib/app/types/EnumGraphTraversalType.d.ts +0 -5
  126. package/lib/app/types/EnumGraphTraversalType.js +0 -10
  127. package/lib/app/types/EnumGraphType.d.ts +0 -4
  128. package/lib/app/types/EnumGraphType.js +0 -9
  129. package/lib/app/types/EnumLinkedListType.d.ts +0 -4
  130. package/lib/app/types/EnumLinkedListType.js +0 -9
  131. package/lib/app/types/EnumRandomGenerationFormat.d.ts +0 -4
  132. package/lib/app/types/EnumRandomGenerationFormat.js +0 -9
  133. package/lib/app/types/EnumSortType.d.ts +0 -7
  134. package/lib/app/types/EnumSortType.js +0 -12
  135. package/lib/app/types/EnumTreeTraversalType.d.ts +0 -5
  136. package/lib/app/types/EnumTreeTraversalType.js +0 -10
  137. package/lib/app/types/FnCompareTwo.d.ts +0 -1
  138. package/lib/app/types/FnCompareTwo.js +0 -3
  139. package/lib/app/types/FnToMemoize.d.ts +0 -1
  140. package/lib/app/types/FnToMemoize.js +0 -3
  141. package/lib/app/types/IArrayFacade.d.ts +0 -4
  142. package/lib/app/types/IArrayFacade.js +0 -3
  143. package/lib/app/types/IBiDirectIterable.d.ts +0 -5
  144. package/lib/app/types/IBiDirectIterable.js +0 -3
  145. package/lib/app/types/IBiDirectIterator.d.ts +0 -11
  146. package/lib/app/types/IBiDirectIterator.js +0 -3
  147. package/lib/app/types/IBinaryTree.d.ts +0 -12
  148. package/lib/app/types/IBinaryTree.js +0 -3
  149. package/lib/app/types/IConvertableToArray.d.ts +0 -4
  150. package/lib/app/types/IConvertableToArray.js +0 -3
  151. package/lib/app/types/IGraph.d.ts +0 -14
  152. package/lib/app/types/IGraph.js +0 -3
  153. package/lib/app/types/IGraphIterationStrategy.d.ts +0 -5
  154. package/lib/app/types/IGraphIterationStrategy.js +0 -3
  155. package/lib/app/types/IGraphIterator.d.ts +0 -11
  156. package/lib/app/types/IGraphIterator.js +0 -3
  157. package/lib/app/types/IIterable.d.ts +0 -4
  158. package/lib/app/types/IIterable.js +0 -3
  159. package/lib/app/types/IIterator.d.ts +0 -14
  160. package/lib/app/types/IIterator.js +0 -3
  161. package/lib/app/types/IKeyValueStorage.d.ts +0 -8
  162. package/lib/app/types/IKeyValueStorage.js +0 -3
  163. package/lib/app/types/ILinearStorage.d.ts +0 -11
  164. package/lib/app/types/ILinearStorage.js +0 -3
  165. package/lib/app/types/ILinearStorageRA.d.ts +0 -13
  166. package/lib/app/types/ILinearStorageRA.js +0 -3
  167. package/lib/app/types/ILinkedList.d.ts +0 -4
  168. package/lib/app/types/ILinkedList.js +0 -3
  169. package/lib/app/types/TypeArrayMatrix.d.ts +0 -1
  170. package/lib/app/types/TypeArrayMatrix.js +0 -3
  171. package/lib/app/utils.d.ts +0 -37
  172. package/lib/app/utils.js +0 -115
  173. package/lib/exports/algorithms.d.ts +0 -16
  174. package/lib/exports/algorithms.js +0 -36
  175. package/lib/exports/constants.d.ts +0 -2
  176. package/lib/exports/constants.js +0 -7
  177. package/lib/exports/data-structures.d.ts +0 -13
  178. package/lib/exports/data-structures.js +0 -28
  179. package/lib/exports/helpers.d.ts +0 -6
  180. package/lib/exports/helpers.js +0 -14
  181. package/lib/exports/sorts.d.ts +0 -6
  182. package/lib/exports/sorts.js +0 -14
  183. package/lib/exports/types.d.ts +0 -16
  184. package/lib/exports/types.js +0 -34
  185. package/lib/exports/utils.d.ts +0 -3
  186. package/lib/exports/utils.js +0 -14
  187. package/lib/exports.d.ts +0 -55
  188. package/lib/exports.js +0 -109
  189. package/lib/index.js +0 -5
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.quickSort = void 0;
4
- var utils_1 = require("../../utils");
5
- /**
6
- * Quick sort algorithm
7
- *
8
- * @description
9
- * Time complexity: Best O(n * log(n)); Avg O(n * log(n)); Worst O(n ^2)
10
- * @description
11
- * Memory complexity: Worst case: O(1)
12
- */
13
- exports.quickSort = function (arr) {
14
- var partition = function (arr, leftIndex, rightIndex) {
15
- var pivot = arr[leftIndex];
16
- var leftWall = leftIndex;
17
- var rightWall = rightIndex;
18
- while (leftWall <= rightWall) {
19
- while (arr[rightWall] > pivot) {
20
- rightWall--;
21
- }
22
- while (arr[leftWall] < pivot) {
23
- leftWall++;
24
- }
25
- if (leftWall <= rightWall) {
26
- utils_1.swapArrayItems(arr, leftWall, rightWall);
27
- rightWall--;
28
- leftWall++;
29
- }
30
- }
31
- return leftWall;
32
- };
33
- var sort = function (arr, leftIndex, rightIndex) {
34
- if (leftIndex === void 0) { leftIndex = 0; }
35
- if (rightIndex === void 0) { rightIndex = arr.length - 1; }
36
- if (leftIndex < rightIndex) {
37
- var pivot = partition(arr, leftIndex, rightIndex);
38
- sort(arr, leftIndex, pivot - 1);
39
- sort(arr, pivot, rightIndex);
40
- }
41
- return arr;
42
- };
43
- return sort(arr);
44
- };
45
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVpY2stc29ydC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9hcHAvYWxnb3JpdGhtcy9zb3J0cy9xdWljay1zb3J0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHFDQUE2QztBQUU3Qzs7Ozs7OztHQU9HO0FBQ1UsUUFBQSxTQUFTLEdBQUcsVUFBQyxHQUFrQjtJQUMxQyxJQUFNLFNBQVMsR0FBRyxVQUNoQixHQUFrQixFQUNsQixTQUFpQixFQUNqQixVQUFrQjtRQUVsQixJQUFNLEtBQUssR0FBRyxHQUFHLENBQUMsU0FBUyxDQUFDLENBQUM7UUFFN0IsSUFBSSxRQUFRLEdBQUcsU0FBUyxDQUFDO1FBQ3pCLElBQUksU0FBUyxHQUFHLFVBQVUsQ0FBQztRQUUzQixPQUFPLFFBQVEsSUFBSSxTQUFTLEVBQUU7WUFDNUIsT0FBTyxHQUFHLENBQUMsU0FBUyxDQUFDLEdBQUcsS0FBSyxFQUFFO2dCQUM3QixTQUFTLEVBQUUsQ0FBQzthQUNiO1lBQ0QsT0FBTyxHQUFHLENBQUMsUUFBUSxDQUFDLEdBQUcsS0FBSyxFQUFFO2dCQUM1QixRQUFRLEVBQUUsQ0FBQzthQUNaO1lBQ0QsSUFBSSxRQUFRLElBQUksU0FBUyxFQUFFO2dCQUN6QixzQkFBYyxDQUFDLEdBQUcsRUFBRSxRQUFRLEVBQUUsU0FBUyxDQUFDLENBQUM7Z0JBQ3pDLFNBQVMsRUFBRSxDQUFDO2dCQUNaLFFBQVEsRUFBRSxDQUFDO2FBQ1o7U0FDRjtRQUVELE9BQU8sUUFBUSxDQUFDO0lBQ2xCLENBQUMsQ0FBQztJQUVGLElBQU0sSUFBSSxHQUFHLFVBQ1gsR0FBa0IsRUFDbEIsU0FBYSxFQUNiLFVBQW1DO1FBRG5DLDBCQUFBLEVBQUEsYUFBYTtRQUNiLDJCQUFBLEVBQUEsYUFBcUIsR0FBRyxDQUFDLE1BQU0sR0FBRyxDQUFDO1FBRW5DLElBQUksU0FBUyxHQUFHLFVBQVUsRUFBRTtZQUMxQixJQUFNLEtBQUssR0FBRyxTQUFTLENBQUMsR0FBRyxFQUFFLFNBQVMsRUFBRSxVQUFVLENBQUMsQ0FBQztZQUVwRCxJQUFJLENBQUMsR0FBRyxFQUFFLFNBQVMsRUFBRSxLQUFLLEdBQUcsQ0FBQyxDQUFDLENBQUM7WUFDaEMsSUFBSSxDQUFDLEdBQUcsRUFBRSxLQUFLLEVBQUUsVUFBVSxDQUFDLENBQUM7U0FDOUI7UUFDRCxPQUFPLEdBQUcsQ0FBQztJQUNiLENBQUMsQ0FBQztJQUVGLE9BQU8sSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ25CLENBQUMsQ0FBQyJ9
@@ -1,9 +0,0 @@
1
- /**
2
- * Selection sorting algorithm
3
- *
4
- * @description
5
- * Time complexity: Best O(n \^ 2); Avg O(n \^ 2); Worst O(n \^ 2)
6
- * @description
7
- * Memory complexity: Worst case: O(1)
8
- */
9
- export declare const selectSort: (arr: Array<number>) => Array<number>;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.selectSort = void 0;
4
- var utils_1 = require("../../utils");
5
- /**
6
- * Selection sorting algorithm
7
- *
8
- * @description
9
- * Time complexity: Best O(n \^ 2); Avg O(n \^ 2); Worst O(n \^ 2)
10
- * @description
11
- * Memory complexity: Worst case: O(1)
12
- */
13
- exports.selectSort = function (arr) {
14
- for (var index = 0; index < arr.length; index++) {
15
- var minIndex = utils_1.getMinIndexFromIndex(arr, index);
16
- utils_1.swapArrayItems(arr, minIndex, index);
17
- }
18
- return arr;
19
- };
20
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VsZWN0LXNvcnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL2FsZ29yaXRobXMvc29ydHMvc2VsZWN0LXNvcnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEscUNBQW1FO0FBRW5FOzs7Ozs7O0dBT0c7QUFDVSxRQUFBLFVBQVUsR0FBRyxVQUFDLEdBQWtCO0lBQzNDLEtBQUssSUFBSSxLQUFLLEdBQUcsQ0FBQyxFQUFFLEtBQUssR0FBRyxHQUFHLENBQUMsTUFBTSxFQUFFLEtBQUssRUFBRSxFQUFFO1FBQy9DLElBQU0sUUFBUSxHQUFXLDRCQUFvQixDQUFDLEdBQUcsRUFBRSxLQUFLLENBQUMsQ0FBQztRQUUxRCxzQkFBYyxDQUFTLEdBQUcsRUFBRSxRQUFRLEVBQUUsS0FBSyxDQUFDLENBQUM7S0FDOUM7SUFFRCxPQUFPLEdBQUcsQ0FBQztBQUNiLENBQUMsQ0FBQyJ9
@@ -1,6 +0,0 @@
1
- import { TypeArrayMatrix } from "../types/TypeArrayMatrix";
2
- /**
3
- * Will flips a matrix over its diagonal
4
- * @throws {IllegalArgumentException} when array is not a matrix
5
- */
6
- export declare const transposeMatrix: (matrix: TypeArrayMatrix) => TypeArrayMatrix;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transposeMatrix = void 0;
4
- var IllegalArgumentException_1 = require("../exceptions/base/IllegalArgumentException");
5
- var utils_1 = require("../utils");
6
- /**
7
- * Will flips a matrix over its diagonal
8
- * @throws {IllegalArgumentException} when array is not a matrix
9
- */
10
- exports.transposeMatrix = function (matrix) {
11
- if (!utils_1.checkIsArrayMatrix(matrix)) {
12
- throw new IllegalArgumentException_1.default("Given array is not a matrix");
13
- }
14
- return matrix.reduce(function (acc, current, currentIndex) {
15
- acc[currentIndex] = matrix.map(function (rowArr) { return rowArr[currentIndex]; });
16
- return acc;
17
- }, new Array(matrix.length));
18
- };
19
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhbnNwb3NlLW1hdHJpeC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcHAvYWxnb3JpdGhtcy90cmFuc3Bvc2UtbWF0cml4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLHdGQUFtRjtBQUNuRixrQ0FBOEM7QUFFOUM7OztHQUdHO0FBQ1UsUUFBQSxlQUFlLEdBQUcsVUFBQyxNQUF1QjtJQUNyRCxJQUFJLENBQUMsMEJBQWtCLENBQUMsTUFBTSxDQUFDLEVBQUU7UUFDL0IsTUFBTSxJQUFJLGtDQUF3QixDQUFDLDZCQUE2QixDQUFDLENBQUM7S0FDbkU7SUFFRCxPQUFPLE1BQU0sQ0FBQyxNQUFNLENBQUMsVUFBQyxHQUFHLEVBQUUsT0FBTyxFQUFFLFlBQVk7UUFDOUMsR0FBRyxDQUFDLFlBQVksQ0FBQyxHQUFHLE1BQU0sQ0FBQyxHQUFHLENBQUMsVUFBQyxNQUFNLElBQUssT0FBQSxNQUFNLENBQUMsWUFBWSxDQUFDLEVBQXBCLENBQW9CLENBQUMsQ0FBQztRQUNqRSxPQUFPLEdBQUcsQ0FBQztJQUNiLENBQUMsRUFBRSxJQUFJLEtBQUssQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQztBQUMvQixDQUFDLENBQUMifQ==
@@ -1,2 +0,0 @@
1
- export declare const EDGE_EXISTS_STATE = 1;
2
- export declare const EDGE_NOT_EXISTS_STATE = 0;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EDGE_NOT_EXISTS_STATE = exports.EDGE_EXISTS_STATE = void 0;
4
- exports.EDGE_EXISTS_STATE = 1;
5
- exports.EDGE_NOT_EXISTS_STATE = 0;
6
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FwcC9jb25zdGFudHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQWEsUUFBQSxpQkFBaUIsR0FBRyxDQUFDLENBQUM7QUFDdEIsUUFBQSxxQkFBcUIsR0FBRyxDQUFDLENBQUMifQ==
@@ -1,15 +0,0 @@
1
- export default abstract class AbstractBinaryNode<T> {
2
- protected _data: T;
3
- protected _left: AbstractBinaryNode<T> | null;
4
- protected _right: AbstractBinaryNode<T> | null;
5
- protected _parent: AbstractBinaryNode<T> | null;
6
- protected constructor(initialData: T);
7
- get data(): T;
8
- set data(value: T);
9
- get left(): AbstractBinaryNode<T> | null;
10
- set left(value: AbstractBinaryNode<T> | null);
11
- get right(): AbstractBinaryNode<T> | null;
12
- set right(value: AbstractBinaryNode<T> | null);
13
- get parent(): AbstractBinaryNode<T> | null;
14
- set parent(value: AbstractBinaryNode<T> | null);
15
- }
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var AbstractBinaryNode = /** @class */ (function () {
4
- function AbstractBinaryNode(initialData) {
5
- this._data = initialData;
6
- this._left = null;
7
- this._right = null;
8
- this._parent = null;
9
- }
10
- Object.defineProperty(AbstractBinaryNode.prototype, "data", {
11
- get: function () {
12
- return this._data;
13
- },
14
- set: function (value) {
15
- this._data = value;
16
- },
17
- enumerable: false,
18
- configurable: true
19
- });
20
- Object.defineProperty(AbstractBinaryNode.prototype, "left", {
21
- get: function () {
22
- return this._left;
23
- },
24
- set: function (value) {
25
- this._left = value;
26
- },
27
- enumerable: false,
28
- configurable: true
29
- });
30
- Object.defineProperty(AbstractBinaryNode.prototype, "right", {
31
- get: function () {
32
- return this._right;
33
- },
34
- set: function (value) {
35
- this._right = value;
36
- },
37
- enumerable: false,
38
- configurable: true
39
- });
40
- Object.defineProperty(AbstractBinaryNode.prototype, "parent", {
41
- get: function () {
42
- return this._parent;
43
- },
44
- set: function (value) {
45
- this._parent = value;
46
- },
47
- enumerable: false,
48
- configurable: true
49
- });
50
- return AbstractBinaryNode;
51
- }());
52
- exports.default = AbstractBinaryNode;
53
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWJzdHJhY3RCaW5hcnlOb2RlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vc3JjL2FwcC9kYXRhLXN0cnVjdHVyZXMvQmluYXJ5VHJlZS9BYnN0cmFjdEJpbmFyeVRyZWUvQWJzdHJhY3RCaW5hcnlOb2RlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUE7SUFNRSw0QkFBc0IsV0FBYztRQUNsQyxJQUFJLENBQUMsS0FBSyxHQUFHLFdBQVcsQ0FBQztRQUN6QixJQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQztRQUNsQixJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQztRQUNuQixJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQztJQUN0QixDQUFDO0lBRUQsc0JBQVcsb0NBQUk7YUFBZjtZQUNFLE9BQU8sSUFBSSxDQUFDLEtBQUssQ0FBQztRQUNwQixDQUFDO2FBRUQsVUFBZ0IsS0FBUTtZQUN0QixJQUFJLENBQUMsS0FBSyxHQUFHLEtBQUssQ0FBQztRQUNyQixDQUFDOzs7T0FKQTtJQU1ELHNCQUFXLG9DQUFJO2FBQWY7WUFDRSxPQUFPLElBQUksQ0FBQyxLQUFLLENBQUM7UUFDcEIsQ0FBQzthQUVELFVBQWdCLEtBQW1DO1lBQ2pELElBQUksQ0FBQyxLQUFLLEdBQUcsS0FBSyxDQUFDO1FBQ3JCLENBQUM7OztPQUpBO0lBTUQsc0JBQVcscUNBQUs7YUFBaEI7WUFDRSxPQUFPLElBQUksQ0FBQyxNQUFNLENBQUM7UUFDckIsQ0FBQzthQUVELFVBQWlCLEtBQW1DO1lBQ2xELElBQUksQ0FBQyxNQUFNLEdBQUcsS0FBSyxDQUFDO1FBQ3RCLENBQUM7OztPQUpBO0lBTUQsc0JBQVcsc0NBQU07YUFBakI7WUFDRSxPQUFPLElBQUksQ0FBQyxPQUFPLENBQUM7UUFDdEIsQ0FBQzthQUVELFVBQWtCLEtBQW1DO1lBQ25ELElBQUksQ0FBQyxPQUFPLEdBQUcsS0FBSyxDQUFDO1FBQ3ZCLENBQUM7OztPQUpBO0lBS0gseUJBQUM7QUFBRCxDQUFDLEFBNUNELElBNENDIn0=
@@ -1,60 +0,0 @@
1
- import IBinaryTree from "../../../types/IBinaryTree";
2
- import AbstractBinaryNode from "./AbstractBinaryNode";
3
- import { FnCompareTwo } from "../../../types/FnCompareTwo";
4
- import { EnumTreeTraversalType } from "../../../types/EnumTreeTraversalType";
5
- /**
6
- *
7
- */
8
- export default abstract class AbstractBinaryTree<T> implements IBinaryTree<T> {
9
- /**
10
- * Function that checks is node A better
11
- * @default a > b
12
- * @example 5 > 4
13
- * @example 'abc' > 'aba'
14
- */
15
- protected compare: FnCompareTwo<T>;
16
- protected _head: AbstractBinaryNode<T> | null;
17
- protected _length: number;
18
- /**
19
- *
20
- * @param fnCompare
21
- * @protected
22
- */
23
- protected constructor(fnCompare?: FnCompareTwo<T>);
24
- /**
25
- * Returns nodes count in the entire tree
26
- */
27
- length(): number;
28
- /**
29
- * Will create new node and place it according to the type of tree rules
30
- */
31
- abstract insert(value: T): void;
32
- /**
33
- * Will check if tree has a node with given data
34
- */
35
- abstract has(value: T): boolean;
36
- /**
37
- * Will delete node from the tree and restructure it
38
- */
39
- abstract delete(value: T): void;
40
- /**
41
- * Max value of the tree
42
- */
43
- abstract max(): T;
44
- /**
45
- * Min value of the tree
46
- */
47
- abstract min(): T;
48
- /**
49
- * Returns same class instance with new head node
50
- */
51
- abstract subtree(value: T): IBinaryTree<T>;
52
- /**
53
- * Returns the highest branch length in the tree
54
- */
55
- abstract height(): number;
56
- /**
57
- * In-order/Pre-order/Post-order traversing of the tree
58
- */
59
- abstract traverse(type: EnumTreeTraversalType): Array<T>;
60
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- *
5
- */
6
- var AbstractBinaryTree = /** @class */ (function () {
7
- /**
8
- *
9
- * @param fnCompare
10
- * @protected
11
- */
12
- function AbstractBinaryTree(fnCompare) {
13
- /**
14
- * Function that checks is node A better
15
- * @default a > b
16
- * @example 5 > 4
17
- * @example 'abc' > 'aba'
18
- */
19
- this.compare = function (a, b) { return a > b; };
20
- if (fnCompare) {
21
- this.compare = fnCompare;
22
- }
23
- this._head = null;
24
- this._length = 0;
25
- }
26
- /**
27
- * Returns nodes count in the entire tree
28
- */
29
- AbstractBinaryTree.prototype.length = function () {
30
- return this._length;
31
- };
32
- return AbstractBinaryTree;
33
- }());
34
- exports.default = AbstractBinaryTree;
35
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWJzdHJhY3RCaW5hcnlUcmVlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vc3JjL2FwcC9kYXRhLXN0cnVjdHVyZXMvQmluYXJ5VHJlZS9BYnN0cmFjdEJpbmFyeVRyZWUvQWJzdHJhY3RCaW5hcnlUcmVlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBS0E7O0dBRUc7QUFDSDtJQVdFOzs7O09BSUc7SUFDSCw0QkFBc0IsU0FBMkI7UUFmakQ7Ozs7O1dBS0c7UUFDTyxZQUFPLEdBQW9CLFVBQUMsQ0FBSSxFQUFFLENBQUksSUFBSyxPQUFBLENBQUMsR0FBRyxDQUFDLEVBQUwsQ0FBSyxDQUFDO1FBVXpELElBQUksU0FBUyxFQUFFO1lBQ2IsSUFBSSxDQUFDLE9BQU8sR0FBRyxTQUFTLENBQUM7U0FDMUI7UUFDRCxJQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQztRQUNsQixJQUFJLENBQUMsT0FBTyxHQUFHLENBQUMsQ0FBQztJQUNuQixDQUFDO0lBRUQ7O09BRUc7SUFDSSxtQ0FBTSxHQUFiO1FBQ0UsT0FBTyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3RCLENBQUM7SUF5Q0gseUJBQUM7QUFBRCxDQUFDLEFBdEVELElBc0VDIn0=
@@ -1,13 +0,0 @@
1
- import AbstractBinaryNode from "../AbstractBinaryTree/AbstractBinaryNode";
2
- export default class BinarySearchNode<T> extends AbstractBinaryNode<T> {
3
- protected _left: BinarySearchNode<T> | null;
4
- protected _right: BinarySearchNode<T> | null;
5
- protected _parent: BinarySearchNode<T> | null;
6
- constructor(initialData: T);
7
- get left(): BinarySearchNode<T> | null;
8
- set left(value: BinarySearchNode<T> | null);
9
- get right(): BinarySearchNode<T> | null;
10
- set right(value: BinarySearchNode<T> | null);
11
- get parent(): BinarySearchNode<T> | null;
12
- set parent(value: BinarySearchNode<T> | null);
13
- }
@@ -1,59 +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 AbstractBinaryNode_1 = require("../AbstractBinaryTree/AbstractBinaryNode");
17
- var BinarySearchNode = /** @class */ (function (_super) {
18
- __extends(BinarySearchNode, _super);
19
- function BinarySearchNode(initialData) {
20
- var _this = _super.call(this, initialData) || this;
21
- _this._left = null;
22
- _this._right = null;
23
- _this._parent = null;
24
- return _this;
25
- }
26
- Object.defineProperty(BinarySearchNode.prototype, "left", {
27
- get: function () {
28
- return this._left;
29
- },
30
- set: function (value) {
31
- this._left = value;
32
- },
33
- enumerable: false,
34
- configurable: true
35
- });
36
- Object.defineProperty(BinarySearchNode.prototype, "right", {
37
- get: function () {
38
- return this._right;
39
- },
40
- set: function (value) {
41
- this._right = value;
42
- },
43
- enumerable: false,
44
- configurable: true
45
- });
46
- Object.defineProperty(BinarySearchNode.prototype, "parent", {
47
- get: function () {
48
- return this._parent;
49
- },
50
- set: function (value) {
51
- this._parent = value;
52
- },
53
- enumerable: false,
54
- configurable: true
55
- });
56
- return BinarySearchNode;
57
- }(AbstractBinaryNode_1.default));
58
- exports.default = BinarySearchNode;
59
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQmluYXJ5U2VhcmNoTm9kZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9hcHAvZGF0YS1zdHJ1Y3R1cmVzL0JpbmFyeVRyZWUvQmluYXJ5U2VhcmNoVHJlZS9CaW5hcnlTZWFyY2hOb2RlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7OztBQUFBLCtFQUEwRTtBQUUxRTtJQUFpRCxvQ0FBcUI7SUFLcEUsMEJBQW1CLFdBQWM7UUFBakMsWUFDRSxrQkFBTSxXQUFXLENBQUMsU0FJbkI7UUFIQyxLQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQztRQUNsQixLQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQztRQUNuQixLQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQzs7SUFDdEIsQ0FBQztJQUVELHNCQUFXLGtDQUFJO2FBQWY7WUFDRSxPQUFPLElBQUksQ0FBQyxLQUFLLENBQUM7UUFDcEIsQ0FBQzthQUVELFVBQWdCLEtBQWlDO1lBQy9DLElBQUksQ0FBQyxLQUFLLEdBQUcsS0FBSyxDQUFDO1FBQ3JCLENBQUM7OztPQUpBO0lBTUQsc0JBQVcsbUNBQUs7YUFBaEI7WUFDRSxPQUFPLElBQUksQ0FBQyxNQUFNLENBQUM7UUFDckIsQ0FBQzthQUVELFVBQWlCLEtBQWlDO1lBQ2hELElBQUksQ0FBQyxNQUFNLEdBQUcsS0FBSyxDQUFDO1FBQ3RCLENBQUM7OztPQUpBO0lBTUQsc0JBQVcsb0NBQU07YUFBakI7WUFDRSxPQUFPLElBQUksQ0FBQyxPQUFPLENBQUM7UUFDdEIsQ0FBQzthQUVELFVBQWtCLEtBQWlDO1lBQ2pELElBQUksQ0FBQyxPQUFPLEdBQUcsS0FBSyxDQUFDO1FBQ3ZCLENBQUM7OztPQUpBO0lBS0gsdUJBQUM7QUFBRCxDQUFDLEFBbkNELENBQWlELDRCQUFrQixHQW1DbEUifQ==
@@ -1,75 +0,0 @@
1
- import { FnCompareTwo } from "../../../types/FnCompareTwo";
2
- import { EnumTreeTraversalType } from "../../../types/EnumTreeTraversalType";
3
- import IBinaryTree from "../../../types/IBinaryTree";
4
- import AbstractBinaryTree from "../AbstractBinaryTree/AbstractBinaryTree";
5
- import BinarySearchNode from "./BinarySearchNode";
6
- /**
7
- * Unbalanced binary search tree implementation
8
- */
9
- export default class BinarySearchTree<T> extends AbstractBinaryTree<T> {
10
- /**
11
- * Override types
12
- */
13
- protected _head: BinarySearchNode<T> | null;
14
- /**
15
- * @inheritDoc
16
- */
17
- constructor(fnCompare?: FnCompareTwo<T>);
18
- /**
19
- *
20
- * @throws {CollectionIsEmptyException} when tree is empty
21
- */
22
- protected checkIsEmpty(): void;
23
- /**
24
- * Will update left and right links parent with current node
25
- */
26
- protected updateLeftRightParents(node: BinarySearchNode<T>): void;
27
- /**
28
- * Will return node instance by its data
29
- */
30
- protected findNode(value: T): BinarySearchNode<T> | null;
31
- /**
32
- * @inheritDoc
33
- */
34
- protected insertToLeaf(createdNode: BinarySearchNode<T>): void;
35
- /**
36
- * Will join two trees into one */
37
- protected join(treeLeft: BinarySearchNode<T> | null, treeRight: BinarySearchNode<T> | null): BinarySearchNode<T> | null;
38
- /**
39
- * @inheritDoc
40
- * @throws {CollectionIsEmptyException} when tree is empty
41
- */
42
- max(): T;
43
- /**
44
- * @inheritDoc
45
- * @throws {CollectionIsEmptyException} when tree is empty
46
- */
47
- min(): T;
48
- /**
49
- * @inheritDoc
50
- * @throws {IsAlreadyExistsException} when node already exists
51
- */
52
- insert(value: T): void;
53
- /**
54
- * @inheritDoc
55
- */
56
- has(value: T): boolean;
57
- /**
58
- * @inheritDoc
59
- * @throws {IsNotFoundException} when node was not found
60
- */
61
- delete(value: T): void;
62
- /**
63
- * @inheritDoc
64
- */
65
- subtree(value: T): IBinaryTree<T>;
66
- /**
67
- * @inheritDoc
68
- * @throws {CollectionIsEmptyException} when tree is empty
69
- */
70
- traverse(type: EnumTreeTraversalType, from?: T): Array<T>;
71
- /**
72
- * Calc max height of the largest branch of the tree
73
- */
74
- height(): number;
75
- }