data-structure-typed 1.21.4 → 1.32.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.
- package/.auto-changelog +9 -0
- package/.auto-changelog-template.hbs +36 -0
- package/.eslintrc.js +61 -0
- package/.gitattributes +112 -0
- package/.github/workflows/ci.yml +30 -0
- package/.prettierignore +6 -0
- package/.prettierrc.js +16 -0
- package/CHANGELOG.md +17 -0
- package/CODE-OF-CONDUCT.md +80 -0
- package/COMMANDS.md +28 -0
- package/README.md +147 -95
- package/SECURITY.md +15 -0
- package/coverage/clover.xml +3393 -0
- package/coverage/coverage-final.json +67 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +386 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/aa-tree.ts.html +88 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/abstract-binary-tree.ts.html +4966 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/avl-tree.ts.html +1015 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/b-tree.ts.html +88 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/binary-indexed-tree.ts.html +313 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/binary-tree.ts.html +226 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/bst.ts.html +1714 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/index.html +296 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/index.ts.html +121 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/rb-tree.ts.html +388 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/segment-tree.ts.html +811 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/splay-tree.ts.html +88 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/tree-multiset.ts.html +2185 -0
- package/coverage/lcov-report/src/data-structures/binary-tree/two-three-tree.ts.html +88 -0
- package/coverage/lcov-report/src/data-structures/graph/abstract-graph.ts.html +3205 -0
- package/coverage/lcov-report/src/data-structures/graph/directed-graph.ts.html +1495 -0
- package/coverage/lcov-report/src/data-structures/graph/index.html +176 -0
- package/coverage/lcov-report/src/data-structures/graph/index.ts.html +97 -0
- package/coverage/lcov-report/src/data-structures/graph/map-graph.ts.html +472 -0
- package/coverage/lcov-report/src/data-structures/graph/undirected-graph.ts.html +907 -0
- package/coverage/lcov-report/src/data-structures/hash/coordinate-map.ts.html +286 -0
- package/coverage/lcov-report/src/data-structures/hash/coordinate-set.ts.html +253 -0
- package/coverage/lcov-report/src/data-structures/hash/hash-table.ts.html +88 -0
- package/coverage/lcov-report/src/data-structures/hash/index.html +206 -0
- package/coverage/lcov-report/src/data-structures/hash/index.ts.html +103 -0
- package/coverage/lcov-report/src/data-structures/hash/pair.ts.html +88 -0
- package/coverage/lcov-report/src/data-structures/hash/tree-map.ts.html +88 -0
- package/coverage/lcov-report/src/data-structures/hash/tree-set.ts.html +88 -0
- package/coverage/lcov-report/src/data-structures/heap/heap.ts.html +721 -0
- package/coverage/lcov-report/src/data-structures/heap/index.html +161 -0
- package/coverage/lcov-report/src/data-structures/heap/index.ts.html +94 -0
- package/coverage/lcov-report/src/data-structures/heap/max-heap.ts.html +178 -0
- package/coverage/lcov-report/src/data-structures/heap/min-heap.ts.html +181 -0
- package/coverage/lcov-report/src/data-structures/index.html +116 -0
- package/coverage/lcov-report/src/data-structures/index.ts.html +118 -0
- package/coverage/lcov-report/src/data-structures/linked-list/doubly-linked-list.ts.html +1804 -0
- package/coverage/lcov-report/src/data-structures/linked-list/index.html +161 -0
- package/coverage/lcov-report/src/data-structures/linked-list/index.ts.html +94 -0
- package/coverage/lcov-report/src/data-structures/linked-list/singly-linked-list.ts.html +1588 -0
- package/coverage/lcov-report/src/data-structures/linked-list/skip-linked-list.ts.html +88 -0
- package/coverage/lcov-report/src/data-structures/matrix/index.html +176 -0
- package/coverage/lcov-report/src/data-structures/matrix/index.ts.html +97 -0
- package/coverage/lcov-report/src/data-structures/matrix/matrix.ts.html +166 -0
- package/coverage/lcov-report/src/data-structures/matrix/matrix2d.ts.html +721 -0
- package/coverage/lcov-report/src/data-structures/matrix/navigator.ts.html +448 -0
- package/coverage/lcov-report/src/data-structures/matrix/vector2d.ts.html +1033 -0
- package/coverage/lcov-report/src/data-structures/priority-queue/index.html +161 -0
- package/coverage/lcov-report/src/data-structures/priority-queue/index.ts.html +94 -0
- package/coverage/lcov-report/src/data-structures/priority-queue/max-priority-queue.ts.html +253 -0
- package/coverage/lcov-report/src/data-structures/priority-queue/min-priority-queue.ts.html +256 -0
- package/coverage/lcov-report/src/data-structures/priority-queue/priority-queue.ts.html +1162 -0
- package/coverage/lcov-report/src/data-structures/queue/deque.ts.html +976 -0
- package/coverage/lcov-report/src/data-structures/queue/index.html +146 -0
- package/coverage/lcov-report/src/data-structures/queue/index.ts.html +91 -0
- package/coverage/lcov-report/src/data-structures/queue/queue.ts.html +658 -0
- package/coverage/lcov-report/src/data-structures/stack/index.html +131 -0
- package/coverage/lcov-report/src/data-structures/stack/index.ts.html +88 -0
- package/coverage/lcov-report/src/data-structures/stack/stack.ts.html +379 -0
- package/coverage/lcov-report/src/data-structures/tree/index.html +131 -0
- package/coverage/lcov-report/src/data-structures/tree/index.ts.html +88 -0
- package/coverage/lcov-report/src/data-structures/tree/tree.ts.html +292 -0
- package/coverage/lcov-report/src/data-structures/trie/index.html +131 -0
- package/coverage/lcov-report/src/data-structures/trie/index.ts.html +88 -0
- package/coverage/lcov-report/src/data-structures/trie/trie.ts.html +760 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/index.ts.html +97 -0
- package/coverage/lcov-report/src/interfaces/index.html +116 -0
- package/coverage/lcov-report/src/interfaces/index.ts.html +130 -0
- package/coverage/lcov-report/src/types/data-structures/abstract-binary-tree.ts.html +235 -0
- package/coverage/lcov-report/src/types/data-structures/bst.ts.html +124 -0
- package/coverage/lcov-report/src/types/data-structures/directed-graph.ts.html +109 -0
- package/coverage/lcov-report/src/types/data-structures/index.html +176 -0
- package/coverage/lcov-report/src/types/data-structures/index.ts.html +130 -0
- package/coverage/lcov-report/src/types/data-structures/rb-tree.ts.html +106 -0
- package/coverage/lcov-report/src/types/index.html +116 -0
- package/coverage/lcov-report/src/types/index.ts.html +94 -0
- package/coverage/lcov-report/src/types/utils/index.html +116 -0
- package/coverage/lcov-report/src/types/utils/index.ts.html +91 -0
- package/coverage/lcov-report/src/utils/index.html +131 -0
- package/coverage/lcov-report/src/utils/index.ts.html +88 -0
- package/coverage/lcov-report/src/utils/utils.ts.html +322 -0
- package/coverage/lcov-report/test/utils/index.html +146 -0
- package/coverage/lcov-report/test/utils/index.ts.html +91 -0
- package/coverage/lcov-report/test/utils/magnitude.ts.html +148 -0
- package/coverage/lcov-report/test/utils/number.ts.html +94 -0
- package/coverage/lcov.info +6676 -0
- package/dist/data-structures/binary-tree/aa-tree.js +6 -2
- package/dist/data-structures/binary-tree/aa-tree.js.map +1 -0
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +398 -672
- package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -0
- package/dist/data-structures/binary-tree/avl-tree.js +122 -151
- package/dist/data-structures/binary-tree/avl-tree.js.map +1 -0
- package/dist/data-structures/binary-tree/b-tree.js +6 -2
- package/dist/data-structures/binary-tree/b-tree.js.map +1 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +24 -54
- package/dist/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
- package/dist/data-structures/binary-tree/binary-tree.js +31 -32
- package/dist/data-structures/binary-tree/binary-tree.js.map +1 -0
- package/dist/data-structures/binary-tree/bst.js +266 -208
- package/dist/data-structures/binary-tree/bst.js.map +1 -0
- package/dist/data-structures/binary-tree/index.js +1 -0
- package/dist/data-structures/binary-tree/index.js.map +1 -0
- package/dist/data-structures/binary-tree/rb-tree.js +46 -37
- package/dist/data-structures/binary-tree/rb-tree.js.map +1 -0
- package/dist/data-structures/binary-tree/segment-tree.js +124 -127
- package/dist/data-structures/binary-tree/segment-tree.js.map +1 -0
- package/dist/data-structures/binary-tree/splay-tree.js +6 -2
- package/dist/data-structures/binary-tree/splay-tree.js.map +1 -0
- package/dist/data-structures/binary-tree/tree-multiset.js +227 -354
- package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -0
- package/dist/data-structures/binary-tree/two-three-tree.js +6 -2
- package/dist/data-structures/binary-tree/two-three-tree.js.map +1 -0
- package/dist/data-structures/graph/abstract-graph.js +582 -609
- package/dist/data-structures/graph/abstract-graph.js.map +1 -0
- package/dist/data-structures/graph/directed-graph.js +276 -312
- package/dist/data-structures/graph/directed-graph.js.map +1 -0
- package/dist/data-structures/graph/index.js +1 -0
- package/dist/data-structures/graph/index.js.map +1 -0
- package/dist/data-structures/graph/map-graph.js +88 -100
- package/dist/data-structures/graph/map-graph.js.map +1 -0
- package/dist/data-structures/graph/undirected-graph.js +180 -195
- package/dist/data-structures/graph/undirected-graph.js.map +1 -0
- package/dist/data-structures/hash/coordinate-map.js +46 -58
- package/dist/data-structures/hash/coordinate-map.js.map +1 -0
- package/dist/data-structures/hash/coordinate-set.js +43 -48
- package/dist/data-structures/hash/coordinate-set.js.map +1 -0
- package/dist/data-structures/hash/hash-table.js +6 -2
- package/dist/data-structures/hash/hash-table.js.map +1 -0
- package/dist/data-structures/hash/index.js +1 -0
- package/dist/data-structures/hash/index.js.map +1 -0
- package/dist/data-structures/hash/pair.js +6 -2
- package/dist/data-structures/hash/pair.js.map +1 -0
- package/dist/data-structures/hash/tree-map.js +6 -2
- package/dist/data-structures/hash/tree-map.js.map +1 -0
- package/dist/data-structures/hash/tree-set.js +6 -2
- package/dist/data-structures/hash/tree-set.js.map +1 -0
- package/dist/data-structures/heap/heap.js +83 -120
- package/dist/data-structures/heap/heap.js.map +1 -0
- package/dist/data-structures/heap/index.js +1 -0
- package/dist/data-structures/heap/index.js.map +1 -0
- package/dist/data-structures/heap/max-heap.js +27 -24
- package/dist/data-structures/heap/max-heap.js.map +1 -0
- package/dist/data-structures/heap/min-heap.js +27 -25
- package/dist/data-structures/heap/min-heap.js.map +1 -0
- package/dist/data-structures/index.js +1 -0
- package/dist/data-structures/index.js.map +1 -0
- package/dist/data-structures/linked-list/doubly-linked-list.js +202 -307
- package/dist/data-structures/linked-list/doubly-linked-list.js.map +1 -0
- package/dist/data-structures/linked-list/index.js +1 -0
- package/dist/data-structures/linked-list/index.js.map +1 -0
- package/dist/data-structures/linked-list/singly-linked-list.js +223 -251
- package/dist/data-structures/linked-list/singly-linked-list.js.map +1 -0
- package/dist/data-structures/linked-list/skip-linked-list.js +6 -2
- package/dist/data-structures/linked-list/skip-linked-list.js.map +1 -0
- package/dist/data-structures/matrix/index.js +1 -0
- package/dist/data-structures/matrix/index.js.map +1 -0
- package/dist/data-structures/matrix/matrix.js +9 -22
- package/dist/data-structures/matrix/matrix.js.map +1 -0
- package/dist/data-structures/matrix/matrix2d.js +75 -149
- package/dist/data-structures/matrix/matrix2d.js.map +1 -0
- package/dist/data-structures/matrix/navigator.js +38 -46
- package/dist/data-structures/matrix/navigator.js.map +1 -0
- package/dist/data-structures/matrix/vector2d.js +90 -254
- package/dist/data-structures/matrix/vector2d.js.map +1 -0
- package/dist/data-structures/priority-queue/index.js +1 -0
- package/dist/data-structures/priority-queue/index.js.map +1 -0
- package/dist/data-structures/priority-queue/max-priority-queue.js +47 -32
- package/dist/data-structures/priority-queue/max-priority-queue.js.map +1 -0
- package/dist/data-structures/priority-queue/min-priority-queue.js +47 -33
- package/dist/data-structures/priority-queue/min-priority-queue.js.map +1 -0
- package/dist/data-structures/priority-queue/priority-queue.js +150 -241
- package/dist/data-structures/priority-queue/priority-queue.js.map +1 -0
- package/dist/data-structures/queue/deque.js +130 -162
- package/dist/data-structures/queue/deque.js.map +1 -0
- package/dist/data-structures/queue/index.js +1 -0
- package/dist/data-structures/queue/index.js.map +1 -0
- package/dist/data-structures/queue/queue.js +181 -100
- package/dist/data-structures/queue/queue.js.map +1 -0
- package/dist/data-structures/stack/index.js +1 -0
- package/dist/data-structures/stack/index.js.map +1 -0
- package/dist/data-structures/stack/stack.js +23 -71
- package/dist/data-structures/stack/stack.js.map +1 -0
- package/dist/data-structures/tree/index.js +1 -0
- package/dist/data-structures/tree/index.js.map +1 -0
- package/dist/data-structures/tree/tree.js +46 -33
- package/dist/data-structures/tree/tree.js.map +1 -0
- package/dist/data-structures/trie/index.js +1 -0
- package/dist/data-structures/trie/index.js.map +1 -0
- package/dist/data-structures/trie/trie.js +201 -129
- package/dist/data-structures/trie/trie.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/abstract-binary-tree.js +1 -0
- package/dist/interfaces/abstract-binary-tree.js.map +1 -0
- package/dist/interfaces/abstract-graph.js +1 -0
- package/dist/interfaces/abstract-graph.js.map +1 -0
- package/dist/interfaces/avl-tree.js +1 -0
- package/dist/interfaces/avl-tree.js.map +1 -0
- package/dist/interfaces/binary-tree.js +1 -0
- package/dist/interfaces/binary-tree.js.map +1 -0
- package/dist/interfaces/bst.js +1 -0
- package/dist/interfaces/bst.js.map +1 -0
- package/dist/interfaces/directed-graph.js +1 -0
- package/dist/interfaces/directed-graph.js.map +1 -0
- package/dist/interfaces/doubly-linked-list.js +1 -0
- package/dist/interfaces/doubly-linked-list.js.map +1 -0
- package/dist/interfaces/heap.js +1 -0
- package/dist/interfaces/heap.js.map +1 -0
- package/dist/interfaces/index.js +1 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/navigator.js +1 -0
- package/dist/interfaces/navigator.js.map +1 -0
- package/dist/interfaces/priority-queue.js +1 -0
- package/dist/interfaces/priority-queue.js.map +1 -0
- package/dist/interfaces/rb-tree.js +1 -0
- package/dist/interfaces/rb-tree.js.map +1 -0
- package/dist/interfaces/segment-tree.js +1 -0
- package/dist/interfaces/segment-tree.js.map +1 -0
- package/dist/interfaces/singly-linked-list.js +1 -0
- package/dist/interfaces/singly-linked-list.js.map +1 -0
- package/dist/interfaces/tree-multiset.js +1 -0
- package/dist/interfaces/tree-multiset.js.map +1 -0
- package/dist/interfaces/undirected-graph.js +1 -0
- package/dist/interfaces/undirected-graph.js.map +1 -0
- package/dist/types/data-structures/abstract-binary-tree.js +1 -7
- package/dist/types/data-structures/abstract-binary-tree.js.map +1 -0
- package/dist/types/data-structures/abstract-graph.js +1 -0
- package/dist/types/data-structures/abstract-graph.js.map +1 -0
- package/dist/types/data-structures/avl-tree.js +1 -0
- package/dist/types/data-structures/avl-tree.js.map +1 -0
- package/dist/types/data-structures/binary-tree.js +1 -0
- package/dist/types/data-structures/binary-tree.js.map +1 -0
- package/dist/types/data-structures/bst.js +1 -0
- package/dist/types/data-structures/bst.js.map +1 -0
- package/dist/types/data-structures/directed-graph.js +1 -0
- package/dist/types/data-structures/directed-graph.js.map +1 -0
- package/dist/types/data-structures/doubly-linked-list.js +1 -0
- package/dist/types/data-structures/doubly-linked-list.js.map +1 -0
- package/dist/types/data-structures/heap.js +1 -0
- package/dist/types/data-structures/heap.js.map +1 -0
- package/dist/types/data-structures/index.js +1 -0
- package/dist/types/data-structures/index.js.map +1 -0
- package/dist/types/data-structures/map-graph.js +1 -0
- package/dist/types/data-structures/map-graph.js.map +1 -0
- package/dist/types/data-structures/navigator.js +1 -0
- package/dist/types/data-structures/navigator.js.map +1 -0
- package/dist/types/data-structures/priority-queue.js +1 -0
- package/dist/types/data-structures/priority-queue.js.map +1 -0
- package/dist/types/data-structures/rb-tree.js +1 -0
- package/dist/types/data-structures/rb-tree.js.map +1 -0
- package/dist/types/data-structures/segment-tree.js +1 -0
- package/dist/types/data-structures/segment-tree.js.map +1 -0
- package/dist/types/data-structures/singly-linked-list.js +1 -0
- package/dist/types/data-structures/singly-linked-list.js.map +1 -0
- package/dist/types/data-structures/tree-multiset.js +1 -0
- package/dist/types/data-structures/tree-multiset.js.map +1 -0
- package/dist/types/helpers.js +1 -0
- package/dist/types/helpers.js.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/utils/index.js +1 -0
- package/dist/types/utils/index.js.map +1 -0
- package/dist/types/utils/utils.js +1 -0
- package/dist/types/utils/utils.js.map +1 -0
- package/dist/types/utils/validate-type.js +1 -0
- package/dist/types/utils/validate-type.js.map +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/utils.js +108 -22
- package/dist/utils/utils.js.map +1 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +127 -0
- package/docs/assets/main.js +58 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1367 -0
- package/docs/classes/AVLTree.html +2182 -0
- package/docs/classes/AVLTreeNode.html +399 -0
- package/docs/classes/AaTree.html +202 -0
- package/docs/classes/AbstractBinaryTree.html +1836 -0
- package/docs/classes/AbstractBinaryTreeNode.html +441 -0
- package/docs/classes/AbstractEdge.html +345 -0
- package/docs/classes/AbstractGraph.html +1105 -0
- package/docs/classes/AbstractVertex.html +299 -0
- package/docs/classes/ArrayDeque.html +469 -0
- package/docs/classes/BST.html +2026 -0
- package/docs/classes/BSTNode.html +400 -0
- package/docs/classes/BTree.html +202 -0
- package/docs/classes/BinaryIndexedTree.html +371 -0
- package/docs/classes/BinaryTree.html +1867 -0
- package/docs/classes/BinaryTreeNode.html +399 -0
- package/docs/classes/Character.html +250 -0
- package/docs/classes/CoordinateMap.html +513 -0
- package/docs/classes/CoordinateSet.html +474 -0
- package/docs/classes/Deque.html +1005 -0
- package/docs/classes/DirectedEdge.html +404 -0
- package/docs/classes/DirectedGraph.html +1530 -0
- package/docs/classes/DirectedVertex.html +286 -0
- package/docs/classes/DoublyLinkedList.html +998 -0
- package/docs/classes/DoublyLinkedListNode.html +327 -0
- package/docs/classes/HashTable.html +202 -0
- package/docs/classes/Heap.html +647 -0
- package/docs/classes/HeapItem.html +296 -0
- package/docs/classes/LinkedListQueue.html +884 -0
- package/docs/classes/MapEdge.html +391 -0
- package/docs/classes/MapGraph.html +1583 -0
- package/docs/classes/MapVertex.html +356 -0
- package/docs/classes/Matrix2D.html +532 -0
- package/docs/classes/MatrixNTI2D.html +270 -0
- package/docs/classes/MaxHeap.html +671 -0
- package/docs/classes/MaxPriorityQueue.html +866 -0
- package/docs/classes/MinHeap.html +672 -0
- package/docs/classes/MinPriorityQueue.html +868 -0
- package/docs/classes/Navigator.html +343 -0
- package/docs/classes/ObjectDeque.html +527 -0
- package/docs/classes/Pair.html +202 -0
- package/docs/classes/PriorityQueue.html +790 -0
- package/docs/classes/Queue.html +521 -0
- package/docs/classes/RBTree.html +2024 -0
- package/docs/classes/RBTreeNode.html +431 -0
- package/docs/classes/SegmentTree.html +464 -0
- package/docs/classes/SegmentTreeNode.html +387 -0
- package/docs/classes/SinglyLinkedList.html +830 -0
- package/docs/classes/SinglyLinkedListNode.html +300 -0
- package/docs/classes/SkipLinkedList.html +202 -0
- package/docs/classes/SplayTree.html +202 -0
- package/docs/classes/Stack.html +398 -0
- package/docs/classes/TreeMap.html +202 -0
- package/docs/classes/TreeMultiset.html +2510 -0
- package/docs/classes/TreeMultisetNode.html +447 -0
- package/docs/classes/TreeNode.html +344 -0
- package/docs/classes/TreeSet.html +202 -0
- package/docs/classes/Trie.html +402 -0
- package/docs/classes/TrieNode.html +310 -0
- package/docs/classes/TwoThreeTree.html +202 -0
- package/docs/classes/UndirectedEdge.html +374 -0
- package/docs/classes/UndirectedGraph.html +1285 -0
- package/docs/classes/UndirectedVertex.html +284 -0
- package/docs/classes/Vector2D.html +835 -0
- package/docs/enums/CP.html +211 -0
- package/docs/enums/FamilyPosition.html +239 -0
- package/docs/enums/LoopType.html +212 -0
- package/docs/enums/RBColor.html +204 -0
- package/docs/enums/TopologicalProperty.html +211 -0
- package/docs/functions/arrayRemove.html +208 -0
- package/docs/functions/isThunk.html +186 -0
- package/docs/functions/toThunk.html +186 -0
- package/docs/functions/trampoline.html +186 -0
- package/docs/functions/trampolineAsync.html +186 -0
- package/docs/functions/uuidV4.html +181 -0
- package/docs/index.html +693 -0
- package/docs/interfaces/IAVLTree.html +1245 -0
- package/docs/interfaces/IAbstractBinaryTree.html +1101 -0
- package/docs/interfaces/IAbstractBinaryTreeNode.html +335 -0
- package/docs/interfaces/IAbstractGraph.html +433 -0
- package/docs/interfaces/IBST.html +1245 -0
- package/docs/interfaces/IDirectedGraph.html +570 -0
- package/docs/interfaces/IRBTree.html +1247 -0
- package/docs/interfaces/IUNDirectedGraph.html +463 -0
- package/docs/modules.html +328 -0
- package/docs/types/AVLTreeNodeNested.html +182 -0
- package/docs/types/AVLTreeOptions.html +180 -0
- package/docs/types/AbstractBinaryTreeNodeNested.html +182 -0
- package/docs/types/AbstractBinaryTreeNodeProperties.html +182 -0
- package/docs/types/AbstractBinaryTreeNodeProperty.html +182 -0
- package/docs/types/AbstractBinaryTreeOptions.html +182 -0
- package/docs/types/BSTComparator.html +192 -0
- package/docs/types/BSTNodeNested.html +182 -0
- package/docs/types/BSTOptions.html +182 -0
- package/docs/types/BinaryTreeDeletedResult.html +189 -0
- package/docs/types/BinaryTreeNodeId.html +177 -0
- package/docs/types/BinaryTreeNodeNested.html +182 -0
- package/docs/types/BinaryTreeNodePropertyName.html +177 -0
- package/docs/types/BinaryTreeOptions.html +180 -0
- package/docs/types/DFSOrderPattern.html +177 -0
- package/docs/types/DijkstraResult.html +199 -0
- package/docs/types/Direction.html +177 -0
- package/docs/types/DummyAny.html +190 -0
- package/docs/types/EdgeId.html +177 -0
- package/docs/types/HeapOptions.html +198 -0
- package/docs/types/IAVLTreeNode.html +184 -0
- package/docs/types/IBSTNode.html +184 -0
- package/docs/types/IBinaryTree.html +182 -0
- package/docs/types/IBinaryTreeNode.html +184 -0
- package/docs/types/IRBTreeNode.html +184 -0
- package/docs/types/ITreeMultiset.html +182 -0
- package/docs/types/ITreeMultisetNode.html +184 -0
- package/docs/types/KeyValueObject.html +182 -0
- package/docs/types/KeyValueObjectWithId.html +184 -0
- package/docs/types/MapGraphCoordinate.html +177 -0
- package/docs/types/NavigatorParams.html +211 -0
- package/docs/types/NodeOrPropertyName.html +177 -0
- package/docs/types/NonNumberNonObjectButDefined.html +177 -0
- package/docs/types/ObjectWithNonNumberId.html +184 -0
- package/docs/types/ObjectWithNumberId.html +184 -0
- package/docs/types/ObjectWithoutId.html +177 -0
- package/docs/types/PriorityQueueComparator.html +197 -0
- package/docs/types/PriorityQueueDFSOrderPattern.html +177 -0
- package/docs/types/PriorityQueueOptions.html +191 -0
- package/docs/types/RBTreeNodeNested.html +182 -0
- package/docs/types/RBTreeOptions.html +180 -0
- package/docs/types/RestrictValById.html +177 -0
- package/docs/types/SegmentTreeNodeVal.html +177 -0
- package/docs/types/SpecifyOptional.html +184 -0
- package/docs/types/Thunk.html +185 -0
- package/docs/types/ToThunkFn.html +185 -0
- package/docs/types/TopologicalStatus.html +177 -0
- package/docs/types/TreeMultisetNodeNested.html +182 -0
- package/docs/types/TreeMultisetOptions.html +180 -0
- package/docs/types/TrlAsyncFn.html +190 -0
- package/docs/types/TrlFn.html +190 -0
- package/docs/types/Turning.html +177 -0
- package/docs/types/VertexId.html +177 -0
- package/docs/variables/THUNK_SYMBOL.html +177 -0
- package/jest.config.js +7 -0
- package/lib/data-structures/binary-tree/aa-tree.js +2 -0
- package/{dist → lib}/data-structures/binary-tree/abstract-binary-tree.d.ts +194 -22
- package/lib/data-structures/binary-tree/abstract-binary-tree.js +1291 -0
- package/{dist → lib}/data-structures/binary-tree/avl-tree.d.ts +12 -12
- package/lib/data-structures/binary-tree/avl-tree.js +311 -0
- package/lib/data-structures/binary-tree/b-tree.js +2 -0
- package/lib/data-structures/binary-tree/binary-indexed-tree.js +69 -0
- package/lib/data-structures/binary-tree/binary-tree.js +35 -0
- package/{dist → lib}/data-structures/binary-tree/bst.d.ts +19 -8
- package/lib/data-structures/binary-tree/bst.js +551 -0
- package/lib/data-structures/binary-tree/index.js +12 -0
- package/{dist → lib}/data-structures/binary-tree/rb-tree.d.ts +0 -6
- package/lib/data-structures/binary-tree/rb-tree.js +22 -0
- package/lib/data-structures/binary-tree/segment-tree.js +210 -0
- package/lib/data-structures/binary-tree/splay-tree.js +2 -0
- package/{dist → lib}/data-structures/binary-tree/tree-multiset.d.ts +20 -23
- package/lib/data-structures/binary-tree/tree-multiset.js +673 -0
- package/lib/data-structures/binary-tree/two-three-tree.js +2 -0
- package/lib/data-structures/graph/abstract-graph.js +918 -0
- package/lib/data-structures/graph/directed-graph.js +416 -0
- package/lib/data-structures/graph/index.js +4 -0
- package/lib/data-structures/graph/map-graph.js +105 -0
- package/lib/data-structures/graph/undirected-graph.js +246 -0
- package/lib/data-structures/hash/coordinate-map.js +61 -0
- package/lib/data-structures/hash/coordinate-set.js +51 -0
- package/lib/data-structures/hash/hash-table.js +2 -0
- package/lib/data-structures/hash/index.js +6 -0
- package/lib/data-structures/hash/pair.js +2 -0
- package/lib/data-structures/hash/tree-map.js +2 -0
- package/lib/data-structures/hash/tree-set.js +2 -0
- package/lib/data-structures/heap/heap.js +152 -0
- package/lib/data-structures/heap/index.js +3 -0
- package/lib/data-structures/heap/max-heap.js +26 -0
- package/lib/data-structures/heap/min-heap.js +27 -0
- package/lib/data-structures/index.js +11 -0
- package/{dist → lib}/data-structures/linked-list/doubly-linked-list.d.ts +5 -5
- package/lib/data-structures/linked-list/doubly-linked-list.js +521 -0
- package/lib/data-structures/linked-list/index.js +3 -0
- package/{dist → lib}/data-structures/linked-list/singly-linked-list.d.ts +6 -5
- package/lib/data-structures/linked-list/singly-linked-list.js +443 -0
- package/lib/data-structures/linked-list/skip-linked-list.js +2 -0
- package/lib/data-structures/matrix/index.js +4 -0
- package/lib/data-structures/matrix/matrix.js +24 -0
- package/lib/data-structures/matrix/matrix2d.js +195 -0
- package/lib/data-structures/matrix/navigator.js +101 -0
- package/lib/data-structures/matrix/vector2d.js +287 -0
- package/lib/data-structures/priority-queue/index.js +3 -0
- package/lib/data-structures/priority-queue/max-priority-queue.js +39 -0
- package/lib/data-structures/priority-queue/min-priority-queue.js +40 -0
- package/lib/data-structures/priority-queue/priority-queue.js +317 -0
- package/{dist → lib}/data-structures/queue/deque.d.ts +45 -0
- package/lib/data-structures/queue/deque.js +270 -0
- package/lib/data-structures/queue/index.js +2 -0
- package/{dist → lib}/data-structures/queue/queue.d.ts +47 -13
- package/lib/data-structures/queue/queue.js +165 -0
- package/lib/data-structures/stack/index.js +1 -0
- package/lib/data-structures/stack/stack.js +87 -0
- package/lib/data-structures/tree/index.js +1 -0
- package/lib/data-structures/tree/tree.js +56 -0
- package/lib/data-structures/trie/index.js +1 -0
- package/lib/data-structures/trie/trie.js +205 -0
- package/lib/index.js +4 -0
- package/{dist → lib}/interfaces/avl-tree.d.ts +1 -9
- package/lib/interfaces/binary-tree.d.ts +4 -0
- package/{dist → lib}/interfaces/bst.d.ts +1 -2
- package/lib/interfaces/heap.js +1 -0
- package/lib/interfaces/index.js +15 -0
- package/lib/interfaces/navigator.d.ts +1 -0
- package/lib/interfaces/navigator.js +1 -0
- package/lib/interfaces/priority-queue.d.ts +1 -0
- package/lib/interfaces/priority-queue.js +1 -0
- package/{dist → lib}/interfaces/rb-tree.d.ts +1 -2
- package/lib/interfaces/rb-tree.js +1 -0
- package/lib/interfaces/segment-tree.d.ts +1 -0
- package/lib/interfaces/segment-tree.js +1 -0
- package/lib/interfaces/singly-linked-list.d.ts +1 -0
- package/lib/interfaces/singly-linked-list.js +1 -0
- package/lib/interfaces/tree-multiset.d.ts +5 -0
- package/lib/interfaces/tree-multiset.js +1 -0
- package/lib/interfaces/undirected-graph.js +1 -0
- package/{dist → lib}/types/data-structures/abstract-binary-tree.d.ts +1 -1
- package/lib/types/data-structures/abstract-binary-tree.js +22 -0
- package/lib/types/data-structures/abstract-graph.js +1 -0
- package/{dist → lib}/types/data-structures/avl-tree.d.ts +1 -1
- package/lib/types/data-structures/avl-tree.js +1 -0
- package/lib/types/data-structures/binary-tree.js +1 -0
- package/lib/types/data-structures/bst.js +6 -0
- package/lib/types/data-structures/directed-graph.js +6 -0
- package/lib/types/data-structures/doubly-linked-list.d.ts +1 -0
- package/lib/types/data-structures/doubly-linked-list.js +1 -0
- package/lib/types/data-structures/heap.js +1 -0
- package/lib/types/data-structures/index.js +15 -0
- package/lib/types/data-structures/map-graph.js +1 -0
- package/lib/types/data-structures/navigator.js +1 -0
- package/lib/types/data-structures/priority-queue.js +1 -0
- package/lib/types/data-structures/rb-tree.js +5 -0
- package/lib/types/data-structures/segment-tree.js +1 -0
- package/lib/types/data-structures/singly-linked-list.d.ts +1 -0
- package/lib/types/data-structures/singly-linked-list.js +1 -0
- package/lib/types/data-structures/tree-multiset.js +1 -0
- package/lib/types/helpers.d.ts +1 -0
- package/lib/types/helpers.js +1 -0
- package/lib/types/index.js +3 -0
- package/lib/types/utils/index.js +2 -0
- package/{dist → lib}/types/utils/utils.d.ts +1 -1
- package/lib/types/utils/utils.js +1 -0
- package/{dist → lib}/types/utils/validate-type.d.ts +1 -1
- package/lib/types/utils/validate-type.js +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/utils/utils.js +57 -0
- package/package.json +150 -56
- package/rename_clear_files.sh +29 -0
- package/test/integration/avl-tree.test.ts +111 -0
- package/test/integration/bst.test.ts +371 -0
- package/test/integration/heap.test.js +19 -0
- package/test/integration/index.html +44 -0
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +111 -0
- package/test/unit/data-structures/binary-tree/bst.test.ts +371 -0
- package/test/unit/data-structures/binary-tree/overall.test.ts +57 -0
- package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +405 -0
- package/test/unit/data-structures/graph/abstract-graph.test.ts +5 -0
- package/test/unit/data-structures/graph/directed-graph.test.ts +517 -0
- package/test/unit/data-structures/graph/index.ts +2 -0
- package/test/unit/data-structures/graph/map-graph.test.ts +46 -0
- package/test/unit/data-structures/graph/overall.test.ts +50 -0
- package/test/unit/data-structures/graph/undirected-graph.test.ts +60 -0
- package/test/unit/data-structures/heap/heap.test.ts +56 -0
- package/test/unit/data-structures/heap/max-heap.test.ts +42 -0
- package/test/unit/data-structures/heap/min-heap.test.ts +81 -0
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +365 -0
- package/test/unit/data-structures/linked-list/index.ts +4 -0
- package/test/unit/data-structures/linked-list/linked-list.test.ts +37 -0
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +401 -0
- package/test/unit/data-structures/linked-list/skip-linked-list.test.ts +13 -0
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +108 -0
- package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +105 -0
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +27 -0
- package/test/unit/data-structures/queue/queue.test.ts +36 -0
- package/test/utils/index.ts +2 -0
- package/test/utils/magnitude.ts +21 -0
- package/test/utils/number.ts +3 -0
- package/tsconfig.build.json +33 -0
- package/tsconfig.json +38 -0
- package/umd/bundle.min.js +3 -0
- package/umd/bundle.min.js.map +1 -0
- package/webpack.config.js +28 -0
- package/dist/bundle.js +0 -2
- package/dist/interfaces/binary-tree.d.ts +0 -6
- package/dist/interfaces/tree-multiset.d.ts +0 -7
- /package/{dist → lib}/data-structures/binary-tree/aa-tree.d.ts +0 -0
- /package/{dist → lib}/data-structures/binary-tree/b-tree.d.ts +0 -0
- /package/{dist → lib}/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
- /package/{dist → lib}/data-structures/binary-tree/binary-tree.d.ts +0 -0
- /package/{dist → lib}/data-structures/binary-tree/index.d.ts +0 -0
- /package/{dist → lib}/data-structures/binary-tree/segment-tree.d.ts +0 -0
- /package/{dist → lib}/data-structures/binary-tree/splay-tree.d.ts +0 -0
- /package/{dist → lib}/data-structures/binary-tree/two-three-tree.d.ts +0 -0
- /package/{dist → lib}/data-structures/graph/abstract-graph.d.ts +0 -0
- /package/{dist → lib}/data-structures/graph/directed-graph.d.ts +0 -0
- /package/{dist → lib}/data-structures/graph/index.d.ts +0 -0
- /package/{dist → lib}/data-structures/graph/map-graph.d.ts +0 -0
- /package/{dist → lib}/data-structures/graph/undirected-graph.d.ts +0 -0
- /package/{dist → lib}/data-structures/hash/coordinate-map.d.ts +0 -0
- /package/{dist → lib}/data-structures/hash/coordinate-set.d.ts +0 -0
- /package/{dist → lib}/data-structures/hash/hash-table.d.ts +0 -0
- /package/{dist → lib}/data-structures/hash/index.d.ts +0 -0
- /package/{dist → lib}/data-structures/hash/pair.d.ts +0 -0
- /package/{dist → lib}/data-structures/hash/tree-map.d.ts +0 -0
- /package/{dist → lib}/data-structures/hash/tree-set.d.ts +0 -0
- /package/{dist → lib}/data-structures/heap/heap.d.ts +0 -0
- /package/{dist → lib}/data-structures/heap/index.d.ts +0 -0
- /package/{dist → lib}/data-structures/heap/max-heap.d.ts +0 -0
- /package/{dist → lib}/data-structures/heap/min-heap.d.ts +0 -0
- /package/{dist → lib}/data-structures/index.d.ts +0 -0
- /package/{dist → lib}/data-structures/linked-list/index.d.ts +0 -0
- /package/{dist → lib}/data-structures/linked-list/skip-linked-list.d.ts +0 -0
- /package/{dist → lib}/data-structures/matrix/index.d.ts +0 -0
- /package/{dist → lib}/data-structures/matrix/matrix.d.ts +0 -0
- /package/{dist → lib}/data-structures/matrix/matrix2d.d.ts +0 -0
- /package/{dist → lib}/data-structures/matrix/navigator.d.ts +0 -0
- /package/{dist → lib}/data-structures/matrix/vector2d.d.ts +0 -0
- /package/{dist → lib}/data-structures/priority-queue/index.d.ts +0 -0
- /package/{dist → lib}/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
- /package/{dist → lib}/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
- /package/{dist → lib}/data-structures/priority-queue/priority-queue.d.ts +0 -0
- /package/{dist → lib}/data-structures/queue/index.d.ts +0 -0
- /package/{dist → lib}/data-structures/stack/index.d.ts +0 -0
- /package/{dist → lib}/data-structures/stack/stack.d.ts +0 -0
- /package/{dist → lib}/data-structures/tree/index.d.ts +0 -0
- /package/{dist → lib}/data-structures/tree/tree.d.ts +0 -0
- /package/{dist → lib}/data-structures/trie/index.d.ts +0 -0
- /package/{dist → lib}/data-structures/trie/trie.d.ts +0 -0
- /package/{dist → lib}/index.d.ts +0 -0
- /package/{dist → lib}/interfaces/abstract-binary-tree.d.ts +0 -0
- /package/{dist/interfaces/doubly-linked-list.d.ts → lib/interfaces/abstract-binary-tree.js} +0 -0
- /package/{dist → lib}/interfaces/abstract-graph.d.ts +0 -0
- /package/{dist/interfaces/heap.d.ts → lib/interfaces/abstract-graph.js} +0 -0
- /package/{dist/interfaces/navigator.d.ts → lib/interfaces/avl-tree.js} +0 -0
- /package/{dist/interfaces/priority-queue.d.ts → lib/interfaces/binary-tree.js} +0 -0
- /package/{dist/interfaces/segment-tree.d.ts → lib/interfaces/bst.js} +0 -0
- /package/{dist → lib}/interfaces/directed-graph.d.ts +0 -0
- /package/{dist/interfaces/singly-linked-list.d.ts → lib/interfaces/directed-graph.js} +0 -0
- /package/{dist/types/data-structures → lib/interfaces}/doubly-linked-list.d.ts +0 -0
- /package/{dist/types/data-structures/singly-linked-list.d.ts → lib/interfaces/doubly-linked-list.js} +0 -0
- /package/{dist/types/helpers.d.ts → lib/interfaces/heap.d.ts} +0 -0
- /package/{dist → lib}/interfaces/index.d.ts +0 -0
- /package/{dist → lib}/interfaces/undirected-graph.d.ts +0 -0
- /package/{dist → lib}/types/data-structures/abstract-graph.d.ts +0 -0
- /package/{dist → lib}/types/data-structures/binary-tree.d.ts +0 -0
- /package/{dist → lib}/types/data-structures/bst.d.ts +0 -0
- /package/{dist → lib}/types/data-structures/directed-graph.d.ts +0 -0
- /package/{dist → lib}/types/data-structures/heap.d.ts +0 -0
- /package/{dist → lib}/types/data-structures/index.d.ts +0 -0
- /package/{dist → lib}/types/data-structures/map-graph.d.ts +0 -0
- /package/{dist → lib}/types/data-structures/navigator.d.ts +0 -0
- /package/{dist → lib}/types/data-structures/priority-queue.d.ts +0 -0
- /package/{dist → lib}/types/data-structures/rb-tree.d.ts +0 -0
- /package/{dist → lib}/types/data-structures/segment-tree.d.ts +0 -0
- /package/{dist → lib}/types/data-structures/tree-multiset.d.ts +0 -0
- /package/{dist → lib}/types/index.d.ts +0 -0
- /package/{dist → lib}/types/utils/index.d.ts +0 -0
- /package/{dist → lib}/utils/index.d.ts +0 -0
- /package/{dist → lib}/utils/utils.d.ts +0 -0
- /package/{dist/bundle.js.LICENSE.txt → umd/bundle.min.js.LICENSE.txt} +0 -0
|
@@ -1,290 +1,126 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Vector2D = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* @license MIT License
|
|
10
|
-
*/
|
|
11
|
-
class Vector2D {
|
|
12
|
-
constructor(x = 0, y = 0, w = 1 // needed for matrix multiplication
|
|
13
|
-
) {
|
|
4
|
+
var Vector2D = (function () {
|
|
5
|
+
function Vector2D(x, y, w) {
|
|
6
|
+
if (x === void 0) { x = 0; }
|
|
7
|
+
if (y === void 0) { y = 0; }
|
|
8
|
+
if (w === void 0) { w = 1; }
|
|
14
9
|
this.x = x;
|
|
15
10
|
this.y = y;
|
|
16
11
|
this.w = w;
|
|
17
12
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The function "add" takes two Vector2D objects as parameters and returns a new Vector2D object with the sum of their
|
|
49
|
-
* x and y components.
|
|
50
|
-
* @param {Vector2D} vector1 - The parameter `vector1` is an instance of the `Vector2D` class. It represents a
|
|
51
|
-
* 2-dimensional vector with an `x` and `y` component.
|
|
52
|
-
* @param {Vector2D} vector2 - The parameter "vector2" is of type Vector2D. It represents a 2-dimensional vector with
|
|
53
|
-
* an x and y component.
|
|
54
|
-
* @returns The method is returning a new instance of the Vector2D class with the x and y components of the two input
|
|
55
|
-
* vectors added together.
|
|
56
|
-
*/
|
|
57
|
-
static add(vector1, vector2) {
|
|
13
|
+
Object.defineProperty(Vector2D.prototype, "isZero", {
|
|
14
|
+
get: function () {
|
|
15
|
+
return this.x === 0 && this.y === 0;
|
|
16
|
+
},
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(Vector2D.prototype, "length", {
|
|
21
|
+
get: function () {
|
|
22
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
23
|
+
},
|
|
24
|
+
enumerable: false,
|
|
25
|
+
configurable: true
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(Vector2D.prototype, "lengthSq", {
|
|
28
|
+
get: function () {
|
|
29
|
+
return this.x * this.x + this.y * this.y;
|
|
30
|
+
},
|
|
31
|
+
enumerable: false,
|
|
32
|
+
configurable: true
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(Vector2D.prototype, "rounded", {
|
|
35
|
+
get: function () {
|
|
36
|
+
return new Vector2D(Math.round(this.x), Math.round(this.y));
|
|
37
|
+
},
|
|
38
|
+
enumerable: false,
|
|
39
|
+
configurable: true
|
|
40
|
+
});
|
|
41
|
+
Vector2D.add = function (vector1, vector2) {
|
|
58
42
|
return new Vector2D(vector1.x + vector2.x, vector1.y + vector2.y);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
* The subtract function takes two Vector2D objects as parameters and returns a new Vector2D object with the x and y
|
|
62
|
-
* components subtracted.
|
|
63
|
-
* @param {Vector2D} vector1 - The parameter `vector1` is an instance of the `Vector2D` class, representing a
|
|
64
|
-
* 2-dimensional vector. It has properties `x` and `y` which represent the x and y components of the vector
|
|
65
|
-
* respectively.
|
|
66
|
-
* @param {Vector2D} vector2 - The parameter "vector2" is a Vector2D object. It represents the second vector that you
|
|
67
|
-
* want to subtract from the first vector.
|
|
68
|
-
* @returns The method is returning a new Vector2D object with the x and y components subtracted from vector1 and
|
|
69
|
-
* vector2.
|
|
70
|
-
*/
|
|
71
|
-
static subtract(vector1, vector2) {
|
|
43
|
+
};
|
|
44
|
+
Vector2D.subtract = function (vector1, vector2) {
|
|
72
45
|
return new Vector2D(vector1.x - vector2.x, vector1.y - vector2.y);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
* The function subtracts a given value from the x and y components of a Vector2D object and returns a new Vector2D
|
|
76
|
-
* object.
|
|
77
|
-
* @param {Vector2D} vector - The parameter "vector" is of type Vector2D, which represents a 2-dimensional vector with
|
|
78
|
-
* x and y components.
|
|
79
|
-
* @param {number} value - The "value" parameter is a number that will be subtracted from both the x and y components
|
|
80
|
-
* of the "vector" parameter.
|
|
81
|
-
* @returns A new Vector2D object with the x and y values subtracted by the given value.
|
|
82
|
-
*/
|
|
83
|
-
static subtractValue(vector, value) {
|
|
46
|
+
};
|
|
47
|
+
Vector2D.subtractValue = function (vector, value) {
|
|
84
48
|
return new Vector2D(vector.x - value, vector.y - value);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
* The function multiplies a Vector2D object by a given value.
|
|
88
|
-
* @param {Vector2D} vector - The parameter "vector" is of type Vector2D, which represents a 2-dimensional vector with
|
|
89
|
-
* x and y components.
|
|
90
|
-
* @param {number} value - The "value" parameter is a number that represents the value by which the x and y components
|
|
91
|
-
* of the vector will be multiplied.
|
|
92
|
-
* @returns A new Vector2D object with the x and y values multiplied by the given value.
|
|
93
|
-
*/
|
|
94
|
-
static multiply(vector, value) {
|
|
49
|
+
};
|
|
50
|
+
Vector2D.multiply = function (vector, value) {
|
|
95
51
|
return new Vector2D(vector.x * value, vector.y * value);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
* The function divides the x and y components of a Vector2D by a given value and returns a new Vector2D.
|
|
99
|
-
* @param {Vector2D} vector - The parameter "vector" is of type Vector2D, which represents a 2-dimensional vector with
|
|
100
|
-
* x and y components.
|
|
101
|
-
* @param {number} value - The value parameter is a number that will be used to divide the x and y components of the
|
|
102
|
-
* vector.
|
|
103
|
-
* @returns A new instance of the Vector2D class with the x and y values divided by the given value.
|
|
104
|
-
*/
|
|
105
|
-
static divide(vector, value) {
|
|
52
|
+
};
|
|
53
|
+
Vector2D.divide = function (vector, value) {
|
|
106
54
|
return new Vector2D(vector.x / value, vector.y / value);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
* The function checks if two Vector2D objects are equal by comparing their x and y values.
|
|
110
|
-
* @param {Vector2D} vector1 - The parameter `vector1` is of type `Vector2D`, which represents a 2-dimensional vector.
|
|
111
|
-
* It has two properties: `x` and `y`, which represent the x and y components of the vector, respectively.
|
|
112
|
-
* @param {Vector2D} vector2 - The parameter "vector2" is of type Vector2D.
|
|
113
|
-
* @returns a boolean value, which indicates whether the two input vectors are equal or not.
|
|
114
|
-
*/
|
|
115
|
-
static equals(vector1, vector2) {
|
|
55
|
+
};
|
|
56
|
+
Vector2D.equals = function (vector1, vector2) {
|
|
116
57
|
return vector1.x === vector2.x && vector1.y === vector2.y;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
* @param {Vector2D} vector2 - The parameter "vector2" is a Vector2D object, which represents a 2-dimensional vector.
|
|
122
|
-
* It is used as one of the inputs for the "equalsRounded" function.
|
|
123
|
-
* @param [roundingFactor=12] - The roundingFactor parameter is used to determine the threshold for considering two
|
|
124
|
-
* vectors as equal. If the absolute difference in the x and y components of the vectors is less than the
|
|
125
|
-
* roundingFactor, the vectors are considered equal.
|
|
126
|
-
* @returns a boolean value.
|
|
127
|
-
*/
|
|
128
|
-
static equalsRounded(vector1, vector2, roundingFactor = 12) {
|
|
129
|
-
const vector = Vector2D.abs(Vector2D.subtract(vector1, vector2));
|
|
58
|
+
};
|
|
59
|
+
Vector2D.equalsRounded = function (vector1, vector2, roundingFactor) {
|
|
60
|
+
if (roundingFactor === void 0) { roundingFactor = 12; }
|
|
61
|
+
var vector = Vector2D.abs(Vector2D.subtract(vector1, vector2));
|
|
130
62
|
if (vector.x < roundingFactor && vector.y < roundingFactor) {
|
|
131
63
|
return true;
|
|
132
64
|
}
|
|
133
65
|
return false;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
* @returns the normalized vector if its length is greater than a very small value (epsilon), otherwise it returns the
|
|
139
|
-
* original vector.
|
|
140
|
-
*/
|
|
141
|
-
static normalize(vector) {
|
|
142
|
-
const length = vector.length;
|
|
143
|
-
if (length > 2.220446049250313e-16) { // Epsilon
|
|
66
|
+
};
|
|
67
|
+
Vector2D.normalize = function (vector) {
|
|
68
|
+
var length = vector.length;
|
|
69
|
+
if (length > 2.220446049250313e-16) {
|
|
144
70
|
return Vector2D.divide(vector, length);
|
|
145
71
|
}
|
|
146
72
|
return vector;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
* The function truncates a vector to a maximum length if it exceeds that length.Adjusts x and y so that the length of the vector does not exceed max
|
|
150
|
-
* @param {Vector2D} vector - A 2D vector represented by the Vector2D class.
|
|
151
|
-
* @param {number} max - The `max` parameter is a number that represents the maximum length that the `vector` should
|
|
152
|
-
* have.
|
|
153
|
-
* @returns either the original vector or a truncated version of the vector, depending on whether the length of the
|
|
154
|
-
* vector is greater than the maximum value specified.
|
|
155
|
-
*/
|
|
156
|
-
static truncate(vector, max) {
|
|
73
|
+
};
|
|
74
|
+
Vector2D.truncate = function (vector, max) {
|
|
157
75
|
if (vector.length > max) {
|
|
158
76
|
return Vector2D.multiply(Vector2D.normalize(vector), max);
|
|
159
77
|
}
|
|
160
78
|
return vector;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
* The function returns a new Vector2D object that is perpendicular to the input vector.The vector that is perpendicular to this one
|
|
164
|
-
* @param {Vector2D} vector - The parameter "vector" is of type Vector2D.
|
|
165
|
-
* @returns A new Vector2D object is being returned.
|
|
166
|
-
*/
|
|
167
|
-
static perp(vector) {
|
|
79
|
+
};
|
|
80
|
+
Vector2D.perp = function (vector) {
|
|
168
81
|
return new Vector2D(-vector.y, vector.x);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
* The reverse function takes a Vector2D object and returns a new Vector2D object with the negated x and y values.
|
|
172
|
-
* @param {Vector2D} vector - The parameter "vector" is of type Vector2D, which represents a 2-dimensional vector. It
|
|
173
|
-
* has two properties: "x" and "y", which represent the x and y components of the vector, respectively.
|
|
174
|
-
* @returns A new Vector2D object with the negated x and y values of the input vector. Returns the vector that is the reverse of this vector
|
|
175
|
-
*/
|
|
176
|
-
static reverse(vector) {
|
|
82
|
+
};
|
|
83
|
+
Vector2D.reverse = function (vector) {
|
|
177
84
|
return new Vector2D(-vector.x, -vector.y);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
* The function takes a Vector2D object as input and returns a new Vector2D object with the absolute values of its x
|
|
181
|
-
* and y components.
|
|
182
|
-
* @param {Vector2D} vector - The parameter "vector" is of type Vector2D, which represents a 2-dimensional vector. It
|
|
183
|
-
* has two properties: "x" and "y", which represent the x and y components of the vector, respectively.
|
|
184
|
-
* @returns The method is returning a new Vector2D object with the absolute values of the x and y components of the
|
|
185
|
-
* input vector.
|
|
186
|
-
*/
|
|
187
|
-
static abs(vector) {
|
|
85
|
+
};
|
|
86
|
+
Vector2D.abs = function (vector) {
|
|
188
87
|
return new Vector2D(Math.abs(vector.x), Math.abs(vector.y));
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
// static transform(vector: Vector2D, transformation: Matrix2D): Vector2D {
|
|
205
|
-
// return Matrix2D.multiplyByVector(transformation, vector)
|
|
206
|
-
// }
|
|
207
|
-
// /**
|
|
208
|
-
// * Transform vectors based on the current tranformation matrices: translation, rotation and scale
|
|
209
|
-
// * @param vectors The vectors to transform
|
|
210
|
-
// */
|
|
211
|
-
// static transformList(vectors: Vector2D[], transformation: Matrix2D): Vector2D[] {
|
|
212
|
-
// return vectors.map(vector => Matrix2D.multiplyByVector(transformation, vector))
|
|
213
|
-
// }
|
|
214
|
-
/**
|
|
215
|
-
* The function calculates the distance between two points in a two-dimensional space.
|
|
216
|
-
* @param {Vector2D} vector1 - The parameter `vector1` represents the first vector in 2D space, while `vector2`
|
|
217
|
-
* represents the second vector. Each vector has an `x` and `y` component, which represent their respective coordinates
|
|
218
|
-
* in the 2D space.
|
|
219
|
-
* @param {Vector2D} vector2 - The `vector2` parameter represents the second vector in the calculation of distance. It
|
|
220
|
-
* is an instance of the `Vector2D` class, which typically has properties `x` and `y` representing the coordinates of
|
|
221
|
-
* the vector in a 2D space.
|
|
222
|
-
* @returns The distance between vector1 and vector2.
|
|
223
|
-
*/
|
|
224
|
-
static distance(vector1, vector2) {
|
|
225
|
-
const ySeparation = vector2.y - vector1.y;
|
|
226
|
-
const xSeparation = vector2.x - vector1.x;
|
|
227
|
-
return Math.sqrt((ySeparation * ySeparation) + (xSeparation * xSeparation));
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* The function calculates the squared distance between two 2D vectors.
|
|
231
|
-
* @param {Vector2D} vector1 - The parameter `vector1` represents the first vector, which is an instance of the
|
|
232
|
-
* `Vector2D` class. It contains the x and y coordinates of the vector.
|
|
233
|
-
* @param {Vector2D} vector2 - The `vector2` parameter represents the second vector in a two-dimensional space. It has
|
|
234
|
-
* properties `x` and `y` which represent the coordinates of the vector.
|
|
235
|
-
* @returns the square of the distance between the two input vectors.
|
|
236
|
-
*/
|
|
237
|
-
static distanceSq(vector1, vector2) {
|
|
238
|
-
const ySeparation = vector2.y - vector1.y;
|
|
239
|
-
const xSeparation = vector2.x - vector1.x;
|
|
240
|
-
return (ySeparation * ySeparation) + (xSeparation * xSeparation);
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* The sign function determines the sign of the cross product between two 2D vectors.
|
|
244
|
-
* (assuming the Y axis is pointing down, X axis to right like a Window app)
|
|
245
|
-
* @param {Vector2D} vector1 - The parameter `vector1` is of type `Vector2D`, which represents a 2-dimensional vector.
|
|
246
|
-
* It likely has properties `x` and `y` representing the x and y components of the vector, respectively.
|
|
247
|
-
* @param {Vector2D} vector2 - The above code defines a function called "sign" that takes two parameters: vector1 and
|
|
248
|
-
* vector2. Both vector1 and vector2 are of type Vector2D.
|
|
249
|
-
* @returns either -1 or 1. Returns positive if v2 is clockwise of this vector, negative if counterclockwise
|
|
250
|
-
*/
|
|
251
|
-
static sign(vector1, vector2) {
|
|
88
|
+
};
|
|
89
|
+
Vector2D.dot = function (vector1, vector2) {
|
|
90
|
+
return vector1.x * vector2.x + vector1.y * vector2.y;
|
|
91
|
+
};
|
|
92
|
+
Vector2D.distance = function (vector1, vector2) {
|
|
93
|
+
var ySeparation = vector2.y - vector1.y;
|
|
94
|
+
var xSeparation = vector2.x - vector1.x;
|
|
95
|
+
return Math.sqrt(ySeparation * ySeparation + xSeparation * xSeparation);
|
|
96
|
+
};
|
|
97
|
+
Vector2D.distanceSq = function (vector1, vector2) {
|
|
98
|
+
var ySeparation = vector2.y - vector1.y;
|
|
99
|
+
var xSeparation = vector2.x - vector1.x;
|
|
100
|
+
return ySeparation * ySeparation + xSeparation * xSeparation;
|
|
101
|
+
};
|
|
102
|
+
Vector2D.sign = function (vector1, vector2) {
|
|
252
103
|
if (vector1.y * vector2.x > vector1.x * vector2.y) {
|
|
253
104
|
return -1;
|
|
254
105
|
}
|
|
255
106
|
return 1;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const origin = new Vector2D(0, -1);
|
|
266
|
-
const radian = Math.acos(Vector2D.dot(vector, origin) / (vector.length * origin.length));
|
|
267
|
-
return Vector2D.sign(vector, origin) === 1 ? ((Math.PI * 2) - radian) : radian;
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* The function "random" generates a random Vector2D object with x and y values within the specified range.
|
|
271
|
-
* @param {number} maxX - The maxX parameter represents the maximum value for the x-coordinate of the random vector.
|
|
272
|
-
* @param {number} maxY - The `maxY` parameter represents the maximum value for the y-coordinate of the generated
|
|
273
|
-
* random vector.
|
|
274
|
-
* @returns a new instance of the Vector2D class with random x and y values.
|
|
275
|
-
*/
|
|
276
|
-
static random(maxX, maxY) {
|
|
277
|
-
const randX = Math.floor(Math.random() * maxX - (maxX / 2));
|
|
278
|
-
const randY = Math.floor(Math.random() * maxY - (maxY / 2));
|
|
107
|
+
};
|
|
108
|
+
Vector2D.angle = function (vector) {
|
|
109
|
+
var origin = new Vector2D(0, -1);
|
|
110
|
+
var radian = Math.acos(Vector2D.dot(vector, origin) / (vector.length * origin.length));
|
|
111
|
+
return Vector2D.sign(vector, origin) === 1 ? Math.PI * 2 - radian : radian;
|
|
112
|
+
};
|
|
113
|
+
Vector2D.random = function (maxX, maxY) {
|
|
114
|
+
var randX = Math.floor(Math.random() * maxX - maxX / 2);
|
|
115
|
+
var randY = Math.floor(Math.random() * maxY - maxY / 2);
|
|
279
116
|
return new Vector2D(randX, randY);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
* The function sets the values of x and y to zero.
|
|
283
|
-
*/
|
|
284
|
-
zero() {
|
|
117
|
+
};
|
|
118
|
+
Vector2D.prototype.zero = function () {
|
|
285
119
|
this.x = 0;
|
|
286
120
|
this.y = 0;
|
|
287
|
-
}
|
|
288
|
-
|
|
121
|
+
};
|
|
122
|
+
return Vector2D;
|
|
123
|
+
}());
|
|
289
124
|
exports.Vector2D = Vector2D;
|
|
290
125
|
exports.default = Vector2D;
|
|
126
|
+
//# sourceMappingURL=vector2d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector2d.js","sourceRoot":"","sources":["../../../src/data-structures/matrix/vector2d.ts"],"names":[],"mappings":"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"}
|
|
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./priority-queue"), exports);
|
|
18
18
|
__exportStar(require("./min-priority-queue"), exports);
|
|
19
19
|
__exportStar(require("./max-priority-queue"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data-structures/priority-queue/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,uDAAqC;AACrC,uDAAqC"}
|
|
@@ -1,39 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
2
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
29
|
exports.MaxPriorityQueue = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* The constructor initializes a priority queue with an optional comparator function.
|
|
15
|
-
* @param [options] - The `options` parameter is an optional object that can contain various properties to configure
|
|
16
|
-
* the priority queue.
|
|
17
|
-
*/
|
|
18
|
-
constructor(options) {
|
|
19
|
-
super(Object.assign(Object.assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : (a, b) => {
|
|
20
|
-
const aKey = a, bKey = b;
|
|
21
|
-
return bKey - aKey;
|
|
22
|
-
} }));
|
|
30
|
+
var priority_queue_1 = require("./priority-queue");
|
|
31
|
+
var MaxPriorityQueue = (function (_super) {
|
|
32
|
+
__extends(MaxPriorityQueue, _super);
|
|
33
|
+
function MaxPriorityQueue(options) {
|
|
34
|
+
return _super.call(this, __assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator)
|
|
35
|
+
? options.comparator
|
|
36
|
+
: function (a, b) {
|
|
37
|
+
var aKey = a, bKey = b;
|
|
38
|
+
return bKey - aKey;
|
|
39
|
+
} })) || this;
|
|
23
40
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const maxPQ = new MaxPriorityQueue(Object.assign(Object.assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : (a, b) => {
|
|
32
|
-
const aKey = a, bKey = b;
|
|
33
|
-
return bKey - aKey;
|
|
34
|
-
} }));
|
|
41
|
+
MaxPriorityQueue.heapify = function (options) {
|
|
42
|
+
var maxPQ = new MaxPriorityQueue(__assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator)
|
|
43
|
+
? options.comparator
|
|
44
|
+
: function (a, b) {
|
|
45
|
+
var aKey = a, bKey = b;
|
|
46
|
+
return bKey - aKey;
|
|
47
|
+
} }));
|
|
35
48
|
maxPQ._fix();
|
|
36
49
|
return maxPQ;
|
|
37
|
-
}
|
|
38
|
-
|
|
50
|
+
};
|
|
51
|
+
return MaxPriorityQueue;
|
|
52
|
+
}(priority_queue_1.PriorityQueue));
|
|
39
53
|
exports.MaxPriorityQueue = MaxPriorityQueue;
|
|
54
|
+
//# sourceMappingURL=max-priority-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"max-priority-queue.js","sourceRoot":"","sources":["../../../src/data-structures/priority-queue/max-priority-queue.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,mDAAiD;AAGjD;IAAkD,oCAAgB;IAShE,0BAAY,OAAgE;eAC1E,wCACK,OAAO,KACV,UAAU,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;gBAC7B,CAAC,CAAC,OAAO,CAAC,UAAU;gBACpB,CAAC,CAAC,UAAC,CAAI,EAAE,CAAI;oBACT,IAAM,IAAI,GAAG,CAAsB,EACjC,IAAI,GAAG,CAAsB,CAAC;oBAChC,OAAO,IAAI,GAAG,IAAI,CAAC;gBACrB,CAAC,IACL;IACJ,CAAC;IAWe,wBAAO,GAAvB,UAA2B,OAAgC;QACzD,IAAM,KAAK,GAAG,IAAI,gBAAgB,uBAC7B,OAAO,KACV,UAAU,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;gBAC7B,CAAC,CAAC,OAAO,CAAC,UAAU;gBACpB,CAAC,CAAC,UAAC,CAAI,EAAE,CAAI;oBACT,IAAM,IAAI,GAAG,CAAsB,EACjC,IAAI,GAAG,CAAsB,CAAC;oBAChC,OAAO,IAAI,GAAG,IAAI,CAAC;gBACrB,CAAC,IACL,CAAC;QACH,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IACH,uBAAC;AAAD,CAAC,AA7CD,CAAkD,8BAAa,GA6C9D;AA7CY,4CAAgB"}
|
|
@@ -1,40 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
2
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
29
|
exports.MinPriorityQueue = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* The constructor initializes a priority queue with an optional comparator function.
|
|
15
|
-
* @param [options] - The `options` parameter is an optional object that can contain various configuration options for
|
|
16
|
-
* the `PriorityQueue` constructor.
|
|
17
|
-
*/
|
|
18
|
-
constructor(options) {
|
|
19
|
-
super(Object.assign(Object.assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : (a, b) => {
|
|
20
|
-
const aKey = a, bKey = b;
|
|
21
|
-
return aKey - bKey;
|
|
22
|
-
} }));
|
|
30
|
+
var priority_queue_1 = require("./priority-queue");
|
|
31
|
+
var MinPriorityQueue = (function (_super) {
|
|
32
|
+
__extends(MinPriorityQueue, _super);
|
|
33
|
+
function MinPriorityQueue(options) {
|
|
34
|
+
return _super.call(this, __assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator)
|
|
35
|
+
? options.comparator
|
|
36
|
+
: function (a, b) {
|
|
37
|
+
var aKey = a, bKey = b;
|
|
38
|
+
return aKey - bKey;
|
|
39
|
+
} })) || this;
|
|
23
40
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
static heapify(options) {
|
|
32
|
-
const minPQ = new MinPriorityQueue(Object.assign(Object.assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : (a, b) => {
|
|
33
|
-
const aKey = a, bKey = b;
|
|
34
|
-
return aKey - bKey;
|
|
35
|
-
} }));
|
|
41
|
+
MinPriorityQueue.heapify = function (options) {
|
|
42
|
+
var minPQ = new MinPriorityQueue(__assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator)
|
|
43
|
+
? options.comparator
|
|
44
|
+
: function (a, b) {
|
|
45
|
+
var aKey = a, bKey = b;
|
|
46
|
+
return aKey - bKey;
|
|
47
|
+
} }));
|
|
36
48
|
minPQ._fix();
|
|
37
49
|
return minPQ;
|
|
38
|
-
}
|
|
39
|
-
|
|
50
|
+
};
|
|
51
|
+
return MinPriorityQueue;
|
|
52
|
+
}(priority_queue_1.PriorityQueue));
|
|
40
53
|
exports.MinPriorityQueue = MinPriorityQueue;
|
|
54
|
+
//# sourceMappingURL=min-priority-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"min-priority-queue.js","sourceRoot":"","sources":["../../../src/data-structures/priority-queue/min-priority-queue.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,mDAAiD;AAGjD;IAAkD,oCAAgB;IAShE,0BAAY,OAAgE;eAC1E,wCACK,OAAO,KACV,UAAU,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;gBAC7B,CAAC,CAAC,OAAO,CAAC,UAAU;gBACpB,CAAC,CAAC,UAAC,CAAI,EAAE,CAAI;oBACT,IAAM,IAAI,GAAG,CAAsB,EACjC,IAAI,GAAG,CAAsB,CAAC;oBAChC,OAAO,IAAI,GAAG,IAAI,CAAC;gBACrB,CAAC,IACL;IACJ,CAAC;IAYe,wBAAO,GAAvB,UAA2B,OAAgC;QACzD,IAAM,KAAK,GAAG,IAAI,gBAAgB,uBAC7B,OAAO,KACV,UAAU,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;gBAC7B,CAAC,CAAC,OAAO,CAAC,UAAU;gBACpB,CAAC,CAAC,UAAC,CAAI,EAAE,CAAI;oBACT,IAAM,IAAI,GAAG,CAAsB,EACjC,IAAI,GAAG,CAAsB,CAAC;oBAChC,OAAO,IAAI,GAAG,IAAI,CAAC;gBACrB,CAAC,IACL,CAAC;QACH,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IACH,uBAAC;AAAD,CAAC,AA9CD,CAAkD,8BAAa,GA8C9D;AA9CY,4CAAgB"}
|