@raikuxq/alg-ds 1.1.2 → 1.1.5

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 (257) hide show
  1. package/README.md +26 -2
  2. package/lib/algorithms/binary-search.d.ts +5 -0
  3. package/lib/algorithms/binary-search.js +27 -0
  4. package/lib/algorithms/factorial.d.ts +9 -0
  5. package/lib/algorithms/factorial.js +17 -0
  6. package/lib/algorithms/fibonacci.d.ts +9 -0
  7. package/lib/algorithms/fibonacci.js +17 -0
  8. package/lib/algorithms/memoize.d.ts +5 -0
  9. package/lib/algorithms/memoize.js +22 -0
  10. package/lib/algorithms/sorts/bubble-sort.d.ts +9 -0
  11. package/lib/algorithms/sorts/bubble-sort.js +23 -0
  12. package/lib/algorithms/sorts/insertion-sort.d.ts +9 -0
  13. package/lib/algorithms/sorts/insertion-sort.js +25 -0
  14. package/lib/algorithms/sorts/merge-sort.d.ts +9 -0
  15. package/lib/algorithms/sorts/merge-sort.js +61 -0
  16. package/lib/algorithms/sorts/quick-sort.d.ts +9 -0
  17. package/lib/algorithms/sorts/quick-sort.js +45 -0
  18. package/lib/algorithms/sorts/select-sort.d.ts +9 -0
  19. package/lib/algorithms/sorts/select-sort.js +20 -0
  20. package/lib/algorithms/transpose-matrix.d.ts +5 -0
  21. package/lib/algorithms/transpose-matrix.js +20 -0
  22. package/lib/constants.d.ts +2 -0
  23. package/lib/constants.js +6 -0
  24. package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.d.ts +15 -0
  25. package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.js +53 -0
  26. package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.d.ts +60 -0
  27. package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.js +36 -0
  28. package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.d.ts +13 -0
  29. package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.js +59 -0
  30. package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.d.ts +70 -0
  31. package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.js +268 -0
  32. package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.d.ts +16 -0
  33. package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.js +70 -0
  34. package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.d.ts +57 -0
  35. package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.js +234 -0
  36. package/lib/data-structures/Graph/AbstractGraph.d.ts +84 -0
  37. package/lib/data-structures/Graph/AbstractGraph.js +141 -0
  38. package/lib/data-structures/Graph/DirectedGraph.d.ts +24 -0
  39. package/lib/data-structures/Graph/DirectedGraph.js +85 -0
  40. package/lib/data-structures/Graph/GraphEdge.d.ts +16 -0
  41. package/lib/data-structures/Graph/GraphEdge.js +43 -0
  42. package/lib/data-structures/Graph/UndirectedGraph.d.ts +28 -0
  43. package/lib/data-structures/Graph/UndirectedGraph.js +102 -0
  44. package/lib/data-structures/Graph/demo/generateRandomGraph.d.ts +4 -0
  45. package/lib/data-structures/Graph/demo/generateRandomGraph.js +72 -0
  46. package/lib/data-structures/Graph/iterator/AbstractGraphIterator.d.ts +35 -0
  47. package/lib/data-structures/Graph/iterator/AbstractGraphIterator.js +90 -0
  48. package/lib/data-structures/Graph/iterator/GraphIteratorBFS.d.ts +28 -0
  49. package/lib/data-structures/Graph/iterator/GraphIteratorBFS.js +70 -0
  50. package/lib/data-structures/Graph/iterator/GraphIteratorDFS.d.ts +28 -0
  51. package/lib/data-structures/Graph/iterator/GraphIteratorDFS.js +70 -0
  52. package/lib/data-structures/Graph/iterator/GraphIteratorDijkstra.d.ts +32 -0
  53. package/lib/data-structures/Graph/iterator/GraphIteratorDijkstra.js +99 -0
  54. package/lib/data-structures/Graph/presenter/presenterAdjacencyLists.d.ts +19 -0
  55. package/lib/data-structures/Graph/presenter/presenterAdjacencyLists.js +28 -0
  56. package/{src/data-structures/Graph/presenter/presenterAdjacencyMatrix.ts → lib/data-structures/Graph/presenter/presenterAdjacencyMatrix.d.ts} +32 -51
  57. package/lib/data-structures/Graph/presenter/presenterAdjacencyMatrix.js +48 -0
  58. package/lib/data-structures/Graph/searching/hasPath.d.ts +9 -0
  59. package/lib/data-structures/Graph/searching/hasPath.js +29 -0
  60. package/lib/data-structures/Graph/searching/shortestPath.d.ts +9 -0
  61. package/lib/data-structures/Graph/searching/shortestPath.js +29 -0
  62. package/lib/data-structures/Graph/strategy/BFSIterationStrategy.d.ts +6 -0
  63. package/lib/data-structures/Graph/strategy/BFSIterationStrategy.js +13 -0
  64. package/lib/data-structures/Graph/strategy/DFSIterationStrategy.d.ts +6 -0
  65. package/lib/data-structures/Graph/strategy/DFSIterationStrategy.js +13 -0
  66. package/lib/data-structures/Graph/strategy/DijkstraIterationStrategy.d.ts +6 -0
  67. package/lib/data-structures/Graph/strategy/DijkstraIterationStrategy.js +13 -0
  68. package/lib/data-structures/Graph/transposing/transposeDirectedGraph.d.ts +2 -0
  69. package/lib/data-structures/Graph/transposing/transposeDirectedGraph.js +14 -0
  70. package/lib/data-structures/HashTable/HashTable.d.ts +73 -0
  71. package/lib/data-structures/HashTable/HashTable.js +169 -0
  72. package/lib/data-structures/HashTable/HashTableNode.d.ts +11 -0
  73. package/lib/data-structures/HashTable/HashTableNode.js +39 -0
  74. package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.d.ts +125 -0
  75. package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.js +236 -0
  76. package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedNode.d.ts +20 -0
  77. package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedNode.js +41 -0
  78. package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.d.ts +48 -0
  79. package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.js +150 -0
  80. package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedNode.d.ts +25 -0
  81. package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedNode.js +65 -0
  82. package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.d.ts +52 -0
  83. package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.js +137 -0
  84. package/{src/data-structures/LinkedList/SingleLinkedList/SingleLinkedNode.ts → lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedNode.d.ts} +7 -10
  85. package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedNode.js +29 -0
  86. package/lib/data-structures/LoopedArray/LoopedArray.d.ts +86 -0
  87. package/lib/data-structures/LoopedArray/LoopedArray.js +161 -0
  88. package/lib/data-structures/Queue/Queue.d.ts +50 -0
  89. package/lib/data-structures/Queue/Queue.js +83 -0
  90. package/lib/data-structures/Stack/Stack.d.ts +50 -0
  91. package/lib/data-structures/Stack/Stack.js +83 -0
  92. package/lib/exports/algorithms.d.ts +16 -0
  93. package/lib/exports/algorithms.js +36 -0
  94. package/lib/exports/constants.d.ts +2 -0
  95. package/lib/exports/constants.js +7 -0
  96. package/lib/exports/data-structures.d.ts +11 -0
  97. package/lib/exports/data-structures.js +24 -0
  98. package/lib/exports/helpers.d.ts +6 -0
  99. package/lib/exports/helpers.js +14 -0
  100. package/lib/exports/sorts.d.ts +6 -0
  101. package/lib/exports/sorts.js +14 -0
  102. package/lib/exports/utils.d.ts +3 -0
  103. package/lib/exports/utils.js +14 -0
  104. package/lib/exports.d.ts +44 -0
  105. package/lib/exports.js +89 -0
  106. package/lib/helpers/createBinaryTree.d.ts +6 -0
  107. package/lib/helpers/createBinaryTree.js +22 -0
  108. package/lib/helpers/createGraph.d.ts +6 -0
  109. package/lib/helpers/createGraph.js +24 -0
  110. package/lib/helpers/createGraphFromMatrix.d.ts +7 -0
  111. package/lib/helpers/createGraphFromMatrix.js +37 -0
  112. package/lib/helpers/createLinkedList.d.ts +3 -0
  113. package/lib/helpers/createLinkedList.js +21 -0
  114. package/lib/index.d.ts +3 -0
  115. package/lib/index.js +6 -0
  116. package/lib/types/ArrayMatrix.d.ts +1 -0
  117. package/lib/types/ArrayMatrix.js +3 -0
  118. package/lib/types/EnumBinarySearchTreeType.d.ts +4 -0
  119. package/lib/types/EnumBinarySearchTreeType.js +9 -0
  120. package/lib/types/EnumGraphType.d.ts +4 -0
  121. package/lib/types/EnumGraphType.js +9 -0
  122. package/lib/types/EnumLinkedListType.d.ts +4 -0
  123. package/lib/types/EnumLinkedListType.js +9 -0
  124. package/lib/types/EnumRandomGenerationFormat.d.ts +4 -0
  125. package/lib/types/EnumRandomGenerationFormat.js +9 -0
  126. package/lib/types/EnumTreeTraversalType.d.ts +5 -0
  127. package/lib/types/EnumTreeTraversalType.js +10 -0
  128. package/lib/types/FnCompareTwo.d.ts +1 -0
  129. package/lib/types/FnCompareTwo.js +3 -0
  130. package/lib/types/FnToMemoize.d.ts +1 -0
  131. package/lib/types/FnToMemoize.js +3 -0
  132. package/{src/types/ILinkedList.ts → lib/types/IArrayFacade.d.ts} +4 -6
  133. package/lib/types/IArrayFacade.js +3 -0
  134. package/{src/types/IBiDirectIterable.ts → lib/types/IBiDirectIterable.d.ts} +5 -6
  135. package/lib/types/IBiDirectIterable.js +3 -0
  136. package/lib/types/IBiDirectIterator.d.ts +11 -0
  137. package/lib/types/IBiDirectIterator.js +3 -0
  138. package/lib/types/IBinaryTree.d.ts +12 -0
  139. package/lib/types/IBinaryTree.js +3 -0
  140. package/lib/types/IConvertableToArray.d.ts +4 -0
  141. package/lib/types/IConvertableToArray.js +3 -0
  142. package/lib/types/IGraph.d.ts +14 -0
  143. package/lib/types/IGraph.js +3 -0
  144. package/{src/types/IGraphIterationStrategy.ts → lib/types/IGraphIterationStrategy.d.ts} +5 -6
  145. package/lib/types/IGraphIterationStrategy.js +3 -0
  146. package/lib/types/IGraphIterator.d.ts +11 -0
  147. package/lib/types/IGraphIterator.js +3 -0
  148. package/{src/types/IIterable.ts → lib/types/IIterable.d.ts} +4 -5
  149. package/lib/types/IIterable.js +3 -0
  150. package/lib/types/IIterator.d.ts +14 -0
  151. package/lib/types/IIterator.js +3 -0
  152. package/lib/types/IKeyValueStorage.d.ts +8 -0
  153. package/lib/types/IKeyValueStorage.js +3 -0
  154. package/lib/types/ILinearStorage.d.ts +11 -0
  155. package/lib/types/ILinearStorage.js +3 -0
  156. package/{src/types/ILinearStorageRA.ts → lib/types/ILinearStorageRA.d.ts} +13 -14
  157. package/lib/types/ILinearStorageRA.js +3 -0
  158. package/{src/types/IArrayFacade.ts → lib/types/ILinkedList.d.ts} +4 -6
  159. package/lib/types/ILinkedList.js +3 -0
  160. package/lib/utils.d.ts +29 -0
  161. package/lib/utils.js +95 -0
  162. package/package.json +9 -3
  163. package/.idea/algorythmes.iml +0 -15
  164. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  165. package/.idea/deployment.xml +0 -14
  166. package/.idea/inspectionProfiles/Project_Default.xml +0 -7
  167. package/.idea/jsLinters/eslint.xml +0 -6
  168. package/.idea/misc.xml +0 -6
  169. package/.idea/modules.xml +0 -8
  170. package/.idea/vcs.xml +0 -6
  171. package/lib/algotirhms.ts +0 -35
  172. package/lib/constants.ts +0 -3
  173. package/lib/data-structures.ts +0 -23
  174. package/lib/helpers.ts +0 -13
  175. package/lib/sorts.ts +0 -7
  176. package/lib/types.ts +0 -53
  177. package/lib/utils.ts +0 -21
  178. package/src/algorithms/binary-search.ts +0 -28
  179. package/src/algorithms/factorial.ts +0 -18
  180. package/src/algorithms/fibonacci.ts +0 -18
  181. package/src/algorithms/memoize.ts +0 -21
  182. package/src/algorithms/sorts/bubble-sort.ts +0 -21
  183. package/src/algorithms/sorts/insertion-sort.ts +0 -25
  184. package/src/algorithms/sorts/merge-sort.ts +0 -74
  185. package/src/algorithms/sorts/quick-sort.ts +0 -54
  186. package/src/algorithms/sorts/select-sort.ts +0 -19
  187. package/src/algorithms/transpose-matrix.ts +0 -19
  188. package/src/constants.ts +0 -2
  189. package/src/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.ts +0 -45
  190. package/src/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts +0 -80
  191. package/src/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts +0 -38
  192. package/src/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts +0 -286
  193. package/src/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.ts +0 -48
  194. package/src/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.ts +0 -228
  195. package/src/data-structures/Graph/AbstractGraph.ts +0 -189
  196. package/src/data-structures/Graph/DirectedGraph.ts +0 -84
  197. package/src/data-structures/Graph/GraphEdge.ts +0 -33
  198. package/src/data-structures/Graph/UndirectedGraph.ts +0 -108
  199. package/src/data-structures/Graph/demo/generateRandomGraph.ts +0 -93
  200. package/src/data-structures/Graph/iterator/AbstractGraphIterator.ts +0 -99
  201. package/src/data-structures/Graph/iterator/GraphIteratorBFS.ts +0 -60
  202. package/src/data-structures/Graph/iterator/GraphIteratorDFS.ts +0 -60
  203. package/src/data-structures/Graph/iterator/GraphIteratorDijkstra.ts +0 -94
  204. package/src/data-structures/Graph/presenter/presenterAdjacencyLists.ts +0 -29
  205. package/src/data-structures/Graph/searching/hasPath.ts +0 -38
  206. package/src/data-structures/Graph/searching/shortestPath.ts +0 -38
  207. package/src/data-structures/Graph/strategy/BFSIterationStrategy.ts +0 -11
  208. package/src/data-structures/Graph/strategy/DFSIterationStrategy.ts +0 -11
  209. package/src/data-structures/Graph/strategy/DijkstraIterationStrategy.ts +0 -11
  210. package/src/data-structures/Graph/transposing/transposeDirectedGraph.ts +0 -19
  211. package/src/data-structures/HashTable/HashTable.ts +0 -202
  212. package/src/data-structures/HashTable/HashTableNode.ts +0 -31
  213. package/src/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.ts +0 -310
  214. package/src/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedNode.ts +0 -33
  215. package/src/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.ts +0 -156
  216. package/src/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedNode.ts +0 -47
  217. package/src/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.ts +0 -147
  218. package/src/data-structures/LoopedArray/LoopedArray.ts +0 -182
  219. package/src/data-structures/Queue/Queue.ts +0 -92
  220. package/src/data-structures/Stack/Stack.ts +0 -92
  221. package/src/demo/demo.bst.ts +0 -67
  222. package/src/demo/demo.graph.ts +0 -246
  223. package/src/demo/demo.hashtable.ts +0 -28
  224. package/src/demo/demo.linked-list.ts +0 -78
  225. package/src/demo/demo.looped-array.ts +0 -104
  226. package/src/demo/demo.queue.ts +0 -40
  227. package/src/demo/demo.stack.ts +0 -40
  228. package/src/demo/performance/bst-compare.ts +0 -35
  229. package/src/demo/performance/ds-compare.ts +0 -58
  230. package/src/demo/performance/hash-table.compare.ts +0 -40
  231. package/src/demo/performance/sort-compare.ts +0 -60
  232. package/src/helpers/createBinaryTree.ts +0 -24
  233. package/src/helpers/createGraph.ts +0 -24
  234. package/src/helpers/createGraphFromMatrix.ts +0 -47
  235. package/src/helpers/createLinkedList.ts +0 -24
  236. package/src/index.ts +0 -44
  237. package/src/types/ArrayMatrix.ts +0 -1
  238. package/src/types/EnumBinarySearchTreeType.ts +0 -4
  239. package/src/types/EnumGraphTraversalType.ts +0 -5
  240. package/src/types/EnumGraphType.ts +0 -4
  241. package/src/types/EnumLinkedListType.ts +0 -4
  242. package/src/types/EnumRandomGenerationFormat.ts +0 -4
  243. package/src/types/EnumSortType.ts +0 -7
  244. package/src/types/EnumTreeTraversalType.ts +0 -5
  245. package/src/types/FnCompareTwo.ts +0 -1
  246. package/src/types/FnSort.ts +0 -1
  247. package/src/types/FnToMemoize.ts +0 -1
  248. package/src/types/IBiDirectIterator.ts +0 -12
  249. package/src/types/IBinaryTree.ts +0 -13
  250. package/src/types/IConvertableToArray.ts +0 -4
  251. package/src/types/IGraph.ts +0 -16
  252. package/src/types/IGraphCreator.ts +0 -5
  253. package/src/types/IGraphIterator.ts +0 -13
  254. package/src/types/IIterator.ts +0 -14
  255. package/src/types/IKeyValueStorage.ts +0 -8
  256. package/src/types/ILinearStorage.ts +0 -11
  257. package/src/utils.ts +0 -65
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createGraphFromMatrix = void 0;
4
+ var EnumGraphType_1 = require("../types/EnumGraphType");
5
+ var createGraph_1 = require("./createGraph");
6
+ var constants_1 = require("../constants");
7
+ /**
8
+ * Creates a graph from N*N matrix that contains 1 in case of edge exists or 0 in case it does not
9
+ */
10
+ exports.createGraphFromMatrix = function (matrix, fieldsList, type) {
11
+ var graph = createGraph_1.createGraph(type);
12
+ fieldsList.forEach(function (fieldName) {
13
+ graph.addVertex(fieldName);
14
+ });
15
+ matrix.forEach(function (row, rowIndex) {
16
+ row.forEach(function (col, colIndex) {
17
+ var rowColState = matrix[rowIndex][colIndex];
18
+ var colRowState = matrix[colIndex][rowIndex];
19
+ if (type === EnumGraphType_1.EnumGraphType.Undirected) {
20
+ if (rowColState === constants_1.EDGE_EXISTS_STATE &&
21
+ colRowState === constants_1.EDGE_EXISTS_STATE) {
22
+ graph.addEdge(fieldsList[rowIndex], fieldsList[colIndex]);
23
+ }
24
+ }
25
+ if (type === EnumGraphType_1.EnumGraphType.Directed) {
26
+ if (rowColState === constants_1.EDGE_EXISTS_STATE) {
27
+ graph.addEdge(fieldsList[rowIndex], fieldsList[colIndex]);
28
+ }
29
+ if (colRowState === constants_1.EDGE_EXISTS_STATE) {
30
+ graph.addEdge(fieldsList[colIndex], fieldsList[rowIndex]);
31
+ }
32
+ }
33
+ });
34
+ });
35
+ return graph;
36
+ };
37
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlR3JhcGhGcm9tTWF0cml4LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2hlbHBlcnMvY3JlYXRlR3JhcGhGcm9tTWF0cml4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLHdEQUF1RDtBQUV2RCw2Q0FBNEM7QUFDNUMsMENBQWlEO0FBRWpEOztHQUVHO0FBQ1UsUUFBQSxxQkFBcUIsR0FBRyxVQUNuQyxNQUFtQixFQUNuQixVQUFvQixFQUNwQixJQUFtQjtJQUVuQixJQUFNLEtBQUssR0FBYyx5QkFBVyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBRTNDLFVBQVUsQ0FBQyxPQUFPLENBQUMsVUFBQyxTQUFTO1FBQzNCLEtBQUssQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLENBQUM7SUFDN0IsQ0FBQyxDQUFDLENBQUM7SUFFSCxNQUFNLENBQUMsT0FBTyxDQUFDLFVBQUMsR0FBa0IsRUFBRSxRQUFnQjtRQUNsRCxHQUFHLENBQUMsT0FBTyxDQUFDLFVBQUMsR0FBVyxFQUFFLFFBQWdCO1lBQ3hDLElBQU0sV0FBVyxHQUFHLE1BQU0sQ0FBQyxRQUFRLENBQUMsQ0FBQyxRQUFRLENBQUMsQ0FBQztZQUMvQyxJQUFNLFdBQVcsR0FBRyxNQUFNLENBQUMsUUFBUSxDQUFDLENBQUMsUUFBUSxDQUFDLENBQUM7WUFFL0MsSUFBSSxJQUFJLEtBQUssNkJBQWEsQ0FBQyxVQUFVLEVBQUU7Z0JBQ3JDLElBQ0UsV0FBVyxLQUFLLDZCQUFpQjtvQkFDakMsV0FBVyxLQUFLLDZCQUFpQixFQUNqQztvQkFDQSxLQUFLLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsRUFBRSxVQUFVLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQztpQkFDM0Q7YUFDRjtZQUVELElBQUksSUFBSSxLQUFLLDZCQUFhLENBQUMsUUFBUSxFQUFFO2dCQUNuQyxJQUFJLFdBQVcsS0FBSyw2QkFBaUIsRUFBRTtvQkFDckMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUMsUUFBUSxDQUFDLEVBQUUsVUFBVSxDQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUM7aUJBQzNEO2dCQUNELElBQUksV0FBVyxLQUFLLDZCQUFpQixFQUFFO29CQUNyQyxLQUFLLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsRUFBRSxVQUFVLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQztpQkFDM0Q7YUFDRjtRQUNILENBQUMsQ0FBQyxDQUFDO0lBQ0wsQ0FBQyxDQUFDLENBQUM7SUFFSCxPQUFPLEtBQUssQ0FBQztBQUNmLENBQUMsQ0FBQyJ9
@@ -0,0 +1,3 @@
1
+ import { EnumLinkedListType } from "../types/EnumLinkedListType";
2
+ import ILinkedList from "../types/ILinkedList";
3
+ export declare const createLinkedList: <T>(type: EnumLinkedListType, capacity?: number | undefined) => ILinkedList<T>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLinkedList = void 0;
4
+ var EnumLinkedListType_1 = require("../types/EnumLinkedListType");
5
+ var DoubleLinkedList_1 = require("../data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList");
6
+ var SingleLinkedList_1 = require("../data-structures/LinkedList/SingleLinkedList/SingleLinkedList");
7
+ exports.createLinkedList = function (type, capacity) {
8
+ var linkedList;
9
+ switch (type) {
10
+ case EnumLinkedListType_1.EnumLinkedListType.DOUBLE:
11
+ linkedList = new DoubleLinkedList_1.default(capacity);
12
+ break;
13
+ case EnumLinkedListType_1.EnumLinkedListType.SINGLE:
14
+ linkedList = new SingleLinkedList_1.default(capacity);
15
+ break;
16
+ default:
17
+ throw new Error("Invalid list type");
18
+ }
19
+ return linkedList;
20
+ };
21
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlTGlua2VkTGlzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9oZWxwZXJzL2NyZWF0ZUxpbmtlZExpc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsa0VBQWlFO0FBQ2pFLG9HQUErRjtBQUMvRixvR0FBK0Y7QUFHbEYsUUFBQSxnQkFBZ0IsR0FBRyxVQUM5QixJQUF3QixFQUN4QixRQUFpQjtJQUVqQixJQUFJLFVBQTBCLENBQUM7SUFFL0IsUUFBUSxJQUFJLEVBQUU7UUFDWixLQUFLLHVDQUFrQixDQUFDLE1BQU07WUFDNUIsVUFBVSxHQUFHLElBQUksMEJBQWdCLENBQUMsUUFBUSxDQUFDLENBQUM7WUFDNUMsTUFBTTtRQUNSLEtBQUssdUNBQWtCLENBQUMsTUFBTTtZQUM1QixVQUFVLEdBQUcsSUFBSSwwQkFBZ0IsQ0FBQyxRQUFRLENBQUMsQ0FBQztZQUM1QyxNQUFNO1FBQ1I7WUFDRSxNQUFNLElBQUksS0FBSyxDQUFDLG1CQUFtQixDQUFDLENBQUM7S0FDeEM7SUFFRCxPQUFPLFVBQVUsQ0FBQztBQUNwQixDQUFDLENBQUMifQ==
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Write your code here
3
+ */
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,4 @@
1
+ export declare enum EnumBinarySearchTreeType {
2
+ BST = "Binary Search Tree",
3
+ RANDOMIZED_BST = "Randomized Binary Search Tree"
4
+ }
@@ -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,4 @@
1
+ export declare enum EnumGraphType {
2
+ Directed = "Directed",
3
+ Undirected = "Undirected"
4
+ }
@@ -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,4 @@
1
+ export declare enum EnumLinkedListType {
2
+ DOUBLE = "Double linked list",
3
+ SINGLE = "Single linked list"
4
+ }
@@ -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,4 @@
1
+ export declare enum EnumRandomGenerationFormat {
2
+ Numbers = "NUMBERS",
3
+ Hash = "HASH"
4
+ }
@@ -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,5 @@
1
+ export declare enum EnumTreeTraversalType {
2
+ InOrder = "InOrder",
3
+ PreOrder = "PreOrder",
4
+ PostOrder = "PostOrder"
5
+ }
@@ -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
@@ -1,6 +1,4 @@
1
- import ILinearStorageRA from "./ILinearStorageRA";
2
- import IConvertableToArray from "./IConvertableToArray";
3
-
4
- export default interface ILinkedList<T>
5
- extends ILinearStorageRA<T>,
6
- IConvertableToArray<T> {}
1
+ import ILinearStorageRA from "./ILinearStorageRA";
2
+ import IConvertableToArray from "./IConvertableToArray";
3
+ export default interface IArrayFacade<T> extends ILinearStorageRA<T>, IConvertableToArray<T> {
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUFycmF5RmFjYWRlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL0lBcnJheUZhY2FkZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
@@ -1,6 +1,5 @@
1
- import IBiDirectIterator from "./IBiDirectIterator";
2
- import IIterable from "./IIterable";
3
-
4
- export default interface IBiDirectIterable<T> extends IIterable<T> {
5
- iterator(fromIndex?: number): IBiDirectIterator<T>;
6
- }
1
+ import IBiDirectIterator from "./IBiDirectIterator";
2
+ import IIterable from "./IIterable";
3
+ export default interface IBiDirectIterable<T> extends IIterable<T> {
4
+ iterator(fromIndex?: number): IBiDirectIterator<T>;
5
+ }
@@ -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,4 @@
1
+ export default interface IConvertableToArray<T> {
2
+ pushFromArray(elements: Array<T>): void;
3
+ getAsArray(): Array<T>;
4
+ }
@@ -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=
@@ -1,6 +1,5 @@
1
- import IGraph from "./IGraph";
2
- import IGraphIterator from "./IGraphIterator";
3
-
4
- export default interface IGraphIterationStrategy<T> {
5
- createIterator(graph: IGraph<T>): IGraphIterator<T>;
6
- }
1
+ import IGraph from "./IGraph";
2
+ import IGraphIterator from "./IGraphIterator";
3
+ export default interface IGraphIterationStrategy<T> {
4
+ createIterator(graph: IGraph<T>): IGraphIterator<T>;
5
+ }
@@ -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
@@ -1,5 +1,4 @@
1
- import IIterator from "./IIterator";
2
-
3
- export default interface IIterable<T> {
4
- iterator(fromIndex?: number): IIterator<T>;
5
- }
1
+ import IIterator from "./IIterator";
2
+ export default interface IIterable<T> {
3
+ iterator(fromIndex?: number): IIterator<T>;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUl0ZXJhYmxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL0lJdGVyYWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
@@ -0,0 +1,14 @@
1
+ export default interface IIterator<T> {
2
+ /**
3
+ * Will do one iteration and returns next item value
4
+ */
5
+ next(): T;
6
+ /**
7
+ * Will returns current value
8
+ */
9
+ current(): T;
10
+ /**
11
+ * Check if next element exists
12
+ */
13
+ hasNext(): boolean;
14
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUl0ZXJhdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL0lJdGVyYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
@@ -0,0 +1,8 @@
1
+ export default interface IKeyValueStorage<T> {
2
+ set(key: string, value: T): void;
3
+ has(key: string): boolean;
4
+ get(key: string): T;
5
+ delete(key: string): void;
6
+ length(): number;
7
+ clear(): void;
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUtleVZhbHVlU3RvcmFnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eXBlcy9JS2V5VmFsdWVTdG9yYWdlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
@@ -0,0 +1,11 @@
1
+ export default interface ILinearStorage<T> {
2
+ peek(): T;
3
+ push(value: T): void;
4
+ pop(): T;
5
+ has(value: T): boolean;
6
+ isEmpty(): boolean;
7
+ isFull(): boolean;
8
+ length(): number;
9
+ clear(): void;
10
+ reverse(): void;
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUxpbmVhclN0b3JhZ2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvSUxpbmVhclN0b3JhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
@@ -1,14 +1,13 @@
1
- import ILinearStorage from "./ILinearStorage";
2
-
3
- /**
4
- * Interface extends default linear storage with methods that allows read/write operations for all storage elements
5
- * RA - randomly accessible
6
- */
7
- export default interface ILinearStorageRA<T> extends ILinearStorage<T> {
8
- peekFromStart(): T;
9
- peekByIndex(index: number): T;
10
- unshift(value: T): void;
11
- pushFromIndex(value: T, fromIndex: number): void;
12
- shift(): T;
13
- deleteFromIndex(fromIndex: number): T;
14
- }
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==
@@ -1,6 +1,4 @@
1
- import ILinearStorageRA from "./ILinearStorageRA";
2
- import IConvertableToArray from "./IConvertableToArray";
3
-
4
- export default interface IArrayFacade<T>
5
- extends ILinearStorageRA<T>,
6
- IConvertableToArray<T> {}
1
+ import ILinearStorageRA from "./ILinearStorageRA";
2
+ import IConvertableToArray from "./IConvertableToArray";
3
+ export default interface ILinkedList<T> extends ILinearStorageRA<T>, IConvertableToArray<T> {
4
+ }
@@ -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
@@ -4,7 +4,7 @@
4
4
  "test": "jest",
5
5
  "dev": "nodemon",
6
6
  "build": "rimraf ./build && tsc",
7
- "start": "npm run build && node --experimental-specifier-resolution=node .build/index.js",
7
+ "start": "npm run build && node lib/index.js",
8
8
  "lint": "yarn eslint . --ext .ts",
9
9
  "lint:fix": "yarn eslint --fix . --ext .ts"
10
10
  },
@@ -12,6 +12,13 @@
12
12
  "type": "git",
13
13
  "url": "https://github.com/raikuxq/lab-ts-algorithms"
14
14
  },
15
+ "main": "./lib/exports.js",
16
+ "types": "./lib/exports.d.ts",
17
+ "files": [
18
+ "lib",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
15
22
  "devDependencies": {
16
23
  "@types/jest": "^26.0.14",
17
24
  "@types/node": "^14.0.24",
@@ -31,6 +38,5 @@
31
38
  "typescript": "^4.0.3"
32
39
  },
33
40
  "dependencies": {},
34
- "version": "1.1.2",
35
- "type": "module"
41
+ "version": "1.1.5"
36
42
  }