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,110 +1,191 @@
|
|
|
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
18
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
19
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
20
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
21
|
+
function step(op) {
|
|
22
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
23
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
24
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
25
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
26
|
+
switch (op[0]) {
|
|
27
|
+
case 0: case 1: t = op; break;
|
|
28
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
29
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
30
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
31
|
+
default:
|
|
32
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
33
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
34
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
35
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
36
|
+
if (t[2]) _.ops.pop();
|
|
37
|
+
_.trys.pop(); continue;
|
|
38
|
+
}
|
|
39
|
+
op = body.call(thisArg, _);
|
|
40
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
41
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var __values = (this && this.__values) || function(o) {
|
|
45
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
46
|
+
if (m) return m.call(o);
|
|
47
|
+
if (o && typeof o.length === "number") return {
|
|
48
|
+
next: function () {
|
|
49
|
+
if (o && i >= o.length) o = void 0;
|
|
50
|
+
return { value: o && o[i++], done: !o };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
54
|
+
};
|
|
2
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Queue = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
56
|
+
exports.Queue = exports.LinkedListQueue = void 0;
|
|
57
|
+
var linked_list_1 = require("../linked-list");
|
|
58
|
+
var LinkedListQueue = (function (_super) {
|
|
59
|
+
__extends(LinkedListQueue, _super);
|
|
60
|
+
function LinkedListQueue() {
|
|
61
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
62
|
+
}
|
|
63
|
+
LinkedListQueue.prototype.enqueue = function (value) {
|
|
64
|
+
this.push(value);
|
|
65
|
+
};
|
|
66
|
+
LinkedListQueue.prototype.dequeue = function () {
|
|
67
|
+
return this.shift();
|
|
68
|
+
};
|
|
69
|
+
LinkedListQueue.prototype.peek = function () {
|
|
70
|
+
var _a;
|
|
71
|
+
return (_a = this.head) === null || _a === void 0 ? void 0 : _a.val;
|
|
72
|
+
};
|
|
73
|
+
return LinkedListQueue;
|
|
74
|
+
}(linked_list_1.SinglyLinkedList));
|
|
75
|
+
exports.LinkedListQueue = LinkedListQueue;
|
|
76
|
+
var Queue = (function () {
|
|
77
|
+
function Queue(elements) {
|
|
17
78
|
this._nodes = elements || [];
|
|
18
79
|
this._offset = 0;
|
|
19
80
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
81
|
+
Object.defineProperty(Queue.prototype, "nodes", {
|
|
82
|
+
get: function () {
|
|
83
|
+
return this._nodes;
|
|
84
|
+
},
|
|
85
|
+
set: function (value) {
|
|
86
|
+
this._nodes = value;
|
|
87
|
+
},
|
|
88
|
+
enumerable: false,
|
|
89
|
+
configurable: true
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(Queue.prototype, "offset", {
|
|
92
|
+
get: function () {
|
|
93
|
+
return this._offset;
|
|
94
|
+
},
|
|
95
|
+
set: function (value) {
|
|
96
|
+
this._offset = value;
|
|
97
|
+
},
|
|
98
|
+
enumerable: false,
|
|
99
|
+
configurable: true
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(Queue.prototype, "size", {
|
|
102
|
+
get: function () {
|
|
103
|
+
return this.nodes.length - this.offset;
|
|
104
|
+
},
|
|
105
|
+
enumerable: false,
|
|
106
|
+
configurable: true
|
|
107
|
+
});
|
|
108
|
+
Queue.fromArray = function (elements) {
|
|
29
109
|
return new Queue(elements);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* @param {T} element - The `element` parameter represents the element that you want to add to the queue.
|
|
34
|
-
* @returns The `add` method is returning a `Queue<T>` object.
|
|
35
|
-
*/
|
|
36
|
-
add(element) {
|
|
37
|
-
this._nodes.push(element);
|
|
110
|
+
};
|
|
111
|
+
Queue.prototype.push = function (element) {
|
|
112
|
+
this.nodes.push(element);
|
|
38
113
|
return this;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (this.size() === 0)
|
|
47
|
-
return null;
|
|
48
|
-
const first = this.peek();
|
|
49
|
-
this._offset += 1;
|
|
50
|
-
if (this._offset * 2 < this._nodes.length)
|
|
114
|
+
};
|
|
115
|
+
Queue.prototype.shift = function () {
|
|
116
|
+
if (this.size === 0)
|
|
117
|
+
return undefined;
|
|
118
|
+
var first = this.peek();
|
|
119
|
+
this.offset += 1;
|
|
120
|
+
if (this.offset * 2 < this.nodes.length)
|
|
51
121
|
return first;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
this._nodes = this._nodes.slice(this._offset);
|
|
55
|
-
this._offset = 0;
|
|
122
|
+
this.nodes = this.nodes.slice(this.offset);
|
|
123
|
+
this.offset = 0;
|
|
56
124
|
return first;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
125
|
+
};
|
|
126
|
+
Queue.prototype.peek = function () {
|
|
127
|
+
return this.size > 0 ? this.nodes[this.offset] : undefined;
|
|
128
|
+
};
|
|
129
|
+
Queue.prototype.peekLast = function () {
|
|
130
|
+
return this.size > 0 ? this.nodes[this.nodes.length - 1] : undefined;
|
|
131
|
+
};
|
|
132
|
+
Queue.prototype.enqueue = function (value) {
|
|
133
|
+
this.push(value);
|
|
134
|
+
};
|
|
135
|
+
Queue.prototype.dequeue = function () {
|
|
136
|
+
return this.shift();
|
|
137
|
+
};
|
|
138
|
+
Queue.prototype.getAt = function (index) {
|
|
139
|
+
return this.nodes[index];
|
|
140
|
+
};
|
|
141
|
+
Queue.prototype.isEmpty = function () {
|
|
142
|
+
return this.size === 0;
|
|
143
|
+
};
|
|
144
|
+
Queue.prototype.toArray = function () {
|
|
145
|
+
return this.nodes.slice(this.offset);
|
|
146
|
+
};
|
|
147
|
+
Queue.prototype.clear = function () {
|
|
148
|
+
this.nodes = [];
|
|
149
|
+
this.offset = 0;
|
|
150
|
+
};
|
|
151
|
+
Queue.prototype.clone = function () {
|
|
152
|
+
return new Queue(this.nodes.slice(this.offset));
|
|
153
|
+
};
|
|
154
|
+
Queue.prototype[Symbol.iterator] = function () {
|
|
155
|
+
var _a, _b, item, e_1_1;
|
|
156
|
+
var e_1, _c;
|
|
157
|
+
return __generator(this, function (_d) {
|
|
158
|
+
switch (_d.label) {
|
|
159
|
+
case 0:
|
|
160
|
+
_d.trys.push([0, 5, 6, 7]);
|
|
161
|
+
_a = __values(this.nodes), _b = _a.next();
|
|
162
|
+
_d.label = 1;
|
|
163
|
+
case 1:
|
|
164
|
+
if (!!_b.done) return [3, 4];
|
|
165
|
+
item = _b.value;
|
|
166
|
+
return [4, item];
|
|
167
|
+
case 2:
|
|
168
|
+
_d.sent();
|
|
169
|
+
_d.label = 3;
|
|
170
|
+
case 3:
|
|
171
|
+
_b = _a.next();
|
|
172
|
+
return [3, 1];
|
|
173
|
+
case 4: return [3, 7];
|
|
174
|
+
case 5:
|
|
175
|
+
e_1_1 = _d.sent();
|
|
176
|
+
e_1 = { error: e_1_1 };
|
|
177
|
+
return [3, 7];
|
|
178
|
+
case 6:
|
|
179
|
+
try {
|
|
180
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
181
|
+
}
|
|
182
|
+
finally { if (e_1) throw e_1.error; }
|
|
183
|
+
return [7];
|
|
184
|
+
case 7: return [2];
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
return Queue;
|
|
189
|
+
}());
|
|
110
190
|
exports.Queue = Queue;
|
|
191
|
+
//# sourceMappingURL=queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../../src/data-structures/queue/queue.ts"],"names":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,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAKD,qBAAK,GAAL;QACE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;IAMD,qBAAK,GAAL;QACE,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAClD,CAAC;IAEA,gBAAC,MAAM,CAAC,QAAQ,CAAC,GAAlB;;;;;;;oBACqB,KAAA,SAAA,IAAI,CAAC,KAAK,CAAA;;;;oBAAlB,IAAI;oBACb,WAAM,IAAI,EAAA;;oBAAV,SAAU,CAAC;;;;;;;;;;;;;;;;;;;KAEd;IACH,YAAC;AAAD,CAAC,AA7JD,IA6JC;AA7JY,sBAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data-structures/stack/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
|
|
@@ -1,91 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Stack = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* @copyright Tyler Zeng <zrwusa@gmail.com>
|
|
7
|
-
* @class
|
|
8
|
-
*/
|
|
9
|
-
class Stack {
|
|
10
|
-
/**
|
|
11
|
-
* The constructor initializes an array of elements, which can be provided as an optional parameter.
|
|
12
|
-
* @param {T[]} [elements] - The `elements` parameter is an optional parameter of type `T[]`, which represents an array
|
|
13
|
-
* of elements of type `T`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
|
|
14
|
-
* is provided and is an array, it is assigned to the `_elements
|
|
15
|
-
*/
|
|
16
|
-
constructor(elements) {
|
|
4
|
+
var Stack = (function () {
|
|
5
|
+
function Stack(elements) {
|
|
17
6
|
this._elements = Array.isArray(elements) ? elements : [];
|
|
18
7
|
}
|
|
19
|
-
|
|
20
|
-
* The function "fromArray" creates a new Stack object from an array of elements.
|
|
21
|
-
* @param {T[]} elements - The `elements` parameter is an array of elements of type `T`.
|
|
22
|
-
* @returns {Stack} The method is returning a new instance of the Stack class, initialized with the elements from the input
|
|
23
|
-
* array.
|
|
24
|
-
*/
|
|
25
|
-
static fromArray(elements) {
|
|
8
|
+
Stack.fromArray = function (elements) {
|
|
26
9
|
return new Stack(elements);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
* The function checks if an array is empty and returns a boolean value.
|
|
30
|
-
* @returns A boolean value indicating whether the `_elements` array is empty or not.
|
|
31
|
-
*/
|
|
32
|
-
isEmpty() {
|
|
10
|
+
};
|
|
11
|
+
Stack.prototype.isEmpty = function () {
|
|
33
12
|
return this._elements.length === 0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
* The size() function returns the number of elements in an array.
|
|
37
|
-
* @returns The size of the elements array.
|
|
38
|
-
*/
|
|
39
|
-
size() {
|
|
13
|
+
};
|
|
14
|
+
Stack.prototype.size = function () {
|
|
40
15
|
return this._elements.length;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
* The `peek` function returns the last element of an array, or null if the array is empty.
|
|
44
|
-
* @returns The `peek()` function returns the last element of the `_elements` array, or `null` if the array is empty.
|
|
45
|
-
*/
|
|
46
|
-
peek() {
|
|
16
|
+
};
|
|
17
|
+
Stack.prototype.peek = function () {
|
|
47
18
|
if (this.isEmpty())
|
|
48
19
|
return null;
|
|
49
20
|
return this._elements[this._elements.length - 1];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
* The push function adds an element to the stack and returns the updated stack.
|
|
53
|
-
* @param {T} element - The parameter "element" is of type T, which means it can be any data type.
|
|
54
|
-
* @returns The `push` method is returning the updated `Stack<T>` object.
|
|
55
|
-
*/
|
|
56
|
-
push(element) {
|
|
21
|
+
};
|
|
22
|
+
Stack.prototype.push = function (element) {
|
|
57
23
|
this._elements.push(element);
|
|
58
24
|
return this;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
* The `pop` function removes and returns the last element from an array, or returns null if the array is empty.
|
|
62
|
-
* @returns The `pop()` method is returning the last element of the array `_elements` if the array is not empty. If the
|
|
63
|
-
* array is empty, it returns `null`.
|
|
64
|
-
*/
|
|
65
|
-
pop() {
|
|
25
|
+
};
|
|
26
|
+
Stack.prototype.pop = function () {
|
|
66
27
|
if (this.isEmpty())
|
|
67
28
|
return null;
|
|
68
29
|
return this._elements.pop() || null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
* The toArray function returns a copy of the elements in an array.
|
|
72
|
-
* @returns An array of type T.
|
|
73
|
-
*/
|
|
74
|
-
toArray() {
|
|
30
|
+
};
|
|
31
|
+
Stack.prototype.toArray = function () {
|
|
75
32
|
return this._elements.slice();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
* The clear function clears the elements array.
|
|
79
|
-
*/
|
|
80
|
-
clear() {
|
|
33
|
+
};
|
|
34
|
+
Stack.prototype.clear = function () {
|
|
81
35
|
this._elements = [];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
* The `clone()` function returns a new `Stack` object with the same elements as the original stack.
|
|
85
|
-
* @returns The `clone()` method is returning a new `Stack` object with a copy of the `_elements` array.
|
|
86
|
-
*/
|
|
87
|
-
clone() {
|
|
36
|
+
};
|
|
37
|
+
Stack.prototype.clone = function () {
|
|
88
38
|
return new Stack(this._elements.slice());
|
|
89
|
-
}
|
|
90
|
-
|
|
39
|
+
};
|
|
40
|
+
return Stack;
|
|
41
|
+
}());
|
|
91
42
|
exports.Stack = Stack;
|
|
43
|
+
//# sourceMappingURL=stack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../src/data-structures/stack/stack.ts"],"names":[],"mappings":";;;AAKA;IASE,eAAY,QAAc;QACxB,IAAI,CAAC,SAAS,GAAG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../../src/data-structures/tree/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB"}
|
|
@@ -1,31 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TreeNode = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
var TreeNode = (function () {
|
|
5
|
+
function TreeNode(id, value, children) {
|
|
6
6
|
this._id = id;
|
|
7
7
|
this._value = value || undefined;
|
|
8
8
|
this._children = children || [];
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
Object.defineProperty(TreeNode.prototype, "id", {
|
|
11
|
+
get: function () {
|
|
12
|
+
return this._id;
|
|
13
|
+
},
|
|
14
|
+
set: function (value) {
|
|
15
|
+
this._id = value;
|
|
16
|
+
},
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(TreeNode.prototype, "value", {
|
|
21
|
+
get: function () {
|
|
22
|
+
return this._value;
|
|
23
|
+
},
|
|
24
|
+
set: function (value) {
|
|
25
|
+
this._value = value;
|
|
26
|
+
},
|
|
27
|
+
enumerable: false,
|
|
28
|
+
configurable: true
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(TreeNode.prototype, "children", {
|
|
31
|
+
get: function () {
|
|
32
|
+
return this._children;
|
|
33
|
+
},
|
|
34
|
+
set: function (value) {
|
|
35
|
+
this._children = value;
|
|
36
|
+
},
|
|
37
|
+
enumerable: false,
|
|
38
|
+
configurable: true
|
|
39
|
+
});
|
|
40
|
+
TreeNode.prototype.addChildren = function (children) {
|
|
29
41
|
if (!this.children) {
|
|
30
42
|
this.children = [];
|
|
31
43
|
}
|
|
@@ -35,26 +47,27 @@ class TreeNode {
|
|
|
35
47
|
else {
|
|
36
48
|
this.children = this.children.concat(children);
|
|
37
49
|
}
|
|
38
|
-
}
|
|
39
|
-
getHeight() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let maxDepth = 1;
|
|
50
|
+
};
|
|
51
|
+
TreeNode.prototype.getHeight = function () {
|
|
52
|
+
var beginRoot = this;
|
|
53
|
+
var maxDepth = 1;
|
|
43
54
|
if (beginRoot) {
|
|
44
|
-
|
|
55
|
+
var bfs_1 = function (node, level) {
|
|
45
56
|
if (level > maxDepth) {
|
|
46
57
|
maxDepth = level;
|
|
47
58
|
}
|
|
48
|
-
|
|
59
|
+
var children = node.children;
|
|
49
60
|
if (children) {
|
|
50
|
-
for (
|
|
51
|
-
|
|
61
|
+
for (var i = 0, len = children.length; i < len; i++) {
|
|
62
|
+
bfs_1(children[i], level + 1);
|
|
52
63
|
}
|
|
53
64
|
}
|
|
54
65
|
};
|
|
55
|
-
|
|
66
|
+
bfs_1(beginRoot, 1);
|
|
56
67
|
}
|
|
57
68
|
return maxDepth;
|
|
58
|
-
}
|
|
59
|
-
|
|
69
|
+
};
|
|
70
|
+
return TreeNode;
|
|
71
|
+
}());
|
|
60
72
|
exports.TreeNode = TreeNode;
|
|
73
|
+
//# sourceMappingURL=tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/data-structures/tree/tree.ts"],"names":[],"mappings":";;;AAAA;IACE,kBAAY,EAAU,EAAE,KAAS,EAAE,QAAwB;QACzD,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,KAAK,IAAI,SAAS,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,QAAQ,IAAI,EAAE,CAAC;IAClC,CAAC;IAID,sBAAI,wBAAE;aAAN;Y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