data-structure-typed 1.40.0-rc → 1.41.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/.eslintrc.js +7 -5
- package/.github/workflows/ci.yml +2 -20
- package/.travis.yml +3 -4
- package/CHANGELOG.md +23 -1
- package/CONTRIBUTING.md +13 -0
- package/README.md +20 -11
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +106 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +348 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +149 -0
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +270 -0
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +363 -0
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +1136 -0
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +167 -0
- package/dist/cjs/data-structures/binary-tree/bst.js +513 -0
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/index.d.ts +7 -0
- package/dist/cjs/data-structures/binary-tree/index.js +24 -0
- package/dist/cjs/data-structures/binary-tree/index.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +97 -0
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +389 -0
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +67 -0
- package/dist/cjs/data-structures/binary-tree/segment-tree.js +181 -0
- package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/tree-multiset.d.ts +126 -0
- package/dist/cjs/data-structures/binary-tree/tree-multiset.js +356 -0
- package/dist/cjs/data-structures/binary-tree/tree-multiset.js.map +1 -0
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +313 -0
- package/dist/cjs/data-structures/graph/abstract-graph.js +885 -0
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -0
- package/dist/cjs/data-structures/graph/directed-graph.d.ts +194 -0
- package/dist/cjs/data-structures/graph/directed-graph.js +405 -0
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -0
- package/dist/cjs/data-structures/graph/index.js.map +1 -0
- package/dist/cjs/data-structures/graph/map-graph.d.ts +73 -0
- package/dist/cjs/data-structures/graph/map-graph.js +94 -0
- package/dist/cjs/data-structures/graph/map-graph.js.map +1 -0
- package/dist/cjs/data-structures/graph/undirected-graph.d.ts +120 -0
- package/dist/cjs/data-structures/graph/undirected-graph.js +240 -0
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -0
- package/dist/cjs/data-structures/hash/coordinate-map.d.ts +44 -0
- package/dist/cjs/data-structures/hash/coordinate-map.js +63 -0
- package/dist/cjs/data-structures/hash/coordinate-map.js.map +1 -0
- package/dist/cjs/data-structures/hash/coordinate-set.d.ts +36 -0
- package/dist/cjs/data-structures/hash/coordinate-set.js +53 -0
- package/dist/cjs/data-structures/hash/coordinate-set.js.map +1 -0
- package/dist/cjs/data-structures/hash/hash-map.d.ts +50 -0
- package/dist/cjs/data-structures/hash/hash-map.js +154 -0
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -0
- package/dist/cjs/data-structures/hash/hash-table.d.ts +103 -0
- package/dist/cjs/data-structures/hash/hash-table.js +237 -0
- package/dist/cjs/data-structures/hash/hash-table.js.map +1 -0
- package/dist/cjs/data-structures/hash/index.d.ts +6 -0
- package/dist/cjs/data-structures/hash/index.js +23 -0
- package/dist/cjs/data-structures/hash/index.js.map +1 -0
- package/dist/cjs/data-structures/hash/tree-map.js.map +1 -0
- package/dist/cjs/data-structures/hash/tree-set.js.map +1 -0
- package/dist/cjs/data-structures/heap/heap.d.ts +235 -0
- package/dist/cjs/data-structures/heap/heap.js +516 -0
- package/dist/cjs/data-structures/heap/heap.js.map +1 -0
- package/dist/cjs/data-structures/heap/index.js.map +1 -0
- package/dist/cjs/data-structures/heap/max-heap.d.ts +15 -0
- package/dist/cjs/data-structures/heap/max-heap.js +27 -0
- package/dist/cjs/data-structures/heap/max-heap.js.map +1 -0
- package/dist/cjs/data-structures/heap/min-heap.d.ts +15 -0
- package/dist/cjs/data-structures/heap/min-heap.js +27 -0
- package/dist/cjs/data-structures/heap/min-heap.js.map +1 -0
- package/dist/cjs/data-structures/index.js.map +1 -0
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +253 -0
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +570 -0
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -0
- package/dist/cjs/data-structures/linked-list/index.js.map +1 -0
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +232 -0
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +534 -0
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -0
- package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +80 -0
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js +188 -0
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -0
- package/dist/cjs/data-structures/matrix/index.js.map +1 -0
- package/dist/cjs/data-structures/matrix/matrix.d.ts +21 -0
- package/dist/cjs/data-structures/matrix/matrix.js.map +1 -0
- package/dist/cjs/data-structures/matrix/matrix2d.d.ts +107 -0
- package/dist/cjs/data-structures/matrix/matrix2d.js +200 -0
- package/dist/cjs/data-structures/matrix/matrix2d.js.map +1 -0
- package/dist/cjs/data-structures/matrix/navigator.d.ts +52 -0
- package/dist/cjs/data-structures/matrix/navigator.js.map +1 -0
- package/dist/cjs/data-structures/matrix/vector2d.d.ts +200 -0
- package/dist/cjs/data-structures/matrix/vector2d.js +291 -0
- package/dist/cjs/data-structures/matrix/vector2d.js.map +1 -0
- package/dist/cjs/data-structures/priority-queue/index.js.map +1 -0
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +15 -0
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +27 -0
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -0
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +15 -0
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +27 -0
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -0
- package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +15 -0
- package/dist/cjs/data-structures/priority-queue/priority-queue.js +18 -0
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -0
- package/dist/cjs/data-structures/queue/deque.d.ts +161 -0
- package/dist/cjs/data-structures/queue/deque.js +265 -0
- package/dist/cjs/data-structures/queue/deque.js.map +1 -0
- package/dist/cjs/data-structures/queue/index.js.map +1 -0
- package/dist/cjs/data-structures/queue/queue.d.ts +122 -0
- package/dist/cjs/data-structures/queue/queue.js +188 -0
- package/dist/cjs/data-structures/queue/queue.js.map +1 -0
- package/dist/cjs/data-structures/stack/index.js.map +1 -0
- package/dist/cjs/data-structures/stack/stack.d.ts +64 -0
- package/dist/cjs/data-structures/stack/stack.js +95 -0
- package/dist/cjs/data-structures/stack/stack.js.map +1 -0
- package/dist/cjs/data-structures/tree/index.js.map +1 -0
- package/dist/cjs/data-structures/tree/tree.d.ts +8 -0
- package/dist/cjs/data-structures/tree/tree.js +41 -0
- package/dist/cjs/data-structures/tree/tree.js.map +1 -0
- package/dist/cjs/data-structures/trie/index.js.map +1 -0
- package/dist/cjs/data-structures/trie/trie.d.ts +79 -0
- package/dist/cjs/data-structures/trie/trie.js +252 -0
- package/dist/cjs/data-structures/trie/trie.js.map +1 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interfaces/binary-tree.d.ts +7 -0
- package/dist/cjs/interfaces/binary-tree.js.map +1 -0
- package/dist/cjs/interfaces/doubly-linked-list.js.map +1 -0
- package/dist/cjs/interfaces/graph.d.ts +5 -0
- package/dist/cjs/interfaces/graph.js +3 -0
- package/dist/cjs/interfaces/graph.js.map +1 -0
- package/dist/cjs/interfaces/heap.js.map +1 -0
- package/dist/cjs/interfaces/index.d.ts +8 -0
- package/dist/cjs/interfaces/index.js +25 -0
- package/dist/cjs/interfaces/index.js.map +1 -0
- package/dist/cjs/interfaces/navigator.js.map +1 -0
- package/dist/cjs/interfaces/priority-queue.js.map +1 -0
- package/dist/cjs/interfaces/segment-tree.js.map +1 -0
- package/dist/cjs/interfaces/singly-linked-list.js.map +1 -0
- package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +4 -0
- package/dist/cjs/types/data-structures/binary-tree/avl-tree.js.map +1 -0
- package/dist/cjs/types/data-structures/binary-tree/binary-indexed-tree.js +3 -0
- package/dist/cjs/types/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +25 -0
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +1 -0
- package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +7 -0
- package/dist/cjs/types/data-structures/binary-tree/bst.js.map +1 -0
- package/dist/cjs/types/data-structures/binary-tree/index.d.ts +6 -0
- package/dist/cjs/types/data-structures/binary-tree/index.js +23 -0
- package/dist/cjs/types/data-structures/binary-tree/index.js.map +1 -0
- package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +4 -0
- package/dist/cjs/types/data-structures/binary-tree/rb-tree.js +14 -0
- package/dist/cjs/types/data-structures/binary-tree/rb-tree.js.map +1 -0
- package/dist/cjs/types/data-structures/binary-tree/segment-tree.js.map +1 -0
- package/dist/cjs/types/data-structures/binary-tree/tree-multiset.d.ts +4 -0
- package/dist/cjs/types/data-structures/binary-tree/tree-multiset.js.map +1 -0
- package/dist/cjs/types/data-structures/graph/abstract-graph.d.ts +10 -0
- package/dist/cjs/types/data-structures/graph/abstract-graph.js.map +1 -0
- package/dist/cjs/types/data-structures/graph/directed-graph.js.map +1 -0
- package/dist/cjs/types/data-structures/graph/index.d.ts +3 -0
- package/dist/cjs/types/data-structures/graph/index.js +20 -0
- package/dist/cjs/types/data-structures/graph/index.js.map +1 -0
- package/dist/cjs/types/data-structures/graph/map-graph.js.map +1 -0
- package/dist/cjs/types/data-structures/graph/undirected-graph.js.map +1 -0
- package/dist/cjs/types/data-structures/hash/coordinate-map.js +3 -0
- package/dist/cjs/types/data-structures/hash/coordinate-map.js.map +1 -0
- package/dist/cjs/types/data-structures/hash/coordinate-set.js +3 -0
- package/dist/cjs/types/data-structures/hash/coordinate-set.js.map +1 -0
- package/dist/cjs/types/data-structures/hash/hash-map.js +3 -0
- package/dist/cjs/types/data-structures/hash/hash-map.js.map +1 -0
- package/dist/cjs/types/data-structures/hash/hash-table.js +3 -0
- package/dist/cjs/types/data-structures/hash/hash-table.js.map +1 -0
- package/dist/cjs/types/data-structures/hash/index.js +3 -0
- package/dist/cjs/types/data-structures/hash/index.js.map +1 -0
- package/dist/cjs/types/data-structures/hash/tree-map.js +3 -0
- package/dist/cjs/types/data-structures/hash/tree-map.js.map +1 -0
- package/dist/cjs/types/data-structures/hash/tree-set.js +3 -0
- package/dist/cjs/types/data-structures/hash/tree-set.js.map +1 -0
- package/dist/cjs/types/data-structures/heap/heap.js.map +1 -0
- package/dist/cjs/types/data-structures/heap/index.d.ts +1 -0
- package/dist/cjs/types/data-structures/heap/index.js +18 -0
- package/dist/cjs/types/data-structures/heap/index.js.map +1 -0
- package/dist/cjs/types/data-structures/heap/max-heap.js +3 -0
- package/dist/cjs/types/data-structures/heap/max-heap.js.map +1 -0
- package/dist/cjs/types/data-structures/heap/min-heap.js +3 -0
- package/dist/cjs/types/data-structures/heap/min-heap.js.map +1 -0
- package/dist/cjs/types/data-structures/index.d.ts +11 -0
- package/dist/cjs/types/data-structures/index.js +28 -0
- package/dist/cjs/types/data-structures/index.js.map +1 -0
- package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.js.map +1 -0
- package/dist/cjs/types/data-structures/linked-list/index.d.ts +2 -0
- package/dist/cjs/types/data-structures/linked-list/index.js +19 -0
- package/dist/cjs/types/data-structures/linked-list/index.js.map +1 -0
- package/dist/cjs/types/data-structures/linked-list/singly-linked-list.js.map +1 -0
- package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js +3 -0
- package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js.map +1 -0
- package/dist/cjs/types/data-structures/matrix/index.d.ts +1 -0
- package/dist/cjs/types/data-structures/matrix/index.js +18 -0
- package/dist/cjs/types/data-structures/matrix/index.js.map +1 -0
- package/dist/cjs/types/data-structures/matrix/matrix.js +3 -0
- package/dist/cjs/types/data-structures/matrix/matrix.js.map +1 -0
- package/dist/cjs/types/data-structures/matrix/matrix2d.js +3 -0
- package/dist/cjs/types/data-structures/matrix/matrix2d.js.map +1 -0
- package/dist/cjs/types/data-structures/matrix/navigator.js.map +1 -0
- package/dist/cjs/types/data-structures/matrix/vector2d.js +3 -0
- package/dist/cjs/types/data-structures/matrix/vector2d.js.map +1 -0
- package/dist/cjs/types/data-structures/priority-queue/index.js +20 -0
- package/dist/cjs/types/data-structures/priority-queue/index.js.map +1 -0
- package/dist/cjs/types/data-structures/priority-queue/max-priority-queue.js +3 -0
- package/dist/cjs/types/data-structures/priority-queue/max-priority-queue.js.map +1 -0
- package/dist/cjs/types/data-structures/priority-queue/min-priority-queue.js +3 -0
- package/dist/cjs/types/data-structures/priority-queue/min-priority-queue.js.map +1 -0
- package/dist/cjs/types/data-structures/priority-queue/priority-queue.js.map +1 -0
- package/dist/cjs/types/data-structures/queue/deque.js +3 -0
- package/dist/cjs/types/data-structures/queue/deque.js.map +1 -0
- package/dist/cjs/types/data-structures/queue/index.js +19 -0
- package/dist/cjs/types/data-structures/queue/index.js.map +1 -0
- package/dist/cjs/types/data-structures/queue/queue.js +3 -0
- package/dist/cjs/types/data-structures/queue/queue.js.map +1 -0
- package/dist/cjs/types/data-structures/stack/index.js +18 -0
- package/dist/cjs/types/data-structures/stack/index.js.map +1 -0
- package/dist/cjs/types/data-structures/stack/stack.js +3 -0
- package/dist/cjs/types/data-structures/stack/stack.js.map +1 -0
- package/dist/cjs/types/data-structures/tree/index.js +18 -0
- package/dist/cjs/types/data-structures/tree/index.js.map +1 -0
- package/dist/cjs/types/data-structures/tree/tree.js +3 -0
- package/dist/cjs/types/data-structures/tree/tree.js.map +1 -0
- package/dist/cjs/types/data-structures/trie/index.js +18 -0
- package/dist/cjs/types/data-structures/trie/index.js.map +1 -0
- package/dist/cjs/types/data-structures/trie/trie.js +3 -0
- package/dist/cjs/types/data-structures/trie/trie.js.map +1 -0
- package/dist/cjs/types/helpers.d.ts +8 -0
- package/dist/cjs/types/helpers.js +10 -0
- package/dist/cjs/types/helpers.js.map +1 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/utils/index.js.map +1 -0
- package/dist/cjs/types/utils/utils.js.map +1 -0
- package/dist/cjs/types/utils/validate-type.js.map +1 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/utils.d.ts +20 -0
- package/dist/cjs/utils/utils.js +74 -0
- package/dist/cjs/utils/utils.js.map +1 -0
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +106 -0
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +348 -0
- package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.d.ts +149 -0
- package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js +274 -0
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +363 -0
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +1147 -0
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +167 -0
- package/dist/mjs/data-structures/binary-tree/bst.js +509 -0
- package/dist/mjs/data-structures/binary-tree/index.d.ts +7 -0
- package/dist/mjs/data-structures/binary-tree/index.js +23 -0
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +97 -0
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +393 -0
- package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +67 -0
- package/dist/mjs/data-structures/binary-tree/segment-tree.js +182 -0
- package/dist/mjs/data-structures/binary-tree/tree-multiset.d.ts +126 -0
- package/dist/mjs/data-structures/binary-tree/tree-multiset.js +356 -0
- package/dist/mjs/data-structures/graph/abstract-graph.d.ts +313 -0
- package/dist/mjs/data-structures/graph/abstract-graph.js +883 -0
- package/dist/mjs/data-structures/graph/directed-graph.d.ts +194 -0
- package/dist/mjs/data-structures/graph/directed-graph.js +406 -0
- package/dist/mjs/data-structures/graph/index.js +20 -0
- package/dist/mjs/data-structures/graph/map-graph.d.ts +73 -0
- package/dist/mjs/data-structures/graph/map-graph.js +96 -0
- package/dist/mjs/data-structures/graph/undirected-graph.d.ts +120 -0
- package/dist/mjs/data-structures/graph/undirected-graph.js +239 -0
- package/dist/mjs/data-structures/hash/coordinate-map.d.ts +44 -0
- package/dist/mjs/data-structures/hash/coordinate-map.js +62 -0
- package/dist/mjs/data-structures/hash/coordinate-set.d.ts +36 -0
- package/dist/mjs/data-structures/hash/coordinate-set.js +52 -0
- package/dist/mjs/data-structures/hash/hash-map.d.ts +50 -0
- package/dist/mjs/data-structures/hash/hash-map.js +159 -0
- package/dist/mjs/data-structures/hash/hash-table.d.ts +103 -0
- package/dist/mjs/data-structures/hash/hash-table.js +243 -0
- package/dist/mjs/data-structures/hash/index.d.ts +6 -0
- package/dist/mjs/data-structures/hash/index.js +22 -0
- package/dist/mjs/data-structures/hash/tree-map.js +6 -0
- package/dist/mjs/data-structures/hash/tree-set.js +6 -0
- package/dist/mjs/data-structures/heap/heap.d.ts +235 -0
- package/dist/mjs/data-structures/heap/heap.js +525 -0
- package/dist/mjs/data-structures/heap/index.js +19 -0
- package/dist/mjs/data-structures/heap/max-heap.d.ts +15 -0
- package/dist/mjs/data-structures/heap/max-heap.js +26 -0
- package/dist/mjs/data-structures/heap/min-heap.d.ts +15 -0
- package/dist/mjs/data-structures/heap/min-heap.js +26 -0
- package/dist/mjs/data-structures/index.js +27 -0
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +253 -0
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +573 -0
- package/dist/mjs/data-structures/linked-list/index.js +19 -0
- package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +232 -0
- package/dist/mjs/data-structures/linked-list/singly-linked-list.js +538 -0
- package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +80 -0
- package/dist/mjs/data-structures/linked-list/skip-linked-list.js +194 -0
- package/dist/mjs/data-structures/matrix/index.js +20 -0
- package/dist/mjs/data-structures/matrix/matrix.d.ts +21 -0
- package/dist/mjs/data-structures/matrix/matrix.js +29 -0
- package/dist/mjs/data-structures/matrix/matrix2d.d.ts +107 -0
- package/dist/mjs/data-structures/matrix/matrix2d.js +200 -0
- package/dist/mjs/data-structures/matrix/navigator.d.ts +52 -0
- package/dist/mjs/data-structures/matrix/navigator.js +113 -0
- package/dist/mjs/data-structures/matrix/vector2d.d.ts +200 -0
- package/dist/mjs/data-structures/matrix/vector2d.js +293 -0
- package/dist/mjs/data-structures/priority-queue/index.js +19 -0
- package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +15 -0
- package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +26 -0
- package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +15 -0
- package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +26 -0
- package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +15 -0
- package/dist/mjs/data-structures/priority-queue/priority-queue.js +17 -0
- package/dist/mjs/data-structures/queue/deque.d.ts +161 -0
- package/dist/mjs/data-structures/queue/deque.js +257 -0
- package/dist/mjs/data-structures/queue/index.js +18 -0
- package/dist/mjs/data-structures/queue/queue.d.ts +122 -0
- package/dist/mjs/data-structures/queue/queue.js +188 -0
- package/dist/mjs/data-structures/stack/index.js +17 -0
- package/dist/mjs/data-structures/stack/stack.d.ts +64 -0
- package/dist/mjs/data-structures/stack/stack.js +95 -0
- package/dist/mjs/data-structures/tree/index.js +17 -0
- package/dist/mjs/data-structures/tree/tree.d.ts +8 -0
- package/dist/mjs/data-structures/tree/tree.js +43 -0
- package/dist/mjs/data-structures/trie/index.js +17 -0
- package/dist/mjs/data-structures/trie/trie.d.ts +79 -0
- package/dist/mjs/data-structures/trie/trie.js +256 -0
- package/dist/mjs/index.js +20 -0
- package/dist/mjs/interfaces/binary-tree.d.ts +7 -0
- package/dist/mjs/interfaces/binary-tree.js +2 -0
- package/dist/mjs/interfaces/doubly-linked-list.js +2 -0
- package/dist/mjs/interfaces/graph.d.ts +5 -0
- package/dist/mjs/interfaces/graph.js +2 -0
- package/dist/mjs/interfaces/heap.js +2 -0
- package/dist/mjs/interfaces/index.d.ts +8 -0
- package/dist/mjs/interfaces/index.js +24 -0
- package/dist/mjs/interfaces/navigator.js +2 -0
- package/dist/mjs/interfaces/priority-queue.js +2 -0
- package/dist/mjs/interfaces/segment-tree.js +2 -0
- package/dist/mjs/interfaces/singly-linked-list.js +2 -0
- package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +4 -0
- package/dist/mjs/types/data-structures/binary-tree/avl-tree.js +2 -0
- package/dist/mjs/types/data-structures/binary-tree/binary-indexed-tree.js +2 -0
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.js +24 -0
- package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +7 -0
- package/dist/mjs/types/data-structures/binary-tree/bst.js +2 -0
- package/dist/mjs/types/data-structures/binary-tree/index.d.ts +6 -0
- package/dist/mjs/types/data-structures/binary-tree/index.js +22 -0
- package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +4 -0
- package/dist/mjs/types/data-structures/binary-tree/rb-tree.js +13 -0
- package/dist/mjs/types/data-structures/binary-tree/segment-tree.js +2 -0
- package/dist/mjs/types/data-structures/binary-tree/tree-multiset.d.ts +4 -0
- package/dist/mjs/types/data-structures/binary-tree/tree-multiset.js +2 -0
- package/dist/mjs/types/data-structures/graph/abstract-graph.d.ts +10 -0
- package/dist/mjs/types/data-structures/graph/abstract-graph.js +2 -0
- package/dist/mjs/types/data-structures/graph/directed-graph.js +9 -0
- package/dist/mjs/types/data-structures/graph/index.d.ts +3 -0
- package/dist/mjs/types/data-structures/graph/index.js +19 -0
- package/dist/mjs/types/data-structures/graph/map-graph.js +2 -0
- package/dist/mjs/types/data-structures/graph/undirected-graph.js +2 -0
- package/dist/mjs/types/data-structures/hash/coordinate-map.js +2 -0
- package/dist/mjs/types/data-structures/hash/coordinate-set.js +2 -0
- package/dist/mjs/types/data-structures/hash/hash-map.js +2 -0
- package/dist/mjs/types/data-structures/hash/hash-table.js +2 -0
- package/dist/mjs/types/data-structures/hash/index.js +2 -0
- package/dist/mjs/types/data-structures/hash/tree-map.js +2 -0
- package/dist/mjs/types/data-structures/hash/tree-set.js +2 -0
- package/dist/mjs/types/data-structures/heap/heap.js +2 -0
- package/dist/mjs/types/data-structures/heap/index.d.ts +1 -0
- package/dist/mjs/types/data-structures/heap/index.js +17 -0
- package/dist/mjs/types/data-structures/heap/max-heap.js +2 -0
- package/dist/mjs/types/data-structures/heap/min-heap.js +2 -0
- package/dist/mjs/types/data-structures/index.d.ts +11 -0
- package/dist/mjs/types/data-structures/index.js +27 -0
- package/dist/mjs/types/data-structures/linked-list/doubly-linked-list.js +2 -0
- package/dist/mjs/types/data-structures/linked-list/index.d.ts +2 -0
- package/dist/mjs/types/data-structures/linked-list/index.js +18 -0
- package/dist/mjs/types/data-structures/linked-list/singly-linked-list.js +2 -0
- package/dist/mjs/types/data-structures/linked-list/skip-linked-list.d.ts +1 -0
- package/dist/mjs/types/data-structures/linked-list/skip-linked-list.js +2 -0
- package/dist/mjs/types/data-structures/matrix/index.d.ts +1 -0
- package/dist/mjs/types/data-structures/matrix/index.js +17 -0
- package/dist/mjs/types/data-structures/matrix/matrix.d.ts +1 -0
- package/dist/mjs/types/data-structures/matrix/matrix.js +2 -0
- package/dist/mjs/types/data-structures/matrix/matrix2d.d.ts +1 -0
- package/dist/mjs/types/data-structures/matrix/matrix2d.js +2 -0
- package/dist/mjs/types/data-structures/matrix/navigator.js +2 -0
- package/dist/mjs/types/data-structures/matrix/vector2d.d.ts +1 -0
- package/dist/mjs/types/data-structures/matrix/vector2d.js +2 -0
- package/dist/mjs/types/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/mjs/types/data-structures/priority-queue/index.js +19 -0
- package/dist/mjs/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
- package/dist/mjs/types/data-structures/priority-queue/max-priority-queue.js +2 -0
- package/dist/mjs/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
- package/dist/mjs/types/data-structures/priority-queue/min-priority-queue.js +2 -0
- package/dist/mjs/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/mjs/types/data-structures/priority-queue/priority-queue.js +2 -0
- package/dist/mjs/types/data-structures/queue/deque.d.ts +1 -0
- package/dist/mjs/types/data-structures/queue/deque.js +2 -0
- package/dist/mjs/types/data-structures/queue/index.d.ts +2 -0
- package/dist/mjs/types/data-structures/queue/index.js +18 -0
- package/dist/mjs/types/data-structures/queue/queue.d.ts +1 -0
- package/dist/mjs/types/data-structures/queue/queue.js +2 -0
- package/dist/mjs/types/data-structures/stack/index.d.ts +1 -0
- package/dist/mjs/types/data-structures/stack/index.js +17 -0
- package/dist/mjs/types/data-structures/stack/stack.d.ts +1 -0
- package/dist/mjs/types/data-structures/stack/stack.js +2 -0
- package/dist/mjs/types/data-structures/tree/index.d.ts +1 -0
- package/dist/mjs/types/data-structures/tree/index.js +17 -0
- package/dist/mjs/types/data-structures/tree/tree.d.ts +1 -0
- package/dist/mjs/types/data-structures/tree/tree.js +2 -0
- package/dist/mjs/types/data-structures/trie/index.d.ts +1 -0
- package/dist/mjs/types/data-structures/trie/index.js +17 -0
- package/dist/mjs/types/data-structures/trie/trie.d.ts +1 -0
- package/dist/mjs/types/data-structures/trie/trie.js +2 -0
- package/dist/mjs/types/helpers.d.ts +8 -0
- package/dist/mjs/types/helpers.js +9 -0
- package/dist/mjs/types/index.js +19 -0
- package/dist/mjs/types/utils/index.js +18 -0
- package/dist/mjs/types/utils/utils.js +2 -0
- package/dist/mjs/types/utils/validate-type.js +2 -0
- package/dist/mjs/utils/index.js +17 -0
- package/dist/mjs/utils/utils.d.ts +20 -0
- package/dist/mjs/utils/utils.js +64 -0
- package/dist/umd/data-structure-typed.min.js +27 -0
- package/dist/umd/data-structure-typed.min.js.map +1 -0
- package/package.json +28 -22
- package/src/data-structures/binary-tree/avl-tree.ts +88 -74
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +265 -35
- package/src/data-structures/binary-tree/binary-tree.ts +1263 -26
- package/src/data-structures/binary-tree/bst.ts +217 -237
- package/src/data-structures/binary-tree/index.ts +0 -5
- package/src/data-structures/binary-tree/rb-tree.ts +416 -356
- package/src/data-structures/binary-tree/segment-tree.ts +25 -92
- package/src/data-structures/binary-tree/tree-multiset.ts +113 -422
- package/src/data-structures/graph/abstract-graph.ts +169 -214
- package/src/data-structures/graph/directed-graph.ts +105 -126
- package/src/data-structures/graph/map-graph.ts +29 -57
- package/src/data-structures/graph/undirected-graph.ts +67 -82
- package/src/data-structures/hash/coordinate-map.ts +0 -4
- package/src/data-structures/hash/coordinate-set.ts +0 -4
- package/src/data-structures/hash/hash-map.ts +65 -83
- package/src/data-structures/hash/hash-table.ts +109 -118
- package/src/data-structures/hash/index.ts +0 -1
- package/src/data-structures/hash/tree-map.ts +2 -1
- package/src/data-structures/hash/tree-set.ts +2 -1
- package/src/data-structures/heap/heap.ts +505 -128
- package/src/data-structures/heap/max-heap.ts +16 -21
- package/src/data-structures/heap/min-heap.ts +16 -22
- package/src/data-structures/linked-list/doubly-linked-list.ts +143 -174
- package/src/data-structures/linked-list/singly-linked-list.ts +174 -99
- package/src/data-structures/linked-list/skip-linked-list.ts +104 -49
- package/src/data-structures/matrix/matrix.ts +2 -2
- package/src/data-structures/matrix/matrix2d.ts +12 -14
- package/src/data-structures/matrix/navigator.ts +4 -4
- package/src/data-structures/matrix/vector2d.ts +2 -3
- package/src/data-structures/priority-queue/max-priority-queue.ts +15 -46
- package/src/data-structures/priority-queue/min-priority-queue.ts +15 -47
- package/src/data-structures/priority-queue/priority-queue.ts +7 -350
- package/src/data-structures/queue/deque.ts +62 -77
- package/src/data-structures/queue/queue.ts +39 -21
- package/src/data-structures/stack/stack.ts +13 -9
- package/src/data-structures/tree/tree.ts +10 -38
- package/src/data-structures/trie/trie.ts +108 -71
- package/src/interfaces/binary-tree.ts +7 -4
- package/src/interfaces/graph.ts +7 -0
- package/src/interfaces/index.ts +1 -8
- package/src/types/data-structures/binary-tree/avl-tree.ts +5 -0
- package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
- package/src/types/data-structures/binary-tree/binary-tree.ts +31 -0
- package/src/types/data-structures/binary-tree/bst.ts +11 -0
- package/src/types/data-structures/binary-tree/index.ts +6 -0
- package/src/types/data-structures/binary-tree/rb-tree.ts +8 -0
- package/src/types/data-structures/binary-tree/tree-multiset.ts +6 -0
- package/src/types/data-structures/graph/abstract-graph.ts +11 -0
- package/src/types/data-structures/graph/index.ts +3 -0
- package/src/types/data-structures/graph/undirected-graph.ts +1 -0
- package/src/types/data-structures/hash/coordinate-map.ts +1 -0
- package/src/types/data-structures/hash/coordinate-set.ts +1 -0
- package/src/types/data-structures/hash/hash-map.ts +1 -0
- package/src/types/data-structures/hash/hash-table.ts +1 -0
- package/src/types/data-structures/hash/tree-map.ts +1 -0
- package/src/types/data-structures/hash/tree-set.ts +1 -0
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/heap/index.ts +1 -0
- package/src/types/data-structures/heap/max-heap.ts +1 -0
- package/src/types/data-structures/heap/min-heap.ts +1 -0
- package/src/types/data-structures/index.ts +8 -13
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -0
- package/src/types/data-structures/linked-list/index.ts +2 -0
- package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -0
- package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
- package/src/types/data-structures/matrix/index.ts +1 -0
- package/src/types/data-structures/matrix/matrix.ts +1 -0
- package/src/types/data-structures/matrix/matrix2d.ts +1 -0
- package/src/types/data-structures/matrix/navigator.ts +14 -0
- package/src/types/data-structures/matrix/vector2d.ts +1 -0
- package/src/types/data-structures/priority-queue/index.ts +3 -0
- package/src/types/data-structures/priority-queue/max-priority-queue.ts +1 -0
- package/src/types/data-structures/priority-queue/min-priority-queue.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/data-structures/queue/deque.ts +1 -0
- package/src/types/data-structures/queue/index.ts +2 -0
- package/src/types/data-structures/queue/queue.ts +1 -0
- package/src/types/data-structures/stack/index.ts +1 -0
- package/src/types/data-structures/stack/stack.ts +1 -0
- package/src/types/data-structures/tree/index.ts +1 -0
- package/src/types/data-structures/tree/tree.ts +1 -0
- package/src/types/data-structures/trie/index.ts +1 -0
- package/src/types/data-structures/trie/trie.ts +1 -0
- package/src/types/helpers.ts +11 -1
- package/src/types/utils/utils.ts +1 -1
- package/src/types/utils/validate-type.ts +2 -2
- package/src/utils/utils.ts +7 -0
- package/test/config.js +4 -0
- package/test/config.ts +1 -0
- package/test/integration/avl-tree.test.ts +24 -22
- package/test/integration/bst.test.ts +52 -47
- package/test/integration/index.html +3 -4
- package/test/types/index.js +29 -0
- package/test/types/utils/big-o.js +2 -0
- package/test/types/utils/big-o.ts +1 -0
- package/test/types/utils/index.js +29 -0
- package/test/types/utils/index.ts +1 -0
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +184 -23
- package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +320 -0
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +393 -40
- package/test/unit/data-structures/binary-tree/bst.test.ts +506 -48
- package/test/unit/data-structures/binary-tree/overall.test.ts +8 -7
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +240 -41
- package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +296 -215
- package/test/unit/data-structures/graph/abstract-graph.test.ts +97 -2
- package/test/unit/data-structures/graph/directed-graph.test.ts +76 -31
- package/test/unit/data-structures/graph/map-graph.test.ts +93 -12
- package/test/unit/data-structures/graph/overall.test.ts +2 -2
- package/test/unit/data-structures/graph/undirected-graph.test.ts +93 -3
- package/test/unit/data-structures/hash/coordinate-map.test.ts +20 -0
- package/test/unit/data-structures/hash/coordinate-set.test.ts +25 -0
- package/test/unit/data-structures/hash/hash-map.test.ts +2 -3
- package/test/unit/data-structures/hash/hash-table.test.ts +10 -8
- package/test/unit/data-structures/heap/heap.test.ts +218 -20
- package/test/unit/data-structures/heap/max-heap.test.ts +50 -42
- package/test/unit/data-structures/heap/min-heap.test.ts +38 -68
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +86 -27
- package/test/unit/data-structures/linked-list/linked-list.test.ts +4 -4
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +71 -27
- package/test/unit/data-structures/linked-list/skip-list.test.ts +33 -2
- package/test/unit/data-structures/matrix/matrix2d.test.ts +207 -0
- package/test/unit/data-structures/matrix/navigator.test.ts +167 -2
- package/test/unit/data-structures/matrix/vector2d.test.ts +171 -0
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +10 -11
- package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +14 -30
- package/test/unit/data-structures/queue/deque.test.ts +303 -23
- package/test/unit/data-structures/queue/queue.test.ts +52 -8
- package/test/unit/data-structures/tree/tree.test.ts +2 -2
- package/test/unit/data-structures/trie/trie.test.ts +743 -13
- package/test/utils/big-o.js +212 -0
- package/test/utils/big-o.ts +201 -0
- package/test/utils/index.js +30 -0
- package/test/utils/index.ts +1 -1
- package/test/utils/number.js +14 -0
- package/tsconfig-base.json +27 -0
- package/tsconfig-cjs.json +9 -0
- package/tsup.config.js +18 -0
- package/umd/bundle.min.js +1 -1
- package/umd/bundle.min.js.LICENSE.txt +15 -0
- package/umd/bundle.min.js.map +1 -1
- package/dist/data-structures/binary-tree/aa-tree.d.ts +0 -2
- package/dist/data-structures/binary-tree/aa-tree.js +0 -7
- package/dist/data-structures/binary-tree/aa-tree.js.map +0 -1
- package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +0 -527
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +0 -1199
- package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +0 -1
- package/dist/data-structures/binary-tree/avl-tree.d.ts +0 -94
- package/dist/data-structures/binary-tree/avl-tree.js +0 -336
- package/dist/data-structures/binary-tree/avl-tree.js.map +0 -1
- package/dist/data-structures/binary-tree/b-tree.d.ts +0 -2
- package/dist/data-structures/binary-tree/b-tree.js +0 -7
- package/dist/data-structures/binary-tree/b-tree.js.map +0 -1
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -46
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +0 -74
- package/dist/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
- package/dist/data-structures/binary-tree/binary-tree.d.ts +0 -31
- package/dist/data-structures/binary-tree/binary-tree.js +0 -41
- package/dist/data-structures/binary-tree/binary-tree.js.map +0 -1
- package/dist/data-structures/binary-tree/bst.d.ts +0 -133
- package/dist/data-structures/binary-tree/bst.js +0 -554
- package/dist/data-structures/binary-tree/bst.js.map +0 -1
- package/dist/data-structures/binary-tree/index.d.ts +0 -12
- package/dist/data-structures/binary-tree/index.js +0 -29
- package/dist/data-structures/binary-tree/index.js.map +0 -1
- package/dist/data-structures/binary-tree/rb-tree.d.ts +0 -13
- package/dist/data-structures/binary-tree/rb-tree.js +0 -28
- package/dist/data-structures/binary-tree/rb-tree.js.map +0 -1
- package/dist/data-structures/binary-tree/segment-tree.d.ts +0 -83
- package/dist/data-structures/binary-tree/segment-tree.js +0 -229
- package/dist/data-structures/binary-tree/segment-tree.js.map +0 -1
- package/dist/data-structures/binary-tree/splay-tree.d.ts +0 -2
- package/dist/data-structures/binary-tree/splay-tree.js +0 -7
- package/dist/data-structures/binary-tree/splay-tree.js.map +0 -1
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +0 -209
- package/dist/data-structures/binary-tree/tree-multiset.js +0 -669
- package/dist/data-structures/binary-tree/tree-multiset.js.map +0 -1
- package/dist/data-structures/binary-tree/two-three-tree.d.ts +0 -2
- package/dist/data-structures/binary-tree/two-three-tree.js +0 -7
- package/dist/data-structures/binary-tree/two-three-tree.js.map +0 -1
- package/dist/data-structures/graph/abstract-graph.d.ts +0 -332
- package/dist/data-structures/graph/abstract-graph.js +0 -925
- package/dist/data-structures/graph/abstract-graph.js.map +0 -1
- package/dist/data-structures/graph/directed-graph.d.ts +0 -200
- package/dist/data-structures/graph/directed-graph.js +0 -423
- package/dist/data-structures/graph/directed-graph.js.map +0 -1
- package/dist/data-structures/graph/index.js.map +0 -1
- package/dist/data-structures/graph/map-graph.d.ts +0 -79
- package/dist/data-structures/graph/map-graph.js +0 -112
- package/dist/data-structures/graph/map-graph.js.map +0 -1
- package/dist/data-structures/graph/undirected-graph.d.ts +0 -127
- package/dist/data-structures/graph/undirected-graph.js +0 -253
- package/dist/data-structures/graph/undirected-graph.js.map +0 -1
- package/dist/data-structures/hash/coordinate-map.d.ts +0 -45
- package/dist/data-structures/hash/coordinate-map.js +0 -66
- package/dist/data-structures/hash/coordinate-map.js.map +0 -1
- package/dist/data-structures/hash/coordinate-set.d.ts +0 -37
- package/dist/data-structures/hash/coordinate-set.js +0 -56
- package/dist/data-structures/hash/coordinate-set.js.map +0 -1
- package/dist/data-structures/hash/hash-map.d.ts +0 -56
- package/dist/data-structures/hash/hash-map.js +0 -172
- package/dist/data-structures/hash/hash-map.js.map +0 -1
- package/dist/data-structures/hash/hash-table.d.ts +0 -106
- package/dist/data-structures/hash/hash-table.js +0 -246
- package/dist/data-structures/hash/hash-table.js.map +0 -1
- package/dist/data-structures/hash/index.d.ts +0 -7
- package/dist/data-structures/hash/index.js +0 -24
- package/dist/data-structures/hash/index.js.map +0 -1
- package/dist/data-structures/hash/pair.d.ts +0 -2
- package/dist/data-structures/hash/pair.js +0 -7
- package/dist/data-structures/hash/pair.js.map +0 -1
- package/dist/data-structures/hash/tree-map.js.map +0 -1
- package/dist/data-structures/hash/tree-set.js.map +0 -1
- package/dist/data-structures/heap/heap.d.ts +0 -83
- package/dist/data-structures/heap/heap.js +0 -158
- package/dist/data-structures/heap/heap.js.map +0 -1
- package/dist/data-structures/heap/index.js.map +0 -1
- package/dist/data-structures/heap/max-heap.d.ts +0 -23
- package/dist/data-structures/heap/max-heap.js +0 -31
- package/dist/data-structures/heap/max-heap.js.map +0 -1
- package/dist/data-structures/heap/min-heap.d.ts +0 -24
- package/dist/data-structures/heap/min-heap.js +0 -32
- package/dist/data-structures/heap/min-heap.js.map +0 -1
- package/dist/data-structures/index.js.map +0 -1
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +0 -234
- package/dist/data-structures/linked-list/doubly-linked-list.js +0 -584
- package/dist/data-structures/linked-list/doubly-linked-list.js.map +0 -1
- package/dist/data-structures/linked-list/index.js.map +0 -1
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +0 -157
- package/dist/data-structures/linked-list/singly-linked-list.js +0 -449
- package/dist/data-structures/linked-list/singly-linked-list.js.map +0 -1
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +0 -61
- package/dist/data-structures/linked-list/skip-linked-list.js +0 -143
- package/dist/data-structures/linked-list/skip-linked-list.js.map +0 -1
- package/dist/data-structures/matrix/index.js.map +0 -1
- package/dist/data-structures/matrix/matrix.d.ts +0 -21
- package/dist/data-structures/matrix/matrix.js.map +0 -1
- package/dist/data-structures/matrix/matrix2d.d.ts +0 -108
- package/dist/data-structures/matrix/matrix2d.js +0 -201
- package/dist/data-structures/matrix/matrix2d.js.map +0 -1
- package/dist/data-structures/matrix/navigator.d.ts +0 -52
- package/dist/data-structures/matrix/navigator.js.map +0 -1
- package/dist/data-structures/matrix/vector2d.d.ts +0 -201
- package/dist/data-structures/matrix/vector2d.js +0 -292
- package/dist/data-structures/matrix/vector2d.js.map +0 -1
- package/dist/data-structures/priority-queue/index.js.map +0 -1
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +0 -15
- package/dist/data-structures/priority-queue/max-priority-queue.js +0 -44
- package/dist/data-structures/priority-queue/max-priority-queue.js.map +0 -1
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +0 -15
- package/dist/data-structures/priority-queue/min-priority-queue.js +0 -45
- package/dist/data-structures/priority-queue/min-priority-queue.js.map +0 -1
- package/dist/data-structures/priority-queue/priority-queue.d.ts +0 -180
- package/dist/data-structures/priority-queue/priority-queue.js +0 -322
- package/dist/data-structures/priority-queue/priority-queue.js.map +0 -1
- package/dist/data-structures/queue/deque.d.ts +0 -165
- package/dist/data-structures/queue/deque.js +0 -277
- package/dist/data-structures/queue/deque.js.map +0 -1
- package/dist/data-structures/queue/index.js.map +0 -1
- package/dist/data-structures/queue/queue.d.ts +0 -107
- package/dist/data-structures/queue/queue.js +0 -171
- package/dist/data-structures/queue/queue.js.map +0 -1
- package/dist/data-structures/stack/index.js.map +0 -1
- package/dist/data-structures/stack/stack.d.ts +0 -63
- package/dist/data-structures/stack/stack.js +0 -92
- package/dist/data-structures/stack/stack.js.map +0 -1
- package/dist/data-structures/tree/index.js.map +0 -1
- package/dist/data-structures/tree/tree.d.ts +0 -14
- package/dist/data-structures/tree/tree.js +0 -61
- package/dist/data-structures/tree/tree.js.map +0 -1
- package/dist/data-structures/trie/index.js.map +0 -1
- package/dist/data-structures/trie/trie.d.ts +0 -61
- package/dist/data-structures/trie/trie.js +0 -211
- package/dist/data-structures/trie/trie.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/interfaces/abstract-binary-tree.d.ts +0 -7
- package/dist/interfaces/abstract-binary-tree.js +0 -3
- package/dist/interfaces/abstract-binary-tree.js.map +0 -1
- package/dist/interfaces/abstract-graph.d.ts +0 -5
- package/dist/interfaces/abstract-graph.js.map +0 -1
- package/dist/interfaces/avl-tree.d.ts +0 -7
- package/dist/interfaces/avl-tree.js.map +0 -1
- package/dist/interfaces/binary-tree.d.ts +0 -6
- package/dist/interfaces/binary-tree.js.map +0 -1
- package/dist/interfaces/bst.d.ts +0 -6
- package/dist/interfaces/bst.js.map +0 -1
- package/dist/interfaces/directed-graph.d.ts +0 -3
- package/dist/interfaces/directed-graph.js +0 -3
- package/dist/interfaces/directed-graph.js.map +0 -1
- package/dist/interfaces/doubly-linked-list.js.map +0 -1
- package/dist/interfaces/heap.js.map +0 -1
- package/dist/interfaces/index.d.ts +0 -15
- package/dist/interfaces/index.js +0 -32
- package/dist/interfaces/index.js.map +0 -1
- package/dist/interfaces/navigator.js.map +0 -1
- package/dist/interfaces/priority-queue.js.map +0 -1
- package/dist/interfaces/rb-tree.d.ts +0 -6
- package/dist/interfaces/rb-tree.js +0 -3
- package/dist/interfaces/rb-tree.js.map +0 -1
- package/dist/interfaces/segment-tree.js.map +0 -1
- package/dist/interfaces/singly-linked-list.js.map +0 -1
- package/dist/interfaces/tree-multiset.d.ts +0 -6
- package/dist/interfaces/tree-multiset.js.map +0 -1
- package/dist/interfaces/undirected-graph.d.ts +0 -3
- package/dist/interfaces/undirected-graph.js.map +0 -1
- package/dist/types/data-structures/abstract-binary-tree.d.ts +0 -34
- package/dist/types/data-structures/abstract-binary-tree.js +0 -25
- package/dist/types/data-structures/abstract-binary-tree.js.map +0 -1
- package/dist/types/data-structures/abstract-graph.d.ts +0 -11
- package/dist/types/data-structures/abstract-graph.js +0 -3
- package/dist/types/data-structures/abstract-graph.js.map +0 -1
- package/dist/types/data-structures/avl-tree.d.ts +0 -4
- package/dist/types/data-structures/avl-tree.js +0 -3
- package/dist/types/data-structures/avl-tree.js.map +0 -1
- package/dist/types/data-structures/binary-tree.d.ts +0 -4
- package/dist/types/data-structures/binary-tree.js +0 -3
- package/dist/types/data-structures/binary-tree.js.map +0 -1
- package/dist/types/data-structures/bst.d.ts +0 -13
- package/dist/types/data-structures/bst.js +0 -10
- package/dist/types/data-structures/bst.js.map +0 -1
- package/dist/types/data-structures/directed-graph.js.map +0 -1
- package/dist/types/data-structures/doubly-linked-list.js.map +0 -1
- package/dist/types/data-structures/hash.js +0 -3
- package/dist/types/data-structures/hash.js.map +0 -1
- package/dist/types/data-structures/heap.d.ts +0 -3
- package/dist/types/data-structures/heap.js.map +0 -1
- package/dist/types/data-structures/index.d.ts +0 -16
- package/dist/types/data-structures/index.js +0 -33
- package/dist/types/data-structures/index.js.map +0 -1
- package/dist/types/data-structures/map-graph.js.map +0 -1
- package/dist/types/data-structures/navigator.js.map +0 -1
- package/dist/types/data-structures/priority-queue.d.ts +0 -7
- package/dist/types/data-structures/priority-queue.js.map +0 -1
- package/dist/types/data-structures/rb-tree.d.ts +0 -8
- package/dist/types/data-structures/rb-tree.js +0 -9
- package/dist/types/data-structures/rb-tree.js.map +0 -1
- package/dist/types/data-structures/segment-tree.js.map +0 -1
- package/dist/types/data-structures/singly-linked-list.js.map +0 -1
- package/dist/types/data-structures/tree-multiset.d.ts +0 -4
- package/dist/types/data-structures/tree-multiset.js +0 -3
- package/dist/types/data-structures/tree-multiset.js.map +0 -1
- package/dist/types/helpers.js +0 -3
- package/dist/types/helpers.js.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/utils/index.js.map +0 -1
- package/dist/types/utils/utils.js.map +0 -1
- package/dist/types/utils/validate-type.js.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/utils.d.ts +0 -19
- package/dist/utils/utils.js +0 -67
- package/dist/utils/utils.js.map +0 -1
- package/lib/data-structures/binary-tree/aa-tree.d.ts +0 -2
- package/lib/data-structures/binary-tree/aa-tree.js +0 -2
- package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +0 -527
- package/lib/data-structures/binary-tree/abstract-binary-tree.js +0 -1193
- package/lib/data-structures/binary-tree/avl-tree.d.ts +0 -94
- package/lib/data-structures/binary-tree/avl-tree.js +0 -330
- package/lib/data-structures/binary-tree/b-tree.d.ts +0 -2
- package/lib/data-structures/binary-tree/b-tree.js +0 -2
- package/lib/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -46
- package/lib/data-structures/binary-tree/binary-indexed-tree.js +0 -69
- package/lib/data-structures/binary-tree/binary-tree.d.ts +0 -31
- package/lib/data-structures/binary-tree/binary-tree.js +0 -35
- package/lib/data-structures/binary-tree/bst.d.ts +0 -133
- package/lib/data-structures/binary-tree/bst.js +0 -548
- package/lib/data-structures/binary-tree/index.d.ts +0 -12
- package/lib/data-structures/binary-tree/index.js +0 -12
- package/lib/data-structures/binary-tree/rb-tree.d.ts +0 -13
- package/lib/data-structures/binary-tree/rb-tree.js +0 -22
- package/lib/data-structures/binary-tree/segment-tree.d.ts +0 -83
- package/lib/data-structures/binary-tree/segment-tree.js +0 -223
- package/lib/data-structures/binary-tree/splay-tree.d.ts +0 -2
- package/lib/data-structures/binary-tree/splay-tree.js +0 -2
- package/lib/data-structures/binary-tree/tree-multiset.d.ts +0 -209
- package/lib/data-structures/binary-tree/tree-multiset.js +0 -663
- package/lib/data-structures/binary-tree/two-three-tree.d.ts +0 -2
- package/lib/data-structures/binary-tree/two-three-tree.js +0 -2
- package/lib/data-structures/graph/abstract-graph.d.ts +0 -332
- package/lib/data-structures/graph/abstract-graph.js +0 -918
- package/lib/data-structures/graph/directed-graph.d.ts +0 -200
- package/lib/data-structures/graph/directed-graph.js +0 -416
- package/lib/data-structures/graph/index.js +0 -4
- package/lib/data-structures/graph/map-graph.d.ts +0 -79
- package/lib/data-structures/graph/map-graph.js +0 -105
- package/lib/data-structures/graph/undirected-graph.d.ts +0 -127
- package/lib/data-structures/graph/undirected-graph.js +0 -246
- package/lib/data-structures/hash/coordinate-map.d.ts +0 -45
- package/lib/data-structures/hash/coordinate-map.js +0 -61
- package/lib/data-structures/hash/coordinate-set.d.ts +0 -37
- package/lib/data-structures/hash/coordinate-set.js +0 -51
- package/lib/data-structures/hash/hash-map.d.ts +0 -56
- package/lib/data-structures/hash/hash-map.js +0 -167
- package/lib/data-structures/hash/hash-table.d.ts +0 -106
- package/lib/data-structures/hash/hash-table.js +0 -240
- package/lib/data-structures/hash/index.d.ts +0 -7
- package/lib/data-structures/hash/index.js +0 -7
- package/lib/data-structures/hash/pair.d.ts +0 -2
- package/lib/data-structures/hash/pair.js +0 -2
- package/lib/data-structures/hash/tree-map.js +0 -2
- package/lib/data-structures/hash/tree-set.js +0 -2
- package/lib/data-structures/heap/heap.d.ts +0 -83
- package/lib/data-structures/heap/heap.js +0 -152
- package/lib/data-structures/heap/index.js +0 -3
- package/lib/data-structures/heap/max-heap.d.ts +0 -23
- package/lib/data-structures/heap/max-heap.js +0 -26
- package/lib/data-structures/heap/min-heap.d.ts +0 -24
- package/lib/data-structures/heap/min-heap.js +0 -27
- package/lib/data-structures/index.js +0 -11
- package/lib/data-structures/linked-list/doubly-linked-list.d.ts +0 -234
- package/lib/data-structures/linked-list/doubly-linked-list.js +0 -578
- package/lib/data-structures/linked-list/index.js +0 -3
- package/lib/data-structures/linked-list/singly-linked-list.d.ts +0 -157
- package/lib/data-structures/linked-list/singly-linked-list.js +0 -443
- package/lib/data-structures/linked-list/skip-linked-list.d.ts +0 -61
- package/lib/data-structures/linked-list/skip-linked-list.js +0 -137
- package/lib/data-structures/matrix/index.js +0 -4
- package/lib/data-structures/matrix/matrix.d.ts +0 -21
- package/lib/data-structures/matrix/matrix.js +0 -24
- package/lib/data-structures/matrix/matrix2d.d.ts +0 -108
- package/lib/data-structures/matrix/matrix2d.js +0 -196
- package/lib/data-structures/matrix/navigator.d.ts +0 -52
- package/lib/data-structures/matrix/navigator.js +0 -101
- package/lib/data-structures/matrix/vector2d.d.ts +0 -201
- package/lib/data-structures/matrix/vector2d.js +0 -287
- package/lib/data-structures/priority-queue/max-priority-queue.d.ts +0 -15
- package/lib/data-structures/priority-queue/max-priority-queue.js +0 -39
- package/lib/data-structures/priority-queue/min-priority-queue.d.ts +0 -15
- package/lib/data-structures/priority-queue/min-priority-queue.js +0 -40
- package/lib/data-structures/priority-queue/priority-queue.d.ts +0 -180
- package/lib/data-structures/priority-queue/priority-queue.js +0 -317
- package/lib/data-structures/queue/deque.d.ts +0 -165
- package/lib/data-structures/queue/deque.js +0 -270
- package/lib/data-structures/queue/queue.d.ts +0 -107
- package/lib/data-structures/queue/queue.js +0 -165
- package/lib/data-structures/stack/stack.d.ts +0 -63
- package/lib/data-structures/stack/stack.js +0 -87
- package/lib/data-structures/tree/tree.d.ts +0 -14
- package/lib/data-structures/tree/tree.js +0 -56
- package/lib/data-structures/trie/trie.d.ts +0 -61
- package/lib/data-structures/trie/trie.js +0 -205
- package/lib/index.js +0 -4
- package/lib/interfaces/abstract-binary-tree.d.ts +0 -7
- package/lib/interfaces/abstract-graph.d.ts +0 -5
- package/lib/interfaces/avl-tree.d.ts +0 -7
- package/lib/interfaces/binary-tree.d.ts +0 -6
- package/lib/interfaces/bst.d.ts +0 -6
- package/lib/interfaces/directed-graph.d.ts +0 -3
- package/lib/interfaces/index.d.ts +0 -15
- package/lib/interfaces/index.js +0 -15
- package/lib/interfaces/rb-tree.d.ts +0 -6
- package/lib/interfaces/tree-multiset.d.ts +0 -6
- package/lib/interfaces/undirected-graph.d.ts +0 -3
- package/lib/types/data-structures/abstract-binary-tree.d.ts +0 -34
- package/lib/types/data-structures/abstract-binary-tree.js +0 -21
- package/lib/types/data-structures/abstract-graph.d.ts +0 -11
- package/lib/types/data-structures/avl-tree.d.ts +0 -4
- package/lib/types/data-structures/binary-tree.d.ts +0 -4
- package/lib/types/data-structures/bst.d.ts +0 -13
- package/lib/types/data-structures/bst.js +0 -6
- package/lib/types/data-structures/directed-graph.js +0 -6
- package/lib/types/data-structures/heap.d.ts +0 -3
- package/lib/types/data-structures/index.d.ts +0 -16
- package/lib/types/data-structures/index.js +0 -16
- package/lib/types/data-structures/priority-queue.d.ts +0 -7
- package/lib/types/data-structures/rb-tree.d.ts +0 -8
- package/lib/types/data-structures/rb-tree.js +0 -5
- package/lib/types/data-structures/tree-multiset.d.ts +0 -4
- package/lib/types/index.js +0 -3
- package/lib/types/utils/index.js +0 -2
- package/lib/utils/utils.d.ts +0 -19
- package/lib/utils/utils.js +0 -57
- package/scripts/rename_clear_files.sh +0 -29
- package/src/data-structures/binary-tree/aa-tree.ts +0 -1
- package/src/data-structures/binary-tree/abstract-binary-tree.ts +0 -1556
- package/src/data-structures/binary-tree/b-tree.ts +0 -1
- package/src/data-structures/binary-tree/splay-tree.ts +0 -1
- package/src/data-structures/binary-tree/two-three-tree.ts +0 -1
- package/src/data-structures/hash/pair.ts +0 -1
- package/src/interfaces/abstract-binary-tree.ts +0 -8
- package/src/interfaces/abstract-graph.ts +0 -7
- package/src/interfaces/avl-tree.ts +0 -8
- package/src/interfaces/bst.ts +0 -6
- package/src/interfaces/directed-graph.ts +0 -3
- package/src/interfaces/rb-tree.ts +0 -6
- package/src/interfaces/tree-multiset.ts +0 -7
- package/src/interfaces/undirected-graph.ts +0 -3
- package/src/types/data-structures/abstract-binary-tree.ts +0 -49
- package/src/types/data-structures/abstract-graph.ts +0 -11
- package/src/types/data-structures/avl-tree.ts +0 -5
- package/src/types/data-structures/binary-tree.ts +0 -5
- package/src/types/data-structures/bst.ts +0 -13
- package/src/types/data-structures/heap.ts +0 -5
- package/src/types/data-structures/navigator.ts +0 -13
- package/src/types/data-structures/priority-queue.ts +0 -9
- package/src/types/data-structures/rb-tree.ts +0 -8
- package/src/types/data-structures/tree-multiset.ts +0 -6
- package/test/utils/magnitude.ts +0 -21
- /package/dist/{data-structures → cjs/data-structures}/graph/index.d.ts +0 -0
- /package/dist/{data-structures → cjs/data-structures}/graph/index.js +0 -0
- /package/dist/{data-structures → cjs/data-structures}/hash/tree-map.d.ts +0 -0
- /package/dist/{data-structures → cjs/data-structures}/hash/tree-map.js +0 -0
- /package/dist/{data-structures → cjs/data-structures}/hash/tree-set.d.ts +0 -0
- /package/dist/{data-structures → cjs/data-structures}/hash/tree-set.js +0 -0
- /package/dist/{data-structures → cjs/data-structures}/heap/index.d.ts +0 -0
- /package/dist/{data-structures → cjs/data-structures}/heap/index.js +0 -0
- /package/dist/{data-structures → cjs/data-structures}/index.d.ts +0 -0
- /package/dist/{data-structures → cjs/data-structures}/index.js +0 -0
- /package/dist/{data-structures → cjs/data-structures}/linked-list/index.d.ts +0 -0
- /package/dist/{data-structures → cjs/data-structures}/linked-list/index.js +0 -0
- /package/dist/{data-structures → cjs/data-structures}/matrix/index.d.ts +0 -0
- /package/dist/{data-structures → cjs/data-structures}/matrix/index.js +0 -0
- /package/dist/{data-structures → cjs/data-structures}/matrix/matrix.js +0 -0
- /package/dist/{data-structures → cjs/data-structures}/matrix/navigator.js +0 -0
- /package/dist/{data-structures → cjs/data-structures}/priority-queue/index.d.ts +0 -0
- /package/dist/{data-structures → cjs/data-structures}/priority-queue/index.js +0 -0
- /package/dist/{data-structures → cjs/data-structures}/queue/index.d.ts +0 -0
- /package/dist/{data-structures → cjs/data-structures}/queue/index.js +0 -0
- /package/dist/{data-structures → cjs/data-structures}/stack/index.d.ts +0 -0
- /package/dist/{data-structures → cjs/data-structures}/stack/index.js +0 -0
- /package/dist/{data-structures → cjs/data-structures}/tree/index.d.ts +0 -0
- /package/dist/{data-structures → cjs/data-structures}/tree/index.js +0 -0
- /package/dist/{data-structures → cjs/data-structures}/trie/index.d.ts +0 -0
- /package/dist/{data-structures → cjs/data-structures}/trie/index.js +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{index.js → cjs/index.js} +0 -0
- /package/dist/{interfaces → cjs/interfaces}/binary-tree.js +0 -0
- /package/dist/{interfaces → cjs/interfaces}/doubly-linked-list.d.ts +0 -0
- /package/dist/{interfaces → cjs/interfaces}/doubly-linked-list.js +0 -0
- /package/dist/{interfaces → cjs/interfaces}/heap.d.ts +0 -0
- /package/dist/{interfaces → cjs/interfaces}/heap.js +0 -0
- /package/dist/{interfaces → cjs/interfaces}/navigator.d.ts +0 -0
- /package/dist/{interfaces → cjs/interfaces}/navigator.js +0 -0
- /package/dist/{interfaces → cjs/interfaces}/priority-queue.d.ts +0 -0
- /package/dist/{interfaces → cjs/interfaces}/priority-queue.js +0 -0
- /package/dist/{interfaces → cjs/interfaces}/segment-tree.d.ts +0 -0
- /package/dist/{interfaces → cjs/interfaces}/segment-tree.js +0 -0
- /package/dist/{interfaces → cjs/interfaces}/singly-linked-list.d.ts +0 -0
- /package/dist/{interfaces → cjs/interfaces}/singly-linked-list.js +0 -0
- /package/dist/{interfaces → cjs/types/data-structures/binary-tree}/avl-tree.js +0 -0
- /package/dist/{types/data-structures/doubly-linked-list.d.ts → cjs/types/data-structures/binary-tree/binary-indexed-tree.d.ts} +0 -0
- /package/dist/{interfaces → cjs/types/data-structures/binary-tree}/bst.js +0 -0
- /package/dist/{types/data-structures → cjs/types/data-structures/binary-tree}/segment-tree.d.ts +0 -0
- /package/dist/{types/data-structures → cjs/types/data-structures/binary-tree}/segment-tree.js +0 -0
- /package/dist/{interfaces → cjs/types/data-structures/binary-tree}/tree-multiset.js +0 -0
- /package/dist/{interfaces → cjs/types/data-structures/graph}/abstract-graph.js +0 -0
- /package/dist/{types/data-structures → cjs/types/data-structures/graph}/directed-graph.d.ts +0 -0
- /package/dist/{types/data-structures → cjs/types/data-structures/graph}/directed-graph.js +0 -0
- /package/dist/{types/data-structures → cjs/types/data-structures/graph}/map-graph.d.ts +0 -0
- /package/dist/{types/data-structures → cjs/types/data-structures/graph}/map-graph.js +0 -0
- /package/dist/{types/data-structures/singly-linked-list.d.ts → cjs/types/data-structures/graph/undirected-graph.d.ts} +0 -0
- /package/dist/{interfaces → cjs/types/data-structures/graph}/undirected-graph.js +0 -0
- /package/dist/{types/helpers.d.ts → cjs/types/data-structures/hash/coordinate-map.d.ts} +0 -0
- /package/{lib/interfaces/abstract-binary-tree.js → dist/cjs/types/data-structures/hash/coordinate-set.d.ts} +0 -0
- /package/{lib/interfaces/abstract-graph.js → dist/cjs/types/data-structures/hash/hash-map.d.ts} +0 -0
- /package/{lib/interfaces/avl-tree.js → dist/cjs/types/data-structures/hash/hash-table.d.ts} +0 -0
- /package/dist/{types/data-structures/hash.d.ts → cjs/types/data-structures/hash/index.d.ts} +0 -0
- /package/{lib/interfaces/binary-tree.js → dist/cjs/types/data-structures/hash/tree-map.d.ts} +0 -0
- /package/{lib/interfaces/bst.js → dist/cjs/types/data-structures/hash/tree-set.d.ts} +0 -0
- /package/{lib/interfaces → dist/cjs/types/data-structures/heap}/heap.d.ts +0 -0
- /package/dist/{types/data-structures → cjs/types/data-structures/heap}/heap.js +0 -0
- /package/{lib/interfaces/directed-graph.js → dist/cjs/types/data-structures/heap/max-heap.d.ts} +0 -0
- /package/{lib/interfaces/doubly-linked-list.d.ts → dist/cjs/types/data-structures/heap/min-heap.d.ts} +0 -0
- /package/{lib/types/data-structures → dist/cjs/types/data-structures/linked-list}/doubly-linked-list.d.ts +0 -0
- /package/dist/{types/data-structures → cjs/types/data-structures/linked-list}/doubly-linked-list.js +0 -0
- /package/{lib/interfaces → dist/cjs/types/data-structures/linked-list}/singly-linked-list.d.ts +0 -0
- /package/dist/{types/data-structures → cjs/types/data-structures/linked-list}/singly-linked-list.js +0 -0
- /package/{lib/interfaces/doubly-linked-list.js → dist/cjs/types/data-structures/linked-list/skip-linked-list.d.ts} +0 -0
- /package/{lib/interfaces/heap.js → dist/cjs/types/data-structures/matrix/matrix.d.ts} +0 -0
- /package/{lib/interfaces/navigator.d.ts → dist/cjs/types/data-structures/matrix/matrix2d.d.ts} +0 -0
- /package/dist/{types/data-structures → cjs/types/data-structures/matrix}/navigator.d.ts +0 -0
- /package/dist/{types/data-structures → cjs/types/data-structures/matrix}/navigator.js +0 -0
- /package/{lib/interfaces/navigator.js → dist/cjs/types/data-structures/matrix/vector2d.d.ts} +0 -0
- /package/{lib → dist/cjs/types}/data-structures/priority-queue/index.d.ts +0 -0
- /package/{lib/interfaces/priority-queue.d.ts → dist/cjs/types/data-structures/priority-queue/max-priority-queue.d.ts} +0 -0
- /package/{lib/interfaces/priority-queue.js → dist/cjs/types/data-structures/priority-queue/min-priority-queue.d.ts} +0 -0
- /package/{lib/interfaces/rb-tree.js → dist/cjs/types/data-structures/priority-queue/priority-queue.d.ts} +0 -0
- /package/dist/{types/data-structures → cjs/types/data-structures/priority-queue}/priority-queue.js +0 -0
- /package/{lib/interfaces/segment-tree.d.ts → dist/cjs/types/data-structures/queue/deque.d.ts} +0 -0
- /package/{lib → dist/cjs/types}/data-structures/queue/index.d.ts +0 -0
- /package/{lib/interfaces/segment-tree.js → dist/cjs/types/data-structures/queue/queue.d.ts} +0 -0
- /package/{lib → dist/cjs/types}/data-structures/stack/index.d.ts +0 -0
- /package/{lib/interfaces/singly-linked-list.js → dist/cjs/types/data-structures/stack/stack.d.ts} +0 -0
- /package/{lib → dist/cjs/types}/data-structures/tree/index.d.ts +0 -0
- /package/{lib/interfaces/tree-multiset.js → dist/cjs/types/data-structures/tree/tree.d.ts} +0 -0
- /package/{lib → dist/cjs/types}/data-structures/trie/index.d.ts +0 -0
- /package/{lib/interfaces/undirected-graph.js → dist/cjs/types/data-structures/trie/trie.d.ts} +0 -0
- /package/dist/{types → cjs/types}/index.d.ts +0 -0
- /package/dist/{types → cjs/types}/index.js +0 -0
- /package/dist/{types → cjs/types}/utils/index.d.ts +0 -0
- /package/dist/{types → cjs/types}/utils/index.js +0 -0
- /package/dist/{types → cjs/types}/utils/utils.d.ts +0 -0
- /package/dist/{types → cjs/types}/utils/utils.js +0 -0
- /package/dist/{types → cjs/types}/utils/validate-type.d.ts +0 -0
- /package/dist/{types → cjs/types}/utils/validate-type.js +0 -0
- /package/dist/{utils → cjs/utils}/index.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/index.js +0 -0
- /package/{lib → dist/mjs}/data-structures/graph/index.d.ts +0 -0
- /package/{lib → dist/mjs}/data-structures/hash/tree-map.d.ts +0 -0
- /package/{lib → dist/mjs}/data-structures/hash/tree-set.d.ts +0 -0
- /package/{lib → dist/mjs}/data-structures/heap/index.d.ts +0 -0
- /package/{lib → dist/mjs}/data-structures/index.d.ts +0 -0
- /package/{lib → dist/mjs}/data-structures/linked-list/index.d.ts +0 -0
- /package/{lib → dist/mjs}/data-structures/matrix/index.d.ts +0 -0
- /package/{lib/data-structures/priority-queue/index.js → dist/mjs/data-structures/priority-queue/index.d.ts} +0 -0
- /package/{lib/data-structures/queue/index.js → dist/mjs/data-structures/queue/index.d.ts} +0 -0
- /package/{lib/data-structures/stack/index.js → dist/mjs/data-structures/stack/index.d.ts} +0 -0
- /package/{lib/data-structures/tree/index.js → dist/mjs/data-structures/tree/index.d.ts} +0 -0
- /package/{lib/data-structures/trie/index.js → dist/mjs/data-structures/trie/index.d.ts} +0 -0
- /package/{lib → dist/mjs}/index.d.ts +0 -0
- /package/{lib/types/data-structures/abstract-graph.js → dist/mjs/interfaces/doubly-linked-list.d.ts} +0 -0
- /package/{lib/types/data-structures/avl-tree.js → dist/mjs/interfaces/heap.d.ts} +0 -0
- /package/{lib/types/data-structures/binary-tree.js → dist/mjs/interfaces/navigator.d.ts} +0 -0
- /package/{lib/types/data-structures/doubly-linked-list.js → dist/mjs/interfaces/priority-queue.d.ts} +0 -0
- /package/{lib/types/data-structures/hash.js → dist/mjs/interfaces/segment-tree.d.ts} +0 -0
- /package/{lib/types/data-structures → dist/mjs/interfaces}/singly-linked-list.d.ts +0 -0
- /package/{lib/types/data-structures/heap.js → dist/mjs/types/data-structures/binary-tree/binary-indexed-tree.d.ts} +0 -0
- /package/{lib/types/data-structures → dist/mjs/types/data-structures/binary-tree}/segment-tree.d.ts +0 -0
- /package/{lib/types/data-structures → dist/mjs/types/data-structures/graph}/directed-graph.d.ts +0 -0
- /package/{lib/types/data-structures → dist/mjs/types/data-structures/graph}/map-graph.d.ts +0 -0
- /package/{lib/types/data-structures/map-graph.js → dist/mjs/types/data-structures/graph/undirected-graph.d.ts} +0 -0
- /package/{lib/types/data-structures/navigator.js → dist/mjs/types/data-structures/hash/coordinate-map.d.ts} +0 -0
- /package/{lib/types/data-structures/priority-queue.js → dist/mjs/types/data-structures/hash/coordinate-set.d.ts} +0 -0
- /package/{lib/types/data-structures/segment-tree.js → dist/mjs/types/data-structures/hash/hash-map.d.ts} +0 -0
- /package/{lib/types/data-structures/singly-linked-list.js → dist/mjs/types/data-structures/hash/hash-table.d.ts} +0 -0
- /package/{lib/types/data-structures/hash.d.ts → dist/mjs/types/data-structures/hash/index.d.ts} +0 -0
- /package/{lib/types/data-structures/tree-multiset.js → dist/mjs/types/data-structures/hash/tree-map.d.ts} +0 -0
- /package/{lib/types/helpers.d.ts → dist/mjs/types/data-structures/hash/tree-set.d.ts} +0 -0
- /package/{lib/types/helpers.js → dist/mjs/types/data-structures/heap/heap.d.ts} +0 -0
- /package/{lib/types/utils/utils.js → dist/mjs/types/data-structures/heap/max-heap.d.ts} +0 -0
- /package/{lib/types/utils/validate-type.js → dist/mjs/types/data-structures/heap/min-heap.d.ts} +0 -0
- /package/{src/types/data-structures/doubly-linked-list.ts → dist/mjs/types/data-structures/linked-list/doubly-linked-list.d.ts} +0 -0
- /package/{src/types/data-structures/singly-linked-list.ts → dist/mjs/types/data-structures/linked-list/singly-linked-list.d.ts} +0 -0
- /package/{lib/types/data-structures → dist/mjs/types/data-structures/matrix}/navigator.d.ts +0 -0
- /package/{lib → dist/mjs}/types/index.d.ts +0 -0
- /package/{lib → dist/mjs}/types/utils/index.d.ts +0 -0
- /package/{lib → dist/mjs}/types/utils/utils.d.ts +0 -0
- /package/{lib → dist/mjs}/types/utils/validate-type.d.ts +0 -0
- /package/{lib → dist/mjs}/utils/index.d.ts +0 -0
- /package/src/types/data-structures/{segment-tree.ts → binary-tree/segment-tree.ts} +0 -0
- /package/src/types/data-structures/{directed-graph.ts → graph/directed-graph.ts} +0 -0
- /package/src/types/data-structures/{map-graph.ts → graph/map-graph.ts} +0 -0
- /package/src/types/data-structures/{hash.ts → hash/index.ts} +0 -0
- /package/{lib/utils/index.js → test/types/index.ts} +0 -0
|
@@ -8,22 +8,25 @@
|
|
|
8
8
|
import {arrayRemove} from '../../utils';
|
|
9
9
|
import {AbstractEdge, AbstractGraph, AbstractVertex} from './abstract-graph';
|
|
10
10
|
import type {TopologicalStatus, VertexKey} from '../../types';
|
|
11
|
-
import {
|
|
11
|
+
import {IGraph} from '../../interfaces';
|
|
12
12
|
|
|
13
13
|
export class DirectedVertex<V = any> extends AbstractVertex<V> {
|
|
14
14
|
/**
|
|
15
15
|
* The constructor function initializes a vertex with an optional value.
|
|
16
16
|
* @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex. It is
|
|
17
17
|
* used to uniquely identify the vertex within a graph or data structure.
|
|
18
|
-
* @param {V} [
|
|
18
|
+
* @param {V} [value] - The "value" parameter is an optional parameter of type V. It is used to initialize the value of the
|
|
19
19
|
* vertex. If no value is provided, the vertex will be initialized with a default value.
|
|
20
20
|
*/
|
|
21
|
-
constructor(key: VertexKey,
|
|
22
|
-
super(key,
|
|
21
|
+
constructor(key: VertexKey, value?: V) {
|
|
22
|
+
super(key, value);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export class DirectedEdge<
|
|
26
|
+
export class DirectedEdge<E = any> extends AbstractEdge<E> {
|
|
27
|
+
src: VertexKey;
|
|
28
|
+
dest: VertexKey;
|
|
29
|
+
|
|
27
30
|
/**
|
|
28
31
|
* The constructor function initializes the source and destination vertices of an edge, along with an optional weight
|
|
29
32
|
* and value.
|
|
@@ -32,40 +35,24 @@ export class DirectedEdge<V = any> extends AbstractEdge<V> {
|
|
|
32
35
|
* @param {VertexKey} dest - The `dest` parameter represents the destination vertex of an edge. It is of type
|
|
33
36
|
* `VertexKey`, which is likely a unique identifier for a vertex in a graph.
|
|
34
37
|
* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
|
|
35
|
-
* @param {
|
|
38
|
+
* @param {E} [value] - The `value` parameter is an optional parameter of type `E`. It represents the value associated with
|
|
36
39
|
* the edge.
|
|
37
40
|
*/
|
|
38
|
-
constructor(src: VertexKey, dest: VertexKey, weight?: number,
|
|
39
|
-
super(weight,
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private _src: VertexKey;
|
|
45
|
-
|
|
46
|
-
get src(): VertexKey {
|
|
47
|
-
return this._src;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
set src(v: VertexKey) {
|
|
51
|
-
this._src = v;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private _dest: VertexKey;
|
|
55
|
-
|
|
56
|
-
get dest(): VertexKey {
|
|
57
|
-
return this._dest;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
set dest(v: VertexKey) {
|
|
61
|
-
this._dest = v;
|
|
41
|
+
constructor(src: VertexKey, dest: VertexKey, weight?: number, value?: E) {
|
|
42
|
+
super(weight, value);
|
|
43
|
+
this.src = src;
|
|
44
|
+
this.dest = dest;
|
|
62
45
|
}
|
|
63
46
|
}
|
|
64
47
|
|
|
65
|
-
export class DirectedGraph<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
48
|
+
export class DirectedGraph<
|
|
49
|
+
V = any,
|
|
50
|
+
E = any,
|
|
51
|
+
VO extends DirectedVertex<V> = DirectedVertex<V>,
|
|
52
|
+
EO extends DirectedEdge<E> = DirectedEdge<E>
|
|
53
|
+
>
|
|
54
|
+
extends AbstractGraph<V, E, VO, EO>
|
|
55
|
+
implements IGraph<V, E, VO, EO> {
|
|
69
56
|
/**
|
|
70
57
|
* The constructor function initializes an instance of a class.
|
|
71
58
|
*/
|
|
@@ -73,15 +60,15 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
73
60
|
super();
|
|
74
61
|
}
|
|
75
62
|
|
|
76
|
-
|
|
63
|
+
protected _outEdgeMap: Map<VO, EO[]> = new Map<VO, EO[]>();
|
|
77
64
|
|
|
78
|
-
get outEdgeMap(): Map<
|
|
65
|
+
get outEdgeMap(): Map<VO, EO[]> {
|
|
79
66
|
return this._outEdgeMap;
|
|
80
67
|
}
|
|
81
68
|
|
|
82
|
-
|
|
69
|
+
protected _inEdgeMap: Map<VO, EO[]> = new Map<VO, EO[]>();
|
|
83
70
|
|
|
84
|
-
get inEdgeMap(): Map<
|
|
71
|
+
get inEdgeMap(): Map<VO, EO[]> {
|
|
85
72
|
return this._inEdgeMap;
|
|
86
73
|
}
|
|
87
74
|
|
|
@@ -94,13 +81,13 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
94
81
|
* The function creates a new vertex with an optional value and returns it.
|
|
95
82
|
* @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
|
|
96
83
|
* could be a number or a string depending on how you want to identify your vertices.
|
|
97
|
-
* @param [
|
|
98
|
-
* it will be assigned to the '
|
|
84
|
+
* @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,
|
|
85
|
+
* it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be
|
|
99
86
|
* assigned the same value as the 'key' parameter
|
|
100
|
-
* @returns a new instance of a DirectedVertex object, casted as type
|
|
87
|
+
* @returns a new instance of a DirectedVertex object, casted as type VO.
|
|
101
88
|
*/
|
|
102
|
-
createVertex(key: VertexKey,
|
|
103
|
-
return new DirectedVertex(key,
|
|
89
|
+
createVertex(key: VertexKey, value?: V): VO {
|
|
90
|
+
return new DirectedVertex(key, value ?? key) as VO;
|
|
104
91
|
}
|
|
105
92
|
|
|
106
93
|
/**
|
|
@@ -114,28 +101,28 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
114
101
|
* @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge.
|
|
115
102
|
* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge. If no
|
|
116
103
|
* weight is provided, it defaults to 1.
|
|
117
|
-
* @param [
|
|
104
|
+
* @param [value] - The 'value' parameter is an optional value that can be assigned to the edge. It can be of any type and
|
|
118
105
|
* is used to store additional information or data associated with the edge.
|
|
119
|
-
* @returns a new instance of a DirectedEdge object, casted as type
|
|
106
|
+
* @returns a new instance of a DirectedEdge object, casted as type EO.
|
|
120
107
|
*/
|
|
121
|
-
createEdge(src: VertexKey, dest: VertexKey, weight?: number,
|
|
122
|
-
return new DirectedEdge(src, dest, weight ?? 1,
|
|
108
|
+
createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO {
|
|
109
|
+
return new DirectedEdge(src, dest, weight ?? 1, value) as EO;
|
|
123
110
|
}
|
|
124
111
|
|
|
125
112
|
/**
|
|
126
113
|
* The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
|
|
127
|
-
* @param {
|
|
128
|
-
* @param {
|
|
129
|
-
* destination vertex of the edge. It can be either a vertex object (`
|
|
114
|
+
* @param {VO | VertexKey | null} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
|
|
115
|
+
* @param {VO | VertexKey | null} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
|
|
116
|
+
* destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `null` if the
|
|
130
117
|
* destination is not specified.
|
|
131
118
|
* @returns the first edge found between the source and destination vertices, or null if no such edge is found.
|
|
132
119
|
*/
|
|
133
|
-
getEdge(srcOrKey:
|
|
134
|
-
let edges:
|
|
120
|
+
getEdge(srcOrKey: VO | VertexKey | null, destOrKey: VO | VertexKey | null): EO | null {
|
|
121
|
+
let edges: EO[] = [];
|
|
135
122
|
|
|
136
123
|
if (srcOrKey !== null && destOrKey !== null) {
|
|
137
|
-
const src:
|
|
138
|
-
const dest:
|
|
124
|
+
const src: VO | null = this._getVertex(srcOrKey);
|
|
125
|
+
const dest: VO | null = this._getVertex(destOrKey);
|
|
139
126
|
|
|
140
127
|
if (src && dest) {
|
|
141
128
|
const srcOutEdges = this._outEdgeMap.get(src);
|
|
@@ -150,49 +137,49 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
150
137
|
|
|
151
138
|
/**
|
|
152
139
|
* The function removes an edge between two vertices in a graph and returns the removed edge.
|
|
153
|
-
* @param {
|
|
154
|
-
* @param {
|
|
155
|
-
* @returns the removed edge (
|
|
140
|
+
* @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
|
|
141
|
+
* @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
|
|
142
|
+
* @returns the removed edge (EO) if it exists, or null if either the source or destination vertex does not exist.
|
|
156
143
|
*/
|
|
157
|
-
|
|
158
|
-
const src:
|
|
159
|
-
const dest:
|
|
160
|
-
let removed:
|
|
144
|
+
deleteEdgeSrcToDest(srcOrKey: VO | VertexKey, destOrKey: VO | VertexKey): EO | null {
|
|
145
|
+
const src: VO | null = this._getVertex(srcOrKey);
|
|
146
|
+
const dest: VO | null = this._getVertex(destOrKey);
|
|
147
|
+
let removed: EO | null = null;
|
|
161
148
|
if (!src || !dest) {
|
|
162
149
|
return null;
|
|
163
150
|
}
|
|
164
151
|
|
|
165
152
|
const srcOutEdges = this._outEdgeMap.get(src);
|
|
166
153
|
if (srcOutEdges) {
|
|
167
|
-
arrayRemove<
|
|
154
|
+
arrayRemove<EO>(srcOutEdges, (edge: EO) => edge.dest === dest.key);
|
|
168
155
|
}
|
|
169
156
|
|
|
170
157
|
const destInEdges = this._inEdgeMap.get(dest);
|
|
171
158
|
if (destInEdges) {
|
|
172
|
-
removed = arrayRemove<
|
|
159
|
+
removed = arrayRemove<EO>(destInEdges, (edge: EO) => edge.src === src.key)[0] || null;
|
|
173
160
|
}
|
|
174
161
|
return removed;
|
|
175
162
|
}
|
|
176
163
|
|
|
177
164
|
/**
|
|
178
165
|
* The function removes an edge from a graph and returns the removed edge, or null if the edge was not found.
|
|
179
|
-
* @param {
|
|
166
|
+
* @param {EO} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
|
|
180
167
|
* and `dest`, which represent the source and destination vertices of the edge, respectively.
|
|
181
|
-
* @returns The method `
|
|
168
|
+
* @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `null` if the edge does not exist.
|
|
182
169
|
*/
|
|
183
|
-
|
|
184
|
-
let removed:
|
|
170
|
+
deleteEdge(edge: EO): EO | null {
|
|
171
|
+
let removed: EO | null = null;
|
|
185
172
|
const src = this._getVertex(edge.src);
|
|
186
173
|
const dest = this._getVertex(edge.dest);
|
|
187
174
|
if (src && dest) {
|
|
188
175
|
const srcOutEdges = this._outEdgeMap.get(src);
|
|
189
176
|
if (srcOutEdges && srcOutEdges.length > 0) {
|
|
190
|
-
arrayRemove(srcOutEdges, (edge:
|
|
177
|
+
arrayRemove(srcOutEdges, (edge: EO) => edge.src === src.key);
|
|
191
178
|
}
|
|
192
179
|
|
|
193
180
|
const destInEdges = this._inEdgeMap.get(dest);
|
|
194
181
|
if (destInEdges && destInEdges.length > 0) {
|
|
195
|
-
removed = arrayRemove(destInEdges, (edge:
|
|
182
|
+
removed = arrayRemove(destInEdges, (edge: EO) => edge.dest === dest.key)[0];
|
|
196
183
|
}
|
|
197
184
|
}
|
|
198
185
|
|
|
@@ -201,18 +188,18 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
201
188
|
|
|
202
189
|
/**
|
|
203
190
|
* The function removes edges between two vertices and returns the removed edges.
|
|
204
|
-
* @param {VertexKey |
|
|
205
|
-
* unique identifier of a vertex in a graph, while `
|
|
206
|
-
* @param {VertexKey |
|
|
191
|
+
* @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
|
|
192
|
+
* unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
|
|
193
|
+
* @param {VertexKey | VO} v2 - The parameter `v2` represents either a `VertexKey` or a `VO` object. It is used to specify
|
|
207
194
|
* the second vertex in the edge that needs to be removed.
|
|
208
|
-
* @returns an array of removed edges (
|
|
195
|
+
* @returns an array of removed edges (EO[]).
|
|
209
196
|
*/
|
|
210
|
-
|
|
211
|
-
const removed:
|
|
197
|
+
deleteEdgesBetween(v1: VertexKey | VO, v2: VertexKey | VO): EO[] {
|
|
198
|
+
const removed: EO[] = [];
|
|
212
199
|
|
|
213
200
|
if (v1 && v2) {
|
|
214
|
-
const v1ToV2 = this.
|
|
215
|
-
const v2ToV1 = this.
|
|
201
|
+
const v1ToV2 = this.deleteEdgeSrcToDest(v1, v2);
|
|
202
|
+
const v2ToV1 = this.deleteEdgeSrcToDest(v2, v1);
|
|
216
203
|
|
|
217
204
|
v1ToV2 && removed.push(v1ToV2);
|
|
218
205
|
v2ToV1 && removed.push(v2ToV1);
|
|
@@ -223,11 +210,11 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
223
210
|
|
|
224
211
|
/**
|
|
225
212
|
* The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
|
|
226
|
-
* @param {
|
|
213
|
+
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
|
|
227
214
|
* (`VertexKey`).
|
|
228
|
-
* @returns The method `incomingEdgesOf` returns an array of edges (`
|
|
215
|
+
* @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
|
|
229
216
|
*/
|
|
230
|
-
incomingEdgesOf(vertexOrKey:
|
|
217
|
+
incomingEdgesOf(vertexOrKey: VO | VertexKey): EO[] {
|
|
231
218
|
const target = this._getVertex(vertexOrKey);
|
|
232
219
|
if (target) {
|
|
233
220
|
return this.inEdgeMap.get(target) || [];
|
|
@@ -237,11 +224,11 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
237
224
|
|
|
238
225
|
/**
|
|
239
226
|
* The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
|
|
240
|
-
* @param {
|
|
227
|
+
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
|
|
241
228
|
* (`VertexKey`).
|
|
242
|
-
* @returns The method `outgoingEdgesOf` returns an array of edges (`
|
|
229
|
+
* @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
|
|
243
230
|
*/
|
|
244
|
-
outgoingEdgesOf(vertexOrKey:
|
|
231
|
+
outgoingEdgesOf(vertexOrKey: VO | VertexKey): EO[] {
|
|
245
232
|
const target = this._getVertex(vertexOrKey);
|
|
246
233
|
if (target) {
|
|
247
234
|
return this._outEdgeMap.get(target) || [];
|
|
@@ -251,69 +238,69 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
251
238
|
|
|
252
239
|
/**
|
|
253
240
|
* The function "degreeOf" returns the total degree of a vertex, which is the sum of its out-degree and in-degree.
|
|
254
|
-
* @param {VertexKey |
|
|
241
|
+
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
|
|
255
242
|
* @returns The sum of the out-degree and in-degree of the specified vertex or vertex ID.
|
|
256
243
|
*/
|
|
257
|
-
degreeOf(vertexOrKey: VertexKey |
|
|
244
|
+
degreeOf(vertexOrKey: VertexKey | VO): number {
|
|
258
245
|
return this.outDegreeOf(vertexOrKey) + this.inDegreeOf(vertexOrKey);
|
|
259
246
|
}
|
|
260
247
|
|
|
261
248
|
/**
|
|
262
249
|
* The function "inDegreeOf" returns the number of incoming edges for a given vertex.
|
|
263
|
-
* @param {VertexKey |
|
|
250
|
+
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
|
|
264
251
|
* @returns The number of incoming edges of the specified vertex or vertex ID.
|
|
265
252
|
*/
|
|
266
|
-
inDegreeOf(vertexOrKey: VertexKey |
|
|
253
|
+
inDegreeOf(vertexOrKey: VertexKey | VO): number {
|
|
267
254
|
return this.incomingEdgesOf(vertexOrKey).length;
|
|
268
255
|
}
|
|
269
256
|
|
|
270
257
|
/**
|
|
271
258
|
* The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
|
|
272
|
-
* @param {VertexKey |
|
|
259
|
+
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
|
|
273
260
|
* @returns The number of outgoing edges from the specified vertex or vertex ID.
|
|
274
261
|
*/
|
|
275
|
-
outDegreeOf(vertexOrKey: VertexKey |
|
|
262
|
+
outDegreeOf(vertexOrKey: VertexKey | VO): number {
|
|
276
263
|
return this.outgoingEdgesOf(vertexOrKey).length;
|
|
277
264
|
}
|
|
278
265
|
|
|
279
266
|
/**
|
|
280
267
|
* The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
|
|
281
|
-
* @param {VertexKey |
|
|
268
|
+
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
|
|
282
269
|
* @returns The function `edgesOf` returns an array of edges.
|
|
283
270
|
*/
|
|
284
|
-
edgesOf(vertexOrKey: VertexKey |
|
|
271
|
+
edgesOf(vertexOrKey: VertexKey | VO): EO[] {
|
|
285
272
|
return [...this.outgoingEdgesOf(vertexOrKey), ...this.incomingEdgesOf(vertexOrKey)];
|
|
286
273
|
}
|
|
287
274
|
|
|
288
275
|
/**
|
|
289
276
|
* The function "getEdgeSrc" returns the source vertex of an edge, or null if the edge does not exist.
|
|
290
|
-
* @param {
|
|
291
|
-
* @returns either a vertex object (
|
|
277
|
+
* @param {EO} e - The parameter "e" is of type EO, which represents an edge in a graph.
|
|
278
|
+
* @returns either a vertex object (VO) or null.
|
|
292
279
|
*/
|
|
293
|
-
getEdgeSrc(e:
|
|
280
|
+
getEdgeSrc(e: EO): VO | null {
|
|
294
281
|
return this._getVertex(e.src);
|
|
295
282
|
}
|
|
296
283
|
|
|
297
284
|
/**
|
|
298
285
|
* The function "getEdgeDest" returns the destination vertex of an edge.
|
|
299
|
-
* @param {
|
|
300
|
-
* @returns either a vertex object of type
|
|
286
|
+
* @param {EO} e - The parameter "e" is of type "EO", which represents an edge in a graph.
|
|
287
|
+
* @returns either a vertex object of type VO or null.
|
|
301
288
|
*/
|
|
302
|
-
getEdgeDest(e:
|
|
289
|
+
getEdgeDest(e: EO): VO | null {
|
|
303
290
|
return this._getVertex(e.dest);
|
|
304
291
|
}
|
|
305
292
|
|
|
306
293
|
/**
|
|
307
294
|
* The function `getDestinations` returns an array of destination vertices connected to a given vertex.
|
|
308
|
-
* @param {
|
|
309
|
-
* find the destinations. It can be either a `
|
|
310
|
-
* @returns an array of vertices (
|
|
295
|
+
* @param {VO | VertexKey | null} vertex - The `vertex` parameter represents the starting vertex from which we want to
|
|
296
|
+
* find the destinations. It can be either a `VO` object, a `VertexKey` value, or `null`.
|
|
297
|
+
* @returns an array of vertices (VO[]).
|
|
311
298
|
*/
|
|
312
|
-
getDestinations(vertex:
|
|
299
|
+
getDestinations(vertex: VO | VertexKey | null): VO[] {
|
|
313
300
|
if (vertex === null) {
|
|
314
301
|
return [];
|
|
315
302
|
}
|
|
316
|
-
const destinations:
|
|
303
|
+
const destinations: VO[] = [];
|
|
317
304
|
const outgoingEdges = this.outgoingEdgesOf(vertex);
|
|
318
305
|
for (const outEdge of outgoingEdges) {
|
|
319
306
|
const child = this.getEdgeDest(outEdge);
|
|
@@ -332,18 +319,18 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
332
319
|
* specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
|
|
333
320
|
* @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns null.
|
|
334
321
|
*/
|
|
335
|
-
topologicalSort(propertyName?: 'vertex' | 'key'): Array<
|
|
322
|
+
topologicalSort(propertyName?: 'vertex' | 'key'): Array<VO | VertexKey> | null {
|
|
336
323
|
propertyName = propertyName ?? 'key';
|
|
337
324
|
// When judging whether there is a cycle in the undirected graph, all nodes with degree of **<= 1** are enqueued
|
|
338
325
|
// When judging whether there is a cycle in the directed graph, all nodes with **in degree = 0** are enqueued
|
|
339
|
-
const statusMap: Map<
|
|
326
|
+
const statusMap: Map<VO | VertexKey, TopologicalStatus> = new Map<VO | VertexKey, TopologicalStatus>();
|
|
340
327
|
for (const entry of this.vertices) {
|
|
341
328
|
statusMap.set(entry[1], 0);
|
|
342
329
|
}
|
|
343
330
|
|
|
344
|
-
let sorted: (
|
|
331
|
+
let sorted: (VO | VertexKey)[] = [];
|
|
345
332
|
let hasCycle = false;
|
|
346
|
-
const dfs = (cur:
|
|
333
|
+
const dfs = (cur: VO | VertexKey) => {
|
|
347
334
|
statusMap.set(cur, 1);
|
|
348
335
|
const children = this.getDestinations(cur);
|
|
349
336
|
for (const child of children) {
|
|
@@ -372,10 +359,10 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
372
359
|
|
|
373
360
|
/**
|
|
374
361
|
* The `edgeSet` function returns an array of all the edges in the graph.
|
|
375
|
-
* @returns The `edgeSet()` method returns an array of edges (`
|
|
362
|
+
* @returns The `edgeSet()` method returns an array of edges (`EO[]`).
|
|
376
363
|
*/
|
|
377
|
-
edgeSet():
|
|
378
|
-
let edges:
|
|
364
|
+
edgeSet(): EO[] {
|
|
365
|
+
let edges: EO[] = [];
|
|
379
366
|
this._outEdgeMap.forEach(outEdges => {
|
|
380
367
|
edges = [...edges, ...outEdges];
|
|
381
368
|
});
|
|
@@ -384,12 +371,12 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
384
371
|
|
|
385
372
|
/**
|
|
386
373
|
* The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
|
|
387
|
-
* @param {
|
|
374
|
+
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
|
|
388
375
|
* (`VertexKey`).
|
|
389
|
-
* @returns an array of vertices (
|
|
376
|
+
* @returns an array of vertices (VO[]).
|
|
390
377
|
*/
|
|
391
|
-
getNeighbors(vertexOrKey:
|
|
392
|
-
const neighbors:
|
|
378
|
+
getNeighbors(vertexOrKey: VO | VertexKey): VO[] {
|
|
379
|
+
const neighbors: VO[] = [];
|
|
393
380
|
const vertex = this._getVertex(vertexOrKey);
|
|
394
381
|
if (vertex) {
|
|
395
382
|
const outEdges = this.outgoingEdgesOf(vertex);
|
|
@@ -407,11 +394,11 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
407
394
|
/**
|
|
408
395
|
* The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
|
|
409
396
|
* otherwise it returns null.
|
|
410
|
-
* @param {
|
|
411
|
-
* @returns The function `getEndsOfEdge` returns an array containing two vertices `[
|
|
397
|
+
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
|
|
398
|
+
* @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
|
|
412
399
|
* graph. If the edge does not exist, it returns `null`.
|
|
413
400
|
*/
|
|
414
|
-
getEndsOfEdge(edge:
|
|
401
|
+
getEndsOfEdge(edge: EO): [VO, VO] | null {
|
|
415
402
|
if (!this.hasEdge(edge.src, edge.dest)) {
|
|
416
403
|
return null;
|
|
417
404
|
}
|
|
@@ -426,12 +413,12 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
426
413
|
|
|
427
414
|
/**
|
|
428
415
|
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
|
|
429
|
-
* @param {
|
|
416
|
+
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
|
|
430
417
|
* needs to be added to the graph.
|
|
431
418
|
* @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
|
|
432
419
|
* source or destination vertex does not exist in the graph.
|
|
433
420
|
*/
|
|
434
|
-
protected _addEdgeOnly(edge:
|
|
421
|
+
protected _addEdgeOnly(edge: EO): boolean {
|
|
435
422
|
if (!(this.hasVertex(edge.src) && this.hasVertex(edge.dest))) {
|
|
436
423
|
return false;
|
|
437
424
|
}
|
|
@@ -459,12 +446,4 @@ export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E ext
|
|
|
459
446
|
return false;
|
|
460
447
|
}
|
|
461
448
|
}
|
|
462
|
-
|
|
463
|
-
protected _setOutEdgeMap(value: Map<V, E[]>) {
|
|
464
|
-
this._outEdgeMap = value;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
protected _setInEdgeMap(value: Map<V, E[]>) {
|
|
468
|
-
this._inEdgeMap = value;
|
|
469
|
-
}
|
|
470
449
|
}
|
|
@@ -2,6 +2,9 @@ import {MapGraphCoordinate, VertexKey} from '../../types';
|
|
|
2
2
|
import {DirectedEdge, DirectedGraph, DirectedVertex} from './directed-graph';
|
|
3
3
|
|
|
4
4
|
export class MapVertex<V = any> extends DirectedVertex<V> {
|
|
5
|
+
lat: number;
|
|
6
|
+
long: number;
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* The constructor function initializes an object with an key, latitude, longitude, and an optional value.
|
|
7
10
|
* @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex.
|
|
@@ -11,37 +14,17 @@ export class MapVertex<V = any> extends DirectedVertex<V> {
|
|
|
11
14
|
* @param {number} long - The "long" parameter represents the longitude of a location. Longitude is a geographic
|
|
12
15
|
* coordinate that specifies the east-west position of a point on the Earth's surface. It is measured in degrees, with
|
|
13
16
|
* values ranging from -180 to 180.
|
|
14
|
-
* @param {V} [
|
|
17
|
+
* @param {V} [value] - The "value" parameter is an optional value of type V. It is not required to be provided when
|
|
15
18
|
* creating an instance of the class.
|
|
16
19
|
*/
|
|
17
|
-
constructor(key: VertexKey, lat: number, long: number
|
|
18
|
-
super(key,
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
private _lat: number;
|
|
24
|
-
|
|
25
|
-
get lat(): number {
|
|
26
|
-
return this._lat;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
set lat(value: number) {
|
|
30
|
-
this._lat = value;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private _long: number;
|
|
34
|
-
|
|
35
|
-
get long(): number {
|
|
36
|
-
return this._long;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
set long(value: number) {
|
|
40
|
-
this._long = value;
|
|
20
|
+
constructor(key: VertexKey, value: V, lat: number, long: number) {
|
|
21
|
+
super(key, value);
|
|
22
|
+
this.lat = lat;
|
|
23
|
+
this.long = long;
|
|
41
24
|
}
|
|
42
25
|
}
|
|
43
26
|
|
|
44
|
-
export class MapEdge<
|
|
27
|
+
export class MapEdge<E = any> extends DirectedEdge<E> {
|
|
45
28
|
/**
|
|
46
29
|
* The constructor function initializes a new instance of a class with the given source, destination, weight, and
|
|
47
30
|
* value.
|
|
@@ -49,18 +32,20 @@ export class MapEdge<V = any> extends DirectedEdge<V> {
|
|
|
49
32
|
* a graph.
|
|
50
33
|
* @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for an edge.
|
|
51
34
|
* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
|
|
52
|
-
* @param {
|
|
35
|
+
* @param {E} [value] - The "value" parameter is an optional parameter of type E. It is used to store additional
|
|
53
36
|
* information or data associated with the edge.
|
|
54
37
|
*/
|
|
55
|
-
constructor(src: VertexKey, dest: VertexKey, weight?: number,
|
|
56
|
-
super(src, dest, weight,
|
|
38
|
+
constructor(src: VertexKey, dest: VertexKey, weight?: number, value?: E) {
|
|
39
|
+
super(src, dest, weight, value);
|
|
57
40
|
}
|
|
58
41
|
}
|
|
59
42
|
|
|
60
|
-
export class MapGraph<
|
|
61
|
-
V,
|
|
62
|
-
E
|
|
63
|
-
>
|
|
43
|
+
export class MapGraph<
|
|
44
|
+
V = any,
|
|
45
|
+
E = any,
|
|
46
|
+
VO extends MapVertex<V> = MapVertex<V>,
|
|
47
|
+
EO extends MapEdge<E> = MapEdge<E>
|
|
48
|
+
> extends DirectedGraph<V, E, VO, EO> {
|
|
64
49
|
/**
|
|
65
50
|
* The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
|
|
66
51
|
* @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
|
|
@@ -76,44 +61,31 @@ export class MapGraph<V extends MapVertex<V['val']> = MapVertex, E extends MapEd
|
|
|
76
61
|
this._bottomRight = bottomRight;
|
|
77
62
|
}
|
|
78
63
|
|
|
79
|
-
|
|
64
|
+
protected _origin: MapGraphCoordinate = [0, 0];
|
|
80
65
|
|
|
81
66
|
get origin(): MapGraphCoordinate {
|
|
82
67
|
return this._origin;
|
|
83
68
|
}
|
|
84
69
|
|
|
85
|
-
|
|
86
|
-
this._origin = value;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
private _bottomRight: MapGraphCoordinate | undefined;
|
|
70
|
+
protected _bottomRight: MapGraphCoordinate | undefined;
|
|
90
71
|
|
|
91
72
|
get bottomRight(): MapGraphCoordinate | undefined {
|
|
92
73
|
return this._bottomRight;
|
|
93
74
|
}
|
|
94
75
|
|
|
95
|
-
set bottomRight(value: MapGraphCoordinate | undefined) {
|
|
96
|
-
this._bottomRight = value;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
76
|
/**
|
|
100
77
|
* The function creates a new vertex with the given key, value, latitude, and longitude.
|
|
101
78
|
* @param {VertexKey} key - The key parameter is the unique identifier for the vertex. It is of type VertexKey, which could
|
|
102
79
|
* be a string or a number depending on how you define it in your code.
|
|
103
|
-
* @param [
|
|
104
|
-
* is of type `V
|
|
80
|
+
* @param [value] - The `value` parameter is an optional value that can be assigned to the `value` property of the vertex. It
|
|
81
|
+
* is of type `V`, which means it should be of the same type as the `value` property of the vertex class `VO`.
|
|
105
82
|
* @param {number} lat - The `lat` parameter represents the latitude of the vertex. It is a number that specifies the
|
|
106
83
|
* position of the vertex on the Earth's surface in the north-south direction.
|
|
107
84
|
* @param {number} long - The `long` parameter represents the longitude coordinate of the vertex.
|
|
108
|
-
* @returns The method is returning a new instance of the `MapVertex` class, casted as type `
|
|
85
|
+
* @returns The method is returning a new instance of the `MapVertex` class, casted as type `VO`.
|
|
109
86
|
*/
|
|
110
|
-
override createVertex(
|
|
111
|
-
key
|
|
112
|
-
val?: V['val'],
|
|
113
|
-
lat: number = this.origin[0],
|
|
114
|
-
long: number = this.origin[1]
|
|
115
|
-
): V {
|
|
116
|
-
return new MapVertex(key, lat, long, val) as V;
|
|
87
|
+
override createVertex(key: VertexKey, value?: V, lat: number = this.origin[0], long: number = this.origin[1]): VO {
|
|
88
|
+
return new MapVertex(key, value, lat, long) as VO;
|
|
117
89
|
}
|
|
118
90
|
|
|
119
91
|
/**
|
|
@@ -124,11 +96,11 @@ export class MapGraph<V extends MapVertex<V['val']> = MapVertex, E extends MapEd
|
|
|
124
96
|
* @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. It
|
|
125
97
|
* is used to assign a numerical value to the edge, which can be used in algorithms such as shortest path algorithms.
|
|
126
98
|
* If the weight is not provided, it can be set to a default value or left undefined.
|
|
127
|
-
* @param [
|
|
99
|
+
* @param [value] - The `value` parameter is an optional value that can be assigned to the edge. It can be of any type,
|
|
128
100
|
* depending on the specific implementation of the `MapEdge` class.
|
|
129
|
-
* @returns a new instance of the `MapEdge` class,
|
|
101
|
+
* @returns a new instance of the `MapEdge` class, cast as type `EO`.
|
|
130
102
|
*/
|
|
131
|
-
override createEdge(src: VertexKey, dest: VertexKey, weight?: number,
|
|
132
|
-
return new MapEdge(src, dest, weight,
|
|
103
|
+
override createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO {
|
|
104
|
+
return new MapEdge(src, dest, weight, value) as EO;
|
|
133
105
|
}
|
|
134
106
|
}
|