data-structure-typed 1.21.4 → 1.31.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 (560) hide show
  1. package/.auto-changelog +9 -0
  2. package/.auto-changelog-template.hbs +36 -0
  3. package/.eslintrc.js +61 -0
  4. package/.github/workflows/ci.yml +30 -0
  5. package/.prettierignore +6 -0
  6. package/.prettierrc.js +16 -0
  7. package/CHANGELOG.md +17 -0
  8. package/README.md +147 -95
  9. package/dist/data-structures/binary-tree/aa-tree.js +6 -2
  10. package/dist/data-structures/binary-tree/aa-tree.js.map +1 -0
  11. package/dist/data-structures/binary-tree/abstract-binary-tree.js +398 -672
  12. package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -0
  13. package/dist/data-structures/binary-tree/avl-tree.js +122 -151
  14. package/dist/data-structures/binary-tree/avl-tree.js.map +1 -0
  15. package/dist/data-structures/binary-tree/b-tree.js +6 -2
  16. package/dist/data-structures/binary-tree/b-tree.js.map +1 -0
  17. package/dist/data-structures/binary-tree/binary-indexed-tree.js +24 -54
  18. package/dist/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
  19. package/dist/data-structures/binary-tree/binary-tree.js +31 -32
  20. package/dist/data-structures/binary-tree/binary-tree.js.map +1 -0
  21. package/dist/data-structures/binary-tree/bst.js +266 -208
  22. package/dist/data-structures/binary-tree/bst.js.map +1 -0
  23. package/dist/data-structures/binary-tree/index.js +1 -0
  24. package/dist/data-structures/binary-tree/index.js.map +1 -0
  25. package/dist/data-structures/binary-tree/rb-tree.js +46 -37
  26. package/dist/data-structures/binary-tree/rb-tree.js.map +1 -0
  27. package/dist/data-structures/binary-tree/segment-tree.js +124 -127
  28. package/dist/data-structures/binary-tree/segment-tree.js.map +1 -0
  29. package/dist/data-structures/binary-tree/splay-tree.js +6 -2
  30. package/dist/data-structures/binary-tree/splay-tree.js.map +1 -0
  31. package/dist/data-structures/binary-tree/tree-multiset.js +227 -354
  32. package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -0
  33. package/dist/data-structures/binary-tree/two-three-tree.js +6 -2
  34. package/dist/data-structures/binary-tree/two-three-tree.js.map +1 -0
  35. package/dist/data-structures/graph/abstract-graph.js +582 -609
  36. package/dist/data-structures/graph/abstract-graph.js.map +1 -0
  37. package/dist/data-structures/graph/directed-graph.js +276 -312
  38. package/dist/data-structures/graph/directed-graph.js.map +1 -0
  39. package/dist/data-structures/graph/index.js +1 -0
  40. package/dist/data-structures/graph/index.js.map +1 -0
  41. package/dist/data-structures/graph/map-graph.js +88 -100
  42. package/dist/data-structures/graph/map-graph.js.map +1 -0
  43. package/dist/data-structures/graph/undirected-graph.js +180 -195
  44. package/dist/data-structures/graph/undirected-graph.js.map +1 -0
  45. package/dist/data-structures/hash/coordinate-map.js +46 -58
  46. package/dist/data-structures/hash/coordinate-map.js.map +1 -0
  47. package/dist/data-structures/hash/coordinate-set.js +43 -48
  48. package/dist/data-structures/hash/coordinate-set.js.map +1 -0
  49. package/dist/data-structures/hash/hash-table.js +6 -2
  50. package/dist/data-structures/hash/hash-table.js.map +1 -0
  51. package/dist/data-structures/hash/index.js +1 -0
  52. package/dist/data-structures/hash/index.js.map +1 -0
  53. package/dist/data-structures/hash/pair.js +6 -2
  54. package/dist/data-structures/hash/pair.js.map +1 -0
  55. package/dist/data-structures/hash/tree-map.js +6 -2
  56. package/dist/data-structures/hash/tree-map.js.map +1 -0
  57. package/dist/data-structures/hash/tree-set.js +6 -2
  58. package/dist/data-structures/hash/tree-set.js.map +1 -0
  59. package/dist/data-structures/heap/heap.js +83 -120
  60. package/dist/data-structures/heap/heap.js.map +1 -0
  61. package/dist/data-structures/heap/index.js +1 -0
  62. package/dist/data-structures/heap/index.js.map +1 -0
  63. package/dist/data-structures/heap/max-heap.js +27 -24
  64. package/dist/data-structures/heap/max-heap.js.map +1 -0
  65. package/dist/data-structures/heap/min-heap.js +27 -25
  66. package/dist/data-structures/heap/min-heap.js.map +1 -0
  67. package/dist/data-structures/index.js +1 -0
  68. package/dist/data-structures/index.js.map +1 -0
  69. package/dist/data-structures/linked-list/doubly-linked-list.js +202 -307
  70. package/dist/data-structures/linked-list/doubly-linked-list.js.map +1 -0
  71. package/dist/data-structures/linked-list/index.js +1 -0
  72. package/dist/data-structures/linked-list/index.js.map +1 -0
  73. package/dist/data-structures/linked-list/singly-linked-list.js +223 -251
  74. package/dist/data-structures/linked-list/singly-linked-list.js.map +1 -0
  75. package/dist/data-structures/linked-list/skip-linked-list.js +6 -2
  76. package/dist/data-structures/linked-list/skip-linked-list.js.map +1 -0
  77. package/dist/data-structures/matrix/index.js +1 -0
  78. package/dist/data-structures/matrix/index.js.map +1 -0
  79. package/dist/data-structures/matrix/matrix.js +9 -22
  80. package/dist/data-structures/matrix/matrix.js.map +1 -0
  81. package/dist/data-structures/matrix/matrix2d.js +75 -149
  82. package/dist/data-structures/matrix/matrix2d.js.map +1 -0
  83. package/dist/data-structures/matrix/navigator.js +38 -46
  84. package/dist/data-structures/matrix/navigator.js.map +1 -0
  85. package/dist/data-structures/matrix/vector2d.js +90 -254
  86. package/dist/data-structures/matrix/vector2d.js.map +1 -0
  87. package/dist/data-structures/priority-queue/index.js +1 -0
  88. package/dist/data-structures/priority-queue/index.js.map +1 -0
  89. package/dist/data-structures/priority-queue/max-priority-queue.js +47 -32
  90. package/dist/data-structures/priority-queue/max-priority-queue.js.map +1 -0
  91. package/dist/data-structures/priority-queue/min-priority-queue.js +47 -33
  92. package/dist/data-structures/priority-queue/min-priority-queue.js.map +1 -0
  93. package/dist/data-structures/priority-queue/priority-queue.js +150 -241
  94. package/dist/data-structures/priority-queue/priority-queue.js.map +1 -0
  95. package/dist/data-structures/queue/deque.js +130 -162
  96. package/dist/data-structures/queue/deque.js.map +1 -0
  97. package/dist/data-structures/queue/index.js +1 -0
  98. package/dist/data-structures/queue/index.js.map +1 -0
  99. package/dist/data-structures/queue/queue.js +181 -100
  100. package/dist/data-structures/queue/queue.js.map +1 -0
  101. package/dist/data-structures/stack/index.js +1 -0
  102. package/dist/data-structures/stack/index.js.map +1 -0
  103. package/dist/data-structures/stack/stack.js +23 -71
  104. package/dist/data-structures/stack/stack.js.map +1 -0
  105. package/dist/data-structures/tree/index.js +1 -0
  106. package/dist/data-structures/tree/index.js.map +1 -0
  107. package/dist/data-structures/tree/tree.js +46 -33
  108. package/dist/data-structures/tree/tree.js.map +1 -0
  109. package/dist/data-structures/trie/index.js +1 -0
  110. package/dist/data-structures/trie/index.js.map +1 -0
  111. package/dist/data-structures/trie/trie.js +201 -129
  112. package/dist/data-structures/trie/trie.js.map +1 -0
  113. package/dist/index.js +1 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/interfaces/abstract-binary-tree.js +1 -0
  116. package/dist/interfaces/abstract-binary-tree.js.map +1 -0
  117. package/dist/interfaces/abstract-graph.js +1 -0
  118. package/dist/interfaces/abstract-graph.js.map +1 -0
  119. package/dist/interfaces/avl-tree.js +1 -0
  120. package/dist/interfaces/avl-tree.js.map +1 -0
  121. package/dist/interfaces/binary-tree.js +1 -0
  122. package/dist/interfaces/binary-tree.js.map +1 -0
  123. package/dist/interfaces/bst.js +1 -0
  124. package/dist/interfaces/bst.js.map +1 -0
  125. package/dist/interfaces/directed-graph.js +1 -0
  126. package/dist/interfaces/directed-graph.js.map +1 -0
  127. package/dist/interfaces/doubly-linked-list.js +1 -0
  128. package/dist/interfaces/doubly-linked-list.js.map +1 -0
  129. package/dist/interfaces/heap.js +1 -0
  130. package/dist/interfaces/heap.js.map +1 -0
  131. package/dist/interfaces/index.js +1 -0
  132. package/dist/interfaces/index.js.map +1 -0
  133. package/dist/interfaces/navigator.js +1 -0
  134. package/dist/interfaces/navigator.js.map +1 -0
  135. package/dist/interfaces/priority-queue.js +1 -0
  136. package/dist/interfaces/priority-queue.js.map +1 -0
  137. package/dist/interfaces/rb-tree.js +1 -0
  138. package/dist/interfaces/rb-tree.js.map +1 -0
  139. package/dist/interfaces/segment-tree.js +1 -0
  140. package/dist/interfaces/segment-tree.js.map +1 -0
  141. package/dist/interfaces/singly-linked-list.js +1 -0
  142. package/dist/interfaces/singly-linked-list.js.map +1 -0
  143. package/dist/interfaces/tree-multiset.js +1 -0
  144. package/dist/interfaces/tree-multiset.js.map +1 -0
  145. package/dist/interfaces/undirected-graph.js +1 -0
  146. package/dist/interfaces/undirected-graph.js.map +1 -0
  147. package/dist/types/data-structures/abstract-binary-tree.js +1 -7
  148. package/dist/types/data-structures/abstract-binary-tree.js.map +1 -0
  149. package/dist/types/data-structures/abstract-graph.js +1 -0
  150. package/dist/types/data-structures/abstract-graph.js.map +1 -0
  151. package/dist/types/data-structures/avl-tree.js +1 -0
  152. package/dist/types/data-structures/avl-tree.js.map +1 -0
  153. package/dist/types/data-structures/binary-tree.js +1 -0
  154. package/dist/types/data-structures/binary-tree.js.map +1 -0
  155. package/dist/types/data-structures/bst.js +1 -0
  156. package/dist/types/data-structures/bst.js.map +1 -0
  157. package/dist/types/data-structures/directed-graph.js +1 -0
  158. package/dist/types/data-structures/directed-graph.js.map +1 -0
  159. package/dist/types/data-structures/doubly-linked-list.js +1 -0
  160. package/dist/types/data-structures/doubly-linked-list.js.map +1 -0
  161. package/dist/types/data-structures/heap.js +1 -0
  162. package/dist/types/data-structures/heap.js.map +1 -0
  163. package/dist/types/data-structures/index.js +1 -0
  164. package/dist/types/data-structures/index.js.map +1 -0
  165. package/dist/types/data-structures/map-graph.js +1 -0
  166. package/dist/types/data-structures/map-graph.js.map +1 -0
  167. package/dist/types/data-structures/navigator.js +1 -0
  168. package/dist/types/data-structures/navigator.js.map +1 -0
  169. package/dist/types/data-structures/priority-queue.js +1 -0
  170. package/dist/types/data-structures/priority-queue.js.map +1 -0
  171. package/dist/types/data-structures/rb-tree.js +1 -0
  172. package/dist/types/data-structures/rb-tree.js.map +1 -0
  173. package/dist/types/data-structures/segment-tree.js +1 -0
  174. package/dist/types/data-structures/segment-tree.js.map +1 -0
  175. package/dist/types/data-structures/singly-linked-list.js +1 -0
  176. package/dist/types/data-structures/singly-linked-list.js.map +1 -0
  177. package/dist/types/data-structures/tree-multiset.js +1 -0
  178. package/dist/types/data-structures/tree-multiset.js.map +1 -0
  179. package/dist/types/helpers.js +1 -0
  180. package/dist/types/helpers.js.map +1 -0
  181. package/dist/types/index.js +1 -0
  182. package/dist/types/index.js.map +1 -0
  183. package/dist/types/utils/index.js +1 -0
  184. package/dist/types/utils/index.js.map +1 -0
  185. package/dist/types/utils/utils.js +1 -0
  186. package/dist/types/utils/utils.js.map +1 -0
  187. package/dist/types/utils/validate-type.js +1 -0
  188. package/dist/types/utils/validate-type.js.map +1 -0
  189. package/dist/utils/index.js +1 -0
  190. package/dist/utils/index.js.map +1 -0
  191. package/dist/utils/utils.js +108 -22
  192. package/dist/utils/utils.js.map +1 -0
  193. package/docs/.nojekyll +1 -0
  194. package/docs/assets/highlight.css +127 -0
  195. package/docs/assets/main.js +58 -0
  196. package/docs/assets/search.js +1 -0
  197. package/docs/assets/style.css +1367 -0
  198. package/docs/classes/AVLTree.html +2259 -0
  199. package/docs/classes/AVLTreeNode.html +399 -0
  200. package/docs/classes/AaTree.html +202 -0
  201. package/docs/classes/AbstractBinaryTree.html +1913 -0
  202. package/docs/classes/AbstractBinaryTreeNode.html +441 -0
  203. package/docs/classes/AbstractEdge.html +345 -0
  204. package/docs/classes/AbstractGraph.html +1105 -0
  205. package/docs/classes/AbstractVertex.html +299 -0
  206. package/docs/classes/ArrayDeque.html +469 -0
  207. package/docs/classes/BST.html +2103 -0
  208. package/docs/classes/BSTNode.html +400 -0
  209. package/docs/classes/BTree.html +202 -0
  210. package/docs/classes/BinaryIndexedTree.html +371 -0
  211. package/docs/classes/BinaryTree.html +1944 -0
  212. package/docs/classes/BinaryTreeNode.html +399 -0
  213. package/docs/classes/Character.html +250 -0
  214. package/docs/classes/CoordinateMap.html +513 -0
  215. package/docs/classes/CoordinateSet.html +474 -0
  216. package/docs/classes/Deque.html +1005 -0
  217. package/docs/classes/DirectedEdge.html +404 -0
  218. package/docs/classes/DirectedGraph.html +1530 -0
  219. package/docs/classes/DirectedVertex.html +286 -0
  220. package/docs/classes/DoublyLinkedList.html +998 -0
  221. package/docs/classes/DoublyLinkedListNode.html +327 -0
  222. package/docs/classes/HashTable.html +202 -0
  223. package/docs/classes/Heap.html +647 -0
  224. package/docs/classes/HeapItem.html +296 -0
  225. package/docs/classes/LinkedListQueue.html +884 -0
  226. package/docs/classes/MapEdge.html +391 -0
  227. package/docs/classes/MapGraph.html +1583 -0
  228. package/docs/classes/MapVertex.html +356 -0
  229. package/docs/classes/Matrix2D.html +532 -0
  230. package/docs/classes/MatrixNTI2D.html +270 -0
  231. package/docs/classes/MaxHeap.html +671 -0
  232. package/docs/classes/MaxPriorityQueue.html +866 -0
  233. package/docs/classes/MinHeap.html +672 -0
  234. package/docs/classes/MinPriorityQueue.html +868 -0
  235. package/docs/classes/Navigator.html +343 -0
  236. package/docs/classes/ObjectDeque.html +527 -0
  237. package/docs/classes/Pair.html +202 -0
  238. package/docs/classes/PriorityQueue.html +790 -0
  239. package/docs/classes/Queue.html +521 -0
  240. package/docs/classes/RBTree.html +2101 -0
  241. package/docs/classes/RBTreeNode.html +431 -0
  242. package/docs/classes/SegmentTree.html +464 -0
  243. package/docs/classes/SegmentTreeNode.html +387 -0
  244. package/docs/classes/SinglyLinkedList.html +830 -0
  245. package/docs/classes/SinglyLinkedListNode.html +300 -0
  246. package/docs/classes/SkipLinkedList.html +202 -0
  247. package/docs/classes/SplayTree.html +202 -0
  248. package/docs/classes/Stack.html +398 -0
  249. package/docs/classes/TreeMap.html +202 -0
  250. package/docs/classes/TreeMultiset.html +2587 -0
  251. package/docs/classes/TreeMultisetNode.html +447 -0
  252. package/docs/classes/TreeNode.html +344 -0
  253. package/docs/classes/TreeSet.html +202 -0
  254. package/docs/classes/Trie.html +402 -0
  255. package/docs/classes/TrieNode.html +310 -0
  256. package/docs/classes/TwoThreeTree.html +202 -0
  257. package/docs/classes/UndirectedEdge.html +374 -0
  258. package/docs/classes/UndirectedGraph.html +1285 -0
  259. package/docs/classes/UndirectedVertex.html +284 -0
  260. package/docs/classes/Vector2D.html +835 -0
  261. package/docs/enums/CP.html +211 -0
  262. package/docs/enums/FamilyPosition.html +239 -0
  263. package/docs/enums/LoopType.html +212 -0
  264. package/docs/enums/RBColor.html +204 -0
  265. package/docs/enums/TopologicalProperty.html +211 -0
  266. package/docs/functions/arrayRemove.html +208 -0
  267. package/docs/functions/isThunk.html +186 -0
  268. package/docs/functions/toThunk.html +186 -0
  269. package/docs/functions/trampoline.html +186 -0
  270. package/docs/functions/trampolineAsync.html +186 -0
  271. package/docs/functions/uuidV4.html +181 -0
  272. package/docs/index.html +693 -0
  273. package/docs/interfaces/IAVLTree.html +1245 -0
  274. package/docs/interfaces/IAbstractBinaryTree.html +1101 -0
  275. package/docs/interfaces/IAbstractBinaryTreeNode.html +335 -0
  276. package/docs/interfaces/IAbstractGraph.html +433 -0
  277. package/docs/interfaces/IBST.html +1245 -0
  278. package/docs/interfaces/IDirectedGraph.html +570 -0
  279. package/docs/interfaces/IRBTree.html +1247 -0
  280. package/docs/interfaces/IUNDirectedGraph.html +463 -0
  281. package/docs/modules.html +328 -0
  282. package/docs/types/AVLTreeNodeNested.html +182 -0
  283. package/docs/types/AVLTreeOptions.html +180 -0
  284. package/docs/types/AbstractBinaryTreeNodeNested.html +182 -0
  285. package/docs/types/AbstractBinaryTreeNodeProperties.html +182 -0
  286. package/docs/types/AbstractBinaryTreeNodeProperty.html +182 -0
  287. package/docs/types/AbstractBinaryTreeOptions.html +182 -0
  288. package/docs/types/BSTComparator.html +192 -0
  289. package/docs/types/BSTNodeNested.html +182 -0
  290. package/docs/types/BSTOptions.html +182 -0
  291. package/docs/types/BinaryTreeDeletedResult.html +189 -0
  292. package/docs/types/BinaryTreeNodeId.html +177 -0
  293. package/docs/types/BinaryTreeNodeNested.html +182 -0
  294. package/docs/types/BinaryTreeNodePropertyName.html +177 -0
  295. package/docs/types/BinaryTreeOptions.html +180 -0
  296. package/docs/types/DFSOrderPattern.html +177 -0
  297. package/docs/types/DijkstraResult.html +199 -0
  298. package/docs/types/Direction.html +177 -0
  299. package/docs/types/DummyAny.html +190 -0
  300. package/docs/types/EdgeId.html +177 -0
  301. package/docs/types/HeapOptions.html +198 -0
  302. package/docs/types/IAVLTreeNode.html +184 -0
  303. package/docs/types/IBSTNode.html +184 -0
  304. package/docs/types/IBinaryTree.html +182 -0
  305. package/docs/types/IBinaryTreeNode.html +184 -0
  306. package/docs/types/IRBTreeNode.html +184 -0
  307. package/docs/types/ITreeMultiset.html +182 -0
  308. package/docs/types/ITreeMultisetNode.html +184 -0
  309. package/docs/types/KeyValueObject.html +182 -0
  310. package/docs/types/KeyValueObjectWithId.html +184 -0
  311. package/docs/types/MapGraphCoordinate.html +177 -0
  312. package/docs/types/NavigatorParams.html +211 -0
  313. package/docs/types/NodeOrPropertyName.html +177 -0
  314. package/docs/types/NonNumberNonObjectButDefined.html +177 -0
  315. package/docs/types/ObjectWithNonNumberId.html +184 -0
  316. package/docs/types/ObjectWithNumberId.html +184 -0
  317. package/docs/types/ObjectWithoutId.html +177 -0
  318. package/docs/types/PriorityQueueComparator.html +197 -0
  319. package/docs/types/PriorityQueueDFSOrderPattern.html +177 -0
  320. package/docs/types/PriorityQueueOptions.html +191 -0
  321. package/docs/types/RBTreeNodeNested.html +182 -0
  322. package/docs/types/RBTreeOptions.html +180 -0
  323. package/docs/types/RestrictValById.html +177 -0
  324. package/docs/types/SegmentTreeNodeVal.html +177 -0
  325. package/docs/types/SpecifyOptional.html +184 -0
  326. package/docs/types/Thunk.html +185 -0
  327. package/docs/types/ToThunkFn.html +185 -0
  328. package/docs/types/TopologicalStatus.html +177 -0
  329. package/docs/types/TreeMultisetNodeNested.html +182 -0
  330. package/docs/types/TreeMultisetOptions.html +180 -0
  331. package/docs/types/TrlAsyncFn.html +190 -0
  332. package/docs/types/TrlFn.html +190 -0
  333. package/docs/types/Turning.html +177 -0
  334. package/docs/types/VertexId.html +177 -0
  335. package/docs/variables/THUNK_SYMBOL.html +177 -0
  336. package/jest.config.js +5 -0
  337. package/lib/data-structures/binary-tree/aa-tree.js +2 -0
  338. package/{dist → lib}/data-structures/binary-tree/abstract-binary-tree.d.ts +25 -20
  339. package/lib/data-structures/binary-tree/abstract-binary-tree.js +1307 -0
  340. package/{dist → lib}/data-structures/binary-tree/avl-tree.d.ts +12 -12
  341. package/lib/data-structures/binary-tree/avl-tree.js +311 -0
  342. package/lib/data-structures/binary-tree/b-tree.js +2 -0
  343. package/lib/data-structures/binary-tree/binary-indexed-tree.js +69 -0
  344. package/lib/data-structures/binary-tree/binary-tree.js +35 -0
  345. package/{dist → lib}/data-structures/binary-tree/bst.d.ts +19 -8
  346. package/lib/data-structures/binary-tree/bst.js +551 -0
  347. package/lib/data-structures/binary-tree/index.js +12 -0
  348. package/{dist → lib}/data-structures/binary-tree/rb-tree.d.ts +0 -6
  349. package/lib/data-structures/binary-tree/rb-tree.js +22 -0
  350. package/lib/data-structures/binary-tree/segment-tree.js +210 -0
  351. package/lib/data-structures/binary-tree/splay-tree.js +2 -0
  352. package/{dist → lib}/data-structures/binary-tree/tree-multiset.d.ts +20 -23
  353. package/lib/data-structures/binary-tree/tree-multiset.js +673 -0
  354. package/lib/data-structures/binary-tree/two-three-tree.js +2 -0
  355. package/lib/data-structures/graph/abstract-graph.js +918 -0
  356. package/lib/data-structures/graph/directed-graph.js +416 -0
  357. package/lib/data-structures/graph/index.js +4 -0
  358. package/lib/data-structures/graph/map-graph.js +105 -0
  359. package/lib/data-structures/graph/undirected-graph.js +246 -0
  360. package/lib/data-structures/hash/coordinate-map.js +61 -0
  361. package/lib/data-structures/hash/coordinate-set.js +51 -0
  362. package/lib/data-structures/hash/hash-table.js +2 -0
  363. package/lib/data-structures/hash/index.js +6 -0
  364. package/lib/data-structures/hash/pair.js +2 -0
  365. package/lib/data-structures/hash/tree-map.js +2 -0
  366. package/lib/data-structures/hash/tree-set.js +2 -0
  367. package/lib/data-structures/heap/heap.js +152 -0
  368. package/lib/data-structures/heap/index.js +3 -0
  369. package/lib/data-structures/heap/max-heap.js +26 -0
  370. package/lib/data-structures/heap/min-heap.js +27 -0
  371. package/lib/data-structures/index.js +11 -0
  372. package/{dist → lib}/data-structures/linked-list/doubly-linked-list.d.ts +5 -5
  373. package/lib/data-structures/linked-list/doubly-linked-list.js +521 -0
  374. package/lib/data-structures/linked-list/index.js +3 -0
  375. package/{dist → lib}/data-structures/linked-list/singly-linked-list.d.ts +6 -5
  376. package/lib/data-structures/linked-list/singly-linked-list.js +443 -0
  377. package/lib/data-structures/linked-list/skip-linked-list.js +2 -0
  378. package/lib/data-structures/matrix/index.js +4 -0
  379. package/lib/data-structures/matrix/matrix.js +24 -0
  380. package/lib/data-structures/matrix/matrix2d.js +195 -0
  381. package/lib/data-structures/matrix/navigator.js +101 -0
  382. package/lib/data-structures/matrix/vector2d.js +287 -0
  383. package/lib/data-structures/priority-queue/index.js +3 -0
  384. package/lib/data-structures/priority-queue/max-priority-queue.js +39 -0
  385. package/lib/data-structures/priority-queue/min-priority-queue.js +40 -0
  386. package/lib/data-structures/priority-queue/priority-queue.js +317 -0
  387. package/{dist → lib}/data-structures/queue/deque.d.ts +45 -0
  388. package/lib/data-structures/queue/deque.js +270 -0
  389. package/lib/data-structures/queue/index.js +2 -0
  390. package/{dist → lib}/data-structures/queue/queue.d.ts +47 -13
  391. package/lib/data-structures/queue/queue.js +165 -0
  392. package/lib/data-structures/stack/index.js +1 -0
  393. package/lib/data-structures/stack/stack.js +87 -0
  394. package/lib/data-structures/tree/index.js +1 -0
  395. package/lib/data-structures/tree/tree.js +56 -0
  396. package/lib/data-structures/trie/index.js +1 -0
  397. package/lib/data-structures/trie/trie.js +205 -0
  398. package/lib/index.js +4 -0
  399. package/{dist → lib}/interfaces/avl-tree.d.ts +1 -9
  400. package/lib/interfaces/binary-tree.d.ts +4 -0
  401. package/{dist → lib}/interfaces/bst.d.ts +1 -2
  402. package/lib/interfaces/heap.js +1 -0
  403. package/lib/interfaces/index.js +15 -0
  404. package/lib/interfaces/navigator.d.ts +1 -0
  405. package/lib/interfaces/navigator.js +1 -0
  406. package/lib/interfaces/priority-queue.d.ts +1 -0
  407. package/lib/interfaces/priority-queue.js +1 -0
  408. package/{dist → lib}/interfaces/rb-tree.d.ts +1 -2
  409. package/lib/interfaces/rb-tree.js +1 -0
  410. package/lib/interfaces/segment-tree.d.ts +1 -0
  411. package/lib/interfaces/segment-tree.js +1 -0
  412. package/lib/interfaces/singly-linked-list.d.ts +1 -0
  413. package/lib/interfaces/singly-linked-list.js +1 -0
  414. package/lib/interfaces/tree-multiset.d.ts +5 -0
  415. package/lib/interfaces/tree-multiset.js +1 -0
  416. package/lib/interfaces/undirected-graph.js +1 -0
  417. package/{dist → lib}/types/data-structures/abstract-binary-tree.d.ts +1 -1
  418. package/lib/types/data-structures/abstract-binary-tree.js +22 -0
  419. package/lib/types/data-structures/abstract-graph.js +1 -0
  420. package/{dist → lib}/types/data-structures/avl-tree.d.ts +1 -1
  421. package/lib/types/data-structures/avl-tree.js +1 -0
  422. package/lib/types/data-structures/binary-tree.js +1 -0
  423. package/lib/types/data-structures/bst.js +6 -0
  424. package/lib/types/data-structures/directed-graph.js +6 -0
  425. package/lib/types/data-structures/doubly-linked-list.d.ts +1 -0
  426. package/lib/types/data-structures/doubly-linked-list.js +1 -0
  427. package/lib/types/data-structures/heap.js +1 -0
  428. package/lib/types/data-structures/index.js +15 -0
  429. package/lib/types/data-structures/map-graph.js +1 -0
  430. package/lib/types/data-structures/navigator.js +1 -0
  431. package/lib/types/data-structures/priority-queue.js +1 -0
  432. package/lib/types/data-structures/rb-tree.js +5 -0
  433. package/lib/types/data-structures/segment-tree.js +1 -0
  434. package/lib/types/data-structures/singly-linked-list.d.ts +1 -0
  435. package/lib/types/data-structures/singly-linked-list.js +1 -0
  436. package/lib/types/data-structures/tree-multiset.js +1 -0
  437. package/lib/types/helpers.d.ts +1 -0
  438. package/lib/types/helpers.js +1 -0
  439. package/lib/types/index.js +3 -0
  440. package/lib/types/utils/index.js +2 -0
  441. package/{dist → lib}/types/utils/utils.d.ts +1 -1
  442. package/lib/types/utils/utils.js +1 -0
  443. package/{dist → lib}/types/utils/validate-type.d.ts +1 -1
  444. package/lib/types/utils/validate-type.js +1 -0
  445. package/lib/utils/index.js +1 -0
  446. package/lib/utils/utils.js +57 -0
  447. package/package.json +147 -56
  448. package/rename_clear_files.sh +29 -0
  449. package/test/integration/avl-tree.test.ts +111 -0
  450. package/test/integration/bst.test.ts +371 -0
  451. package/test/integration/heap.test.js +19 -0
  452. package/test/integration/index.html +44 -0
  453. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +111 -0
  454. package/test/unit/data-structures/binary-tree/bst.test.ts +371 -0
  455. package/test/unit/data-structures/binary-tree/overall.test.ts +57 -0
  456. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +405 -0
  457. package/test/unit/data-structures/graph/abstract-graph.test.ts +5 -0
  458. package/test/unit/data-structures/graph/directed-graph.test.ts +517 -0
  459. package/test/unit/data-structures/graph/index.ts +2 -0
  460. package/test/unit/data-structures/graph/map-graph.test.ts +46 -0
  461. package/test/unit/data-structures/graph/overall.test.ts +50 -0
  462. package/test/unit/data-structures/graph/undirected-graph.test.ts +60 -0
  463. package/test/unit/data-structures/heap/heap.test.ts +56 -0
  464. package/test/unit/data-structures/heap/max-heap.test.ts +42 -0
  465. package/test/unit/data-structures/heap/min-heap.test.ts +81 -0
  466. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +365 -0
  467. package/test/unit/data-structures/linked-list/index.ts +4 -0
  468. package/test/unit/data-structures/linked-list/linked-list.test.ts +37 -0
  469. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +401 -0
  470. package/test/unit/data-structures/linked-list/skip-linked-list.test.ts +13 -0
  471. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +106 -0
  472. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +105 -0
  473. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +27 -0
  474. package/test/unit/data-structures/queue/queue.test.ts +36 -0
  475. package/test/utils/index.ts +2 -0
  476. package/test/utils/magnitude.ts +21 -0
  477. package/test/utils/number.ts +3 -0
  478. package/tsconfig.build.json +33 -0
  479. package/tsconfig.json +38 -0
  480. package/umd/bundle.min.js +3 -0
  481. package/umd/bundle.min.js.map +1 -0
  482. package/webpack.config.js +28 -0
  483. package/dist/bundle.js +0 -2
  484. package/dist/interfaces/binary-tree.d.ts +0 -6
  485. package/dist/interfaces/tree-multiset.d.ts +0 -7
  486. /package/{dist → lib}/data-structures/binary-tree/aa-tree.d.ts +0 -0
  487. /package/{dist → lib}/data-structures/binary-tree/b-tree.d.ts +0 -0
  488. /package/{dist → lib}/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  489. /package/{dist → lib}/data-structures/binary-tree/binary-tree.d.ts +0 -0
  490. /package/{dist → lib}/data-structures/binary-tree/index.d.ts +0 -0
  491. /package/{dist → lib}/data-structures/binary-tree/segment-tree.d.ts +0 -0
  492. /package/{dist → lib}/data-structures/binary-tree/splay-tree.d.ts +0 -0
  493. /package/{dist → lib}/data-structures/binary-tree/two-three-tree.d.ts +0 -0
  494. /package/{dist → lib}/data-structures/graph/abstract-graph.d.ts +0 -0
  495. /package/{dist → lib}/data-structures/graph/directed-graph.d.ts +0 -0
  496. /package/{dist → lib}/data-structures/graph/index.d.ts +0 -0
  497. /package/{dist → lib}/data-structures/graph/map-graph.d.ts +0 -0
  498. /package/{dist → lib}/data-structures/graph/undirected-graph.d.ts +0 -0
  499. /package/{dist → lib}/data-structures/hash/coordinate-map.d.ts +0 -0
  500. /package/{dist → lib}/data-structures/hash/coordinate-set.d.ts +0 -0
  501. /package/{dist → lib}/data-structures/hash/hash-table.d.ts +0 -0
  502. /package/{dist → lib}/data-structures/hash/index.d.ts +0 -0
  503. /package/{dist → lib}/data-structures/hash/pair.d.ts +0 -0
  504. /package/{dist → lib}/data-structures/hash/tree-map.d.ts +0 -0
  505. /package/{dist → lib}/data-structures/hash/tree-set.d.ts +0 -0
  506. /package/{dist → lib}/data-structures/heap/heap.d.ts +0 -0
  507. /package/{dist → lib}/data-structures/heap/index.d.ts +0 -0
  508. /package/{dist → lib}/data-structures/heap/max-heap.d.ts +0 -0
  509. /package/{dist → lib}/data-structures/heap/min-heap.d.ts +0 -0
  510. /package/{dist → lib}/data-structures/index.d.ts +0 -0
  511. /package/{dist → lib}/data-structures/linked-list/index.d.ts +0 -0
  512. /package/{dist → lib}/data-structures/linked-list/skip-linked-list.d.ts +0 -0
  513. /package/{dist → lib}/data-structures/matrix/index.d.ts +0 -0
  514. /package/{dist → lib}/data-structures/matrix/matrix.d.ts +0 -0
  515. /package/{dist → lib}/data-structures/matrix/matrix2d.d.ts +0 -0
  516. /package/{dist → lib}/data-structures/matrix/navigator.d.ts +0 -0
  517. /package/{dist → lib}/data-structures/matrix/vector2d.d.ts +0 -0
  518. /package/{dist → lib}/data-structures/priority-queue/index.d.ts +0 -0
  519. /package/{dist → lib}/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
  520. /package/{dist → lib}/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
  521. /package/{dist → lib}/data-structures/priority-queue/priority-queue.d.ts +0 -0
  522. /package/{dist → lib}/data-structures/queue/index.d.ts +0 -0
  523. /package/{dist → lib}/data-structures/stack/index.d.ts +0 -0
  524. /package/{dist → lib}/data-structures/stack/stack.d.ts +0 -0
  525. /package/{dist → lib}/data-structures/tree/index.d.ts +0 -0
  526. /package/{dist → lib}/data-structures/tree/tree.d.ts +0 -0
  527. /package/{dist → lib}/data-structures/trie/index.d.ts +0 -0
  528. /package/{dist → lib}/data-structures/trie/trie.d.ts +0 -0
  529. /package/{dist → lib}/index.d.ts +0 -0
  530. /package/{dist → lib}/interfaces/abstract-binary-tree.d.ts +0 -0
  531. /package/{dist/interfaces/doubly-linked-list.d.ts → lib/interfaces/abstract-binary-tree.js} +0 -0
  532. /package/{dist → lib}/interfaces/abstract-graph.d.ts +0 -0
  533. /package/{dist/interfaces/heap.d.ts → lib/interfaces/abstract-graph.js} +0 -0
  534. /package/{dist/interfaces/navigator.d.ts → lib/interfaces/avl-tree.js} +0 -0
  535. /package/{dist/interfaces/priority-queue.d.ts → lib/interfaces/binary-tree.js} +0 -0
  536. /package/{dist/interfaces/segment-tree.d.ts → lib/interfaces/bst.js} +0 -0
  537. /package/{dist → lib}/interfaces/directed-graph.d.ts +0 -0
  538. /package/{dist/interfaces/singly-linked-list.d.ts → lib/interfaces/directed-graph.js} +0 -0
  539. /package/{dist/types/data-structures → lib/interfaces}/doubly-linked-list.d.ts +0 -0
  540. /package/{dist/types/data-structures/singly-linked-list.d.ts → lib/interfaces/doubly-linked-list.js} +0 -0
  541. /package/{dist/types/helpers.d.ts → lib/interfaces/heap.d.ts} +0 -0
  542. /package/{dist → lib}/interfaces/index.d.ts +0 -0
  543. /package/{dist → lib}/interfaces/undirected-graph.d.ts +0 -0
  544. /package/{dist → lib}/types/data-structures/abstract-graph.d.ts +0 -0
  545. /package/{dist → lib}/types/data-structures/binary-tree.d.ts +0 -0
  546. /package/{dist → lib}/types/data-structures/bst.d.ts +0 -0
  547. /package/{dist → lib}/types/data-structures/directed-graph.d.ts +0 -0
  548. /package/{dist → lib}/types/data-structures/heap.d.ts +0 -0
  549. /package/{dist → lib}/types/data-structures/index.d.ts +0 -0
  550. /package/{dist → lib}/types/data-structures/map-graph.d.ts +0 -0
  551. /package/{dist → lib}/types/data-structures/navigator.d.ts +0 -0
  552. /package/{dist → lib}/types/data-structures/priority-queue.d.ts +0 -0
  553. /package/{dist → lib}/types/data-structures/rb-tree.d.ts +0 -0
  554. /package/{dist → lib}/types/data-structures/segment-tree.d.ts +0 -0
  555. /package/{dist → lib}/types/data-structures/tree-multiset.d.ts +0 -0
  556. /package/{dist → lib}/types/index.d.ts +0 -0
  557. /package/{dist → lib}/types/utils/index.d.ts +0 -0
  558. /package/{dist → lib}/utils/index.d.ts +0 -0
  559. /package/{dist → lib}/utils/utils.d.ts +0 -0
  560. /package/{dist/bundle.js.LICENSE.txt → umd/bundle.min.js.LICENSE.txt} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singly-linked-list.js","sourceRoot":"","sources":["../../../src/data-structures/linked-list/singly-linked-list.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;IAME,8BAAY,GAAM;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAID,sBAAI,qCAAG;aAAP;YACE,OAAO,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC;aAED,UAAQ,KAAQ;YACd,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QACpB,CAAC;;;OAJA;IAQD,sBAAI,sCAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;aAED,UAAS,KAAqC;YAC5C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;;;OAJA;IAKH,2BAAC;AAAD,CAAC,AA9BD,IA8BC;AA9BY,oDAAoB;AAgCjC;IAIE;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;IAID,sBAAI,kCAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;aAED,UAAS,KAAqC;YAC5C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;;;OAJA;IAQD,sBAAI,kCAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;aAED,UAAS,KAAqC;YAC5C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;;;OAJA;IAQD,sBAAI,oCAAM;aAAV;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B;;;;;oBACM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;;;yBAEjB,OAAO;oBACZ,WAAM,OAAO,CAAC,GAAG,EAAA;;oBAAjB,SAAiB,CAAC;oBAClB,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;;;;;KAE1B;IACH,uBAAC;AAAD,CAAC,AA7cD,IA6cC;AA7cY,4CAAgB"}
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SkipLinkedList = void 0;
4
- class SkipLinkedList {
5
- }
4
+ var SkipLinkedList = (function () {
5
+ function SkipLinkedList() {
6
+ }
7
+ return SkipLinkedList;
8
+ }());
6
9
  exports.SkipLinkedList = SkipLinkedList;
10
+ //# sourceMappingURL=skip-linked-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skip-linked-list.js","sourceRoot":"","sources":["../../../src/data-structures/linked-list/skip-linked-list.ts"],"names":[],"mappings":";;;AAAA;IAAA;IAA6B,CAAC;IAAD,qBAAC;AAAD,CAAC,AAA9B,IAA8B;AAAjB,wCAAc"}
@@ -18,3 +18,4 @@ __exportStar(require("./matrix"), exports);
18
18
  __exportStar(require("./vector2d"), exports);
19
19
  __exportStar(require("./matrix2d"), exports);
20
20
  __exportStar(require("./navigator"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data-structures/matrix/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,6CAA2B;AAC3B,6CAA2B;AAC3B,8CAA4B"}
@@ -1,28 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MatrixNTI2D = void 0;
4
- /**
5
- * data-structure-typed
6
- *
7
- * @author Tyler Zeng
8
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
9
- * @license MIT License
10
- */
11
- // todo need to be improved
12
- class MatrixNTI2D {
13
- /**
14
- * The constructor creates a matrix with the specified number of rows and columns, and initializes all elements to a
15
- * given initial value or 0 if not provided.
16
- * @param options - An object containing the following properties:
17
- */
18
- constructor(options) {
19
- const { row, col, initialVal } = options;
20
- this._matrix = new Array(row).fill(undefined).map(() => new Array(col).fill(initialVal || 0));
4
+ var MatrixNTI2D = (function () {
5
+ function MatrixNTI2D(options) {
6
+ var row = options.row, col = options.col, initialVal = options.initialVal;
7
+ this._matrix = new Array(row).fill(undefined).map(function () { return new Array(col).fill(initialVal || 0); });
21
8
  }
22
- /* The `toArray` method returns the matrix as a two-dimensional array. It converts the internal representation of the
23
- matrix, which is an array of arrays, into a format that is more commonly used in JavaScript. */
24
- toArray() {
9
+ MatrixNTI2D.prototype.toArray = function () {
25
10
  return this._matrix;
26
- }
27
- }
11
+ };
12
+ return MatrixNTI2D;
13
+ }());
28
14
  exports.MatrixNTI2D = MatrixNTI2D;
15
+ //# sourceMappingURL=matrix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrix.js","sourceRoot":"","sources":["../../../src/data-structures/matrix/matrix.ts"],"names":[],"mappings":";;;AAQA;IAQE,qBAAY,OAAqD;QACvD,IAAA,GAAG,GAAsB,OAAO,IAA7B,EAAE,GAAG,GAAiB,OAAO,IAAxB,EAAE,UAAU,GAAK,OAAO,WAAZ,CAAa;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,cAAM,OAAA,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC,EAApC,CAAoC,CAAC,CAAC;IAChG,CAAC;IAID,6BAAO,GAAP;QACE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IACH,kBAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,kCAAW"}
@@ -1,25 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.Matrix2D = void 0;
7
- /**
8
- * data-structure-typed
9
- *
10
- * @author Tyler Zeng
11
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
12
- * @license MIT License
13
- */
14
- const vector2d_1 = __importDefault(require("./vector2d"));
15
- class Matrix2D {
16
- /**
17
- * The constructor function initializes a Matrix2D object with either a default identity matrix, or a provided matrix
18
- * or Vector2D object.
19
- * @param {number[][] | Vector2D} [value] - The `value` parameter can be either a 2D array of numbers (`number[][]`) or
20
- * an instance of the `Vector2D` class.
21
- */
22
- constructor(value) {
4
+ var vector2d_1 = require("./vector2d");
5
+ var Matrix2D = (function () {
6
+ function Matrix2D(value) {
23
7
  if (typeof value === 'undefined') {
24
8
  this._matrix = Matrix2D.identity;
25
9
  }
@@ -33,170 +17,112 @@ class Matrix2D {
33
17
  this._matrix = value;
34
18
  }
35
19
  }
36
- /**
37
- * The function returns a 2D array with three empty arrays.
38
- * @returns An empty 2-dimensional array with 3 empty arrays inside.
39
- */
40
- static get empty() {
41
- return [[], [], []];
42
- }
43
- /**
44
- * The above function returns a 3x3 identity matrix.
45
- * @returns The method is returning a 2-dimensional array of numbers representing the identity matrix.
46
- */
47
- static get identity() {
48
- return [
49
- [1, 0, 0],
50
- [0, 1, 0],
51
- [0, 0, 1]
52
- ];
53
- }
54
- /**
55
- * The function returns a two-dimensional array of numbers.
56
- * @returns The getter method is returning the value of the private variable `_matrix`, which is a two-dimensional
57
- * array of numbers.
58
- */
59
- get m() {
60
- return this._matrix;
61
- }
62
- /**
63
- * The function "toVector" returns a new Vector2D object with the values from the first and second elements of the
64
- * _matrix array.
65
- * @returns A new instance of the Vector2D class is being returned. The values of the returned vector are taken from
66
- * the first column of the matrix.
67
- */
68
- get toVector() {
69
- return new vector2d_1.default(this._matrix[0][0], this._matrix[1][0]);
70
- }
71
- /**
72
- * The function takes two 2D matrices as input and returns their sum as a new 2D matrix.
73
- * @param {Matrix2D} matrix1 - Matrix2D - The first matrix to be added.
74
- * @param {Matrix2D} matrix2 - The parameter `matrix2` is a Matrix2D object.
75
- * @returns a new instance of the Matrix2D class, which is created using the result array.
76
- */
77
- static add(matrix1, matrix2) {
78
- const result = Matrix2D.empty;
79
- for (let i = 0; i < 3; i++) {
80
- for (let j = 0; j < 3; j++) {
20
+ Object.defineProperty(Matrix2D, "empty", {
21
+ get: function () {
22
+ return [[], [], []];
23
+ },
24
+ enumerable: false,
25
+ configurable: true
26
+ });
27
+ Object.defineProperty(Matrix2D, "identity", {
28
+ get: function () {
29
+ return [
30
+ [1, 0, 0],
31
+ [0, 1, 0],
32
+ [0, 0, 1]
33
+ ];
34
+ },
35
+ enumerable: false,
36
+ configurable: true
37
+ });
38
+ Object.defineProperty(Matrix2D.prototype, "m", {
39
+ get: function () {
40
+ return this._matrix;
41
+ },
42
+ enumerable: false,
43
+ configurable: true
44
+ });
45
+ Object.defineProperty(Matrix2D.prototype, "toVector", {
46
+ get: function () {
47
+ return new vector2d_1.default(this._matrix[0][0], this._matrix[1][0]);
48
+ },
49
+ enumerable: false,
50
+ configurable: true
51
+ });
52
+ Matrix2D.add = function (matrix1, matrix2) {
53
+ var result = Matrix2D.empty;
54
+ for (var i = 0; i < 3; i++) {
55
+ for (var j = 0; j < 3; j++) {
81
56
  result[i][j] = matrix1.m[i][j] + matrix2.m[i][j];
82
57
  }
83
58
  }
84
59
  return new Matrix2D(result);
85
- }
86
- /**
87
- * The function subtracts two 2D matrices and returns the result as a new Matrix2D object.
88
- * @param {Matrix2D} matrix1 - Matrix2D - The first matrix to subtract from.
89
- * @param {Matrix2D} matrix2 - Matrix2D is a class representing a 2D matrix. It has a property `m` which is a 2D array
90
- * representing the matrix elements.
91
- * @returns a new instance of the Matrix2D class, which is created using the result array.
92
- */
93
- static subtract(matrix1, matrix2) {
94
- const result = Matrix2D.empty;
95
- for (let i = 0; i < 3; i++) {
96
- for (let j = 0; j < 3; j++) {
60
+ };
61
+ Matrix2D.subtract = function (matrix1, matrix2) {
62
+ var result = Matrix2D.empty;
63
+ for (var i = 0; i < 3; i++) {
64
+ for (var j = 0; j < 3; j++) {
97
65
  result[i][j] = matrix1.m[i][j] - matrix2.m[i][j];
98
66
  }
99
67
  }
100
68
  return new Matrix2D(result);
101
- }
102
- /**
103
- * The function multiplies two 2D matrices and returns the result as a new Matrix2D object.
104
- * @param {Matrix2D} matrix1 - A 2D matrix represented by the Matrix2D class.
105
- * @param {Matrix2D} matrix2 - The parameter `matrix2` is a 2D matrix of size 3x3.
106
- * @returns a new instance of the Matrix2D class, created using the result array.
107
- */
108
- static multiply(matrix1, matrix2) {
109
- const result = Matrix2D.empty;
110
- for (let i = 0; i < 3; i++) {
111
- for (let j = 0; j < 3; j++) {
69
+ };
70
+ Matrix2D.multiply = function (matrix1, matrix2) {
71
+ var result = Matrix2D.empty;
72
+ for (var i = 0; i < 3; i++) {
73
+ for (var j = 0; j < 3; j++) {
112
74
  result[i][j] = 0;
113
- for (let k = 0; k < 3; k++) {
75
+ for (var k = 0; k < 3; k++) {
114
76
  result[i][j] += matrix1.m[i][k] * matrix2.m[k][j];
115
77
  }
116
78
  }
117
79
  }
118
80
  return new Matrix2D(result);
119
- }
120
- /**
121
- * The function multiplies each element of a 2D matrix by a given value and returns the resulting matrix.
122
- * @param {Matrix2D} matrix - The `matrix` parameter is an instance of the `Matrix2D` class, which represents a 2D
123
- * matrix. It contains a property `m` that is a 2D array representing the matrix elements.
124
- * @param {number} value - The `value` parameter is a number that you want to multiply each element of the `matrix` by.
125
- * @returns a new instance of the Matrix2D class, which is created using the result array.
126
- */
127
- static multiplyByValue(matrix, value) {
128
- const result = Matrix2D.empty;
129
- for (let i = 0; i < 3; i++) {
130
- for (let j = 0; j < 3; j++) {
81
+ };
82
+ Matrix2D.multiplyByValue = function (matrix, value) {
83
+ var result = Matrix2D.empty;
84
+ for (var i = 0; i < 3; i++) {
85
+ for (var j = 0; j < 3; j++) {
131
86
  result[i][j] = matrix.m[i][j] * value;
132
87
  }
133
88
  }
134
89
  return new Matrix2D(result);
135
- }
136
- /**
137
- * The function multiplies a 2D matrix by a 2D vector and returns the result as a 2D vector.
138
- * @param {Matrix2D} matrix - The parameter "matrix" is of type Matrix2D. It represents a 2-dimensional matrix.
139
- * @param {Vector2D} vector - The "vector" parameter is a 2D vector, represented by an object of type Vector2D.
140
- * @returns a Vector2D.
141
- */
142
- static multiplyByVector(matrix, vector) {
90
+ };
91
+ Matrix2D.multiplyByVector = function (matrix, vector) {
143
92
  return Matrix2D.multiply(matrix, new Matrix2D(vector)).toVector;
144
- }
145
- /**
146
- * The function returns a 2D matrix that scales and flips a vector around the center of a given width and height.
147
- * @param {number} width - The width parameter represents the width of the view or the canvas. It is a number that
148
- * specifies the width in pixels or any other unit of measurement.
149
- * @param {number} height - The height parameter represents the height of the view or the canvas. It is used to
150
- * calculate the centerY value, which is the vertical center of the view.
151
- * @returns a Matrix2D object.
152
- */
153
- static view(width, height) {
154
- const scaleStep = 1; // Scale every vector * scaleStep
155
- const centerX = width / 2;
156
- const centerY = height / 2;
157
- const flipX = Math.cos(Math.PI); // rotate 180deg / 3.14radian around X-axis
93
+ };
94
+ Matrix2D.view = function (width, height) {
95
+ var scaleStep = 1;
96
+ var centerX = width / 2;
97
+ var centerY = height / 2;
98
+ var flipX = Math.cos(Math.PI);
158
99
  return new Matrix2D([
159
100
  [scaleStep, 0, centerX],
160
101
  [0, flipX * scaleStep, centerY],
161
102
  [0, 0, 1]
162
103
  ]);
163
- }
164
- /**
165
- * The function scales a matrix by a given factor.
166
- * @param {number} factor - The factor parameter is a number that represents the scaling factor by which the matrix
167
- * should be scaled.
168
- * @returns the result of multiplying a new instance of Matrix2D by the given factor.
169
- */
170
- static scale(factor) {
104
+ };
105
+ Matrix2D.scale = function (factor) {
171
106
  return Matrix2D.multiplyByValue(new Matrix2D(), factor);
172
- }
173
- /**
174
- * The function "rotate" takes an angle in radians and returns a 2D transformation matrix for rotating objects.
175
- * @param {number} radians - The "radians" parameter is the angle in radians by which you want to rotate an object.
176
- * @returns The code is returning a new instance of a Matrix2D object.
177
- */
178
- static rotate(radians) {
179
- const cos = Math.cos(radians);
180
- const sin = Math.sin(radians);
107
+ };
108
+ Matrix2D.rotate = function (radians) {
109
+ var cos = Math.cos(radians);
110
+ var sin = Math.sin(radians);
181
111
  return new Matrix2D([
182
112
  [cos, -sin, 0],
183
113
  [sin, cos, 0],
184
114
  [0, 0, 1]
185
115
  ]);
186
- }
187
- /**
188
- * The translate function takes a 2D vector and returns a 2D matrix that represents a translation transformation.
189
- * @param {Vector2D} vector - The parameter "vector" is of type Vector2D. It represents a 2D vector with components x
190
- * and y, and an optional w component.
191
- * @returns The method is returning a new instance of the Matrix2D class.
192
- */
193
- static translate(vector) {
116
+ };
117
+ Matrix2D.translate = function (vector) {
194
118
  return new Matrix2D([
195
119
  [1, 0, vector.x],
196
120
  [0, 1, vector.y],
197
121
  [0, 0, vector.w]
198
122
  ]);
199
- }
200
- }
123
+ };
124
+ return Matrix2D;
125
+ }());
201
126
  exports.Matrix2D = Matrix2D;
202
127
  exports.default = Matrix2D;
128
+ //# sourceMappingURL=matrix2d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrix2d.js","sourceRoot":"","sources":["../../../src/data-structures/matrix/matrix2d.ts"],"names":[],"mappings":";;;AAOA,uCAAkC;AAElC;IASE,kBAAY,KAA6B;QACvC,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC;SAClC;aAAM,IAAI,KAAK,YAAY,kBAAQ,EAAE;YACpC,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;YAC7B,IA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a,MAAc;QACzB,OAAO,QAAQ,CAAC,eAAe,CAAC,IAAI,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;IAOM,eAAM,GAAb,UAAc,OAAe;QAC3B,IAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE9B,OAAO,IAAI,QAAQ,CAAC;YAClB,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;YACd,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;YACb,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SACV,CAAC,CAAC;IACL,CAAC;IAQM,kBAAS,GAAhB,UAAiB,MAAgB;QAC/B,OAAO,IAAI,QAAQ,CAAC;YAClB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;YAChB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;YAChB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;SACjB,CAAC,CAAC;IACL,CAAC;IACH,eAAC;AAAD,CAAC,AAxMD,IAwMC;AAxMY,4BAAQ;AA0MrB,kBAAe,QAAQ,CAAC"}
@@ -1,28 +1,33 @@
1
1
  "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
2
18
  Object.defineProperty(exports, "__esModule", { value: true });
3
19
  exports.Navigator = exports.Character = void 0;
4
- class Character {
5
- /**
6
- * The constructor function takes in a direction and turning object and sets the direction and turn properties of the
7
- * Character class.
8
- * @param {Direction} direction - The direction parameter is used to specify the current direction of the character. It
9
- * can be any value that represents a direction, such as "north", "south", "east", or "west".
10
- * @param {Turning} turning - The `turning` parameter is an object that maps each direction to the corresponding
11
- * turning direction. It is used to determine the new direction when the character turns.
12
- */
13
- constructor(direction, turning) {
20
+ var Character = (function () {
21
+ function Character(direction, turning) {
14
22
  this.direction = direction;
15
- this.turn = () => new Character(turning[direction], turning);
23
+ this.turn = function () { return new Character(turning[direction], turning); };
16
24
  }
17
- }
25
+ return Character;
26
+ }());
18
27
  exports.Character = Character;
19
- class Navigator {
20
- /**
21
- * The constructor initializes the Navigator object with the given parameters and sets the current position as visited
22
- * in the matrix.
23
- * @param - - `matrix`: a 2D array representing the grid or map
24
- */
25
- constructor({ matrix, turning, onMove, init: { cur, charDir, VISITED } }) {
28
+ var Navigator = (function () {
29
+ function Navigator(_a) {
30
+ var matrix = _a.matrix, turning = _a.turning, onMove = _a.onMove, _b = _a.init, cur = _b.cur, charDir = _b.charDir, VISITED = _b.VISITED;
26
31
  this._matrix = matrix;
27
32
  this._cur = cur;
28
33
  this._character = new Character(charDir, turning);
@@ -31,13 +36,9 @@ class Navigator {
31
36
  this._VISITED = VISITED;
32
37
  this._matrix[this._cur[0]][this._cur[1]] = this._VISITED;
33
38
  }
34
- /**
35
- * The "start" function moves the character in its current direction until it encounters an obstacle, then it turns the
36
- * character and repeats the process.
37
- */
38
- start() {
39
+ Navigator.prototype.start = function () {
39
40
  while (this.check(this._character.direction) || this.check(this._character.turn().direction)) {
40
- const { direction } = this._character;
41
+ var direction = this._character.direction;
41
42
  if (this.check(direction)) {
42
43
  this.move(direction);
43
44
  }
@@ -45,17 +46,11 @@ class Navigator {
45
46
  this._character = this._character.turn();
46
47
  }
47
48
  }
48
- }
49
- /**
50
- * The function checks if there is a valid move in the specified direction in a matrix.
51
- * @param {Direction} direction - The direction parameter is a string that represents the direction in which to check.
52
- * It can be one of the following values: 'up', 'right', 'down', or 'left'.
53
- * @returns a boolean value.
54
- */
55
- check(direction) {
56
- let forward, row;
57
- const matrix = this._matrix;
58
- const [i, j] = this._cur;
49
+ };
50
+ Navigator.prototype.check = function (direction) {
51
+ var forward, row;
52
+ var matrix = this._matrix;
53
+ var _a = __read(this._cur, 2), i = _a[0], j = _a[1];
59
54
  switch (direction) {
60
55
  case 'up':
61
56
  row = matrix[i - 1];
@@ -77,13 +72,8 @@ class Navigator {
77
72
  break;
78
73
  }
79
74
  return forward !== undefined && forward !== this._VISITED;
80
- }
81
- /**
82
- * The `move` function updates the current position based on the given direction and updates the matrix accordingly.
83
- * @param {Direction} direction - The `direction` parameter is a string that represents the direction in which to move.
84
- * It can have one of the following values: 'up', 'right', 'down', or 'left'.
85
- */
86
- move(direction) {
75
+ };
76
+ Navigator.prototype.move = function (direction) {
87
77
  switch (direction) {
88
78
  case 'up':
89
79
  this._cur[0]--;
@@ -98,9 +88,11 @@ class Navigator {
98
88
  this._cur[1]--;
99
89
  break;
100
90
  }
101
- const [i, j] = this._cur;
91
+ var _a = __read(this._cur, 2), i = _a[0], j = _a[1];
102
92
  this._matrix[i][j] = this._VISITED;
103
93
  this.onMove && this.onMove(this._cur);
104
- }
105
- }
94
+ };
95
+ return Navigator;
96
+ }());
106
97
  exports.Navigator = Navigator;
98
+ //# sourceMappingURL=navigator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigator.js","sourceRoot":"","sources":["../../../src/data-structures/matrix/navigator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AASA;IAYE,mBAAY,SAAoB,EAAE,OAAgB;QAChD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,cAAM,OAAA,IAAI,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,EAA1C,CAA0C,CAAC;IAC/D,CAAC;IACH,gBAAC;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