data-structure-typed 1.43.3 → 1.44.1
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/CHANGELOG.md +1 -1
- package/README.md +15 -15
- package/benchmark/report.html +30 -30
- package/benchmark/report.json +152 -206
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/index.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -0
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -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.js.map +1 -0
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -0
- package/dist/cjs/data-structures/hash/coordinate-map.js.map +1 -0
- package/dist/cjs/data-structures/hash/coordinate-set.js.map +1 -0
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -0
- package/dist/cjs/data-structures/hash/hash-table.js.map +1 -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.js.map +1 -0
- package/dist/cjs/data-structures/heap/index.js.map +1 -0
- package/dist/cjs/data-structures/heap/max-heap.js.map +1 -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.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.js.map +1 -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.js.map +1 -0
- package/dist/cjs/data-structures/matrix/matrix2d.js.map +1 -0
- package/dist/cjs/data-structures/matrix/navigator.js.map +1 -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.js.map +1 -0
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -0
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -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.js.map +1 -0
- package/dist/cjs/data-structures/stack/index.js.map +1 -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.js.map +1 -0
- package/dist/cjs/data-structures/trie/index.js.map +1 -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.js.map +1 -0
- package/dist/cjs/interfaces/doubly-linked-list.js.map +1 -0
- package/dist/cjs/{src/interfaces → interfaces}/graph.js.map +1 -1
- package/dist/cjs/{src/interfaces → interfaces}/heap.js.map +1 -1
- 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.js.map +1 -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.js.map +1 -0
- package/dist/cjs/types/data-structures/binary-tree/bst.js.map +1 -0
- package/dist/cjs/types/data-structures/binary-tree/index.js.map +1 -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-multimap.js.map +1 -0
- package/dist/cjs/types/data-structures/graph/abstract-graph.js.map +1 -0
- package/dist/cjs/types/data-structures/graph/directed-graph.d.ts +1 -0
- package/dist/cjs/types/data-structures/graph/directed-graph.js +3 -0
- package/dist/cjs/types/data-structures/graph/directed-graph.js.map +1 -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.map +1 -0
- package/dist/cjs/types/data-structures/hash/coordinate-set.js.map +1 -0
- package/dist/cjs/types/data-structures/hash/hash-map.js.map +1 -0
- package/dist/cjs/types/data-structures/hash/hash-table.js.map +1 -0
- package/dist/cjs/types/data-structures/hash/index.js.map +1 -0
- package/dist/cjs/types/data-structures/hash/tree-map.js.map +1 -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.js.map +1 -0
- package/dist/cjs/types/data-structures/heap/max-heap.js.map +1 -0
- package/dist/cjs/types/data-structures/heap/min-heap.js.map +1 -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.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.map +1 -0
- package/dist/cjs/types/data-structures/matrix/index.js.map +1 -0
- package/dist/cjs/types/data-structures/matrix/matrix.js.map +1 -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.map +1 -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.map +1 -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.map +1 -0
- package/dist/cjs/types/data-structures/queue/index.js.map +1 -0
- package/dist/cjs/types/data-structures/queue/queue.js.map +1 -0
- package/dist/cjs/types/data-structures/stack/index.js.map +1 -0
- package/dist/cjs/types/data-structures/stack/stack.js.map +1 -0
- package/dist/cjs/types/data-structures/tree/index.js.map +1 -0
- package/dist/cjs/types/data-structures/tree/tree.js.map +1 -0
- package/dist/cjs/types/data-structures/trie/index.js.map +1 -0
- package/dist/cjs/types/data-structures/trie/trie.js.map +1 -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/{src/types → types}/utils/utils.js.map +1 -1
- 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.js.map +1 -0
- package/dist/mjs/{src/data-structures → data-structures}/binary-tree/avl-tree.js +3 -8
- package/dist/mjs/{src/data-structures → data-structures}/binary-tree/binary-indexed-tree.js +3 -7
- package/dist/mjs/{src/data-structures → data-structures}/binary-tree/binary-tree.js +35 -40
- package/dist/mjs/{src/data-structures → data-structures}/binary-tree/bst.js +34 -39
- package/dist/mjs/data-structures/binary-tree/index.js +7 -0
- package/dist/mjs/{src/data-structures → data-structures}/binary-tree/rb-tree.js +42 -47
- package/dist/mjs/{src/data-structures → data-structures}/binary-tree/segment-tree.js +2 -7
- package/dist/mjs/{src/data-structures → data-structures}/binary-tree/tree-multimap.js +10 -15
- package/dist/mjs/{src/data-structures → data-structures}/graph/abstract-graph.js +9 -15
- package/dist/mjs/{src/data-structures → data-structures}/graph/directed-graph.js +9 -15
- package/dist/mjs/data-structures/graph/index.js +4 -0
- package/dist/mjs/{src/data-structures → data-structures}/graph/map-graph.js +4 -10
- package/dist/mjs/{src/data-structures → data-structures}/graph/undirected-graph.js +7 -13
- package/dist/mjs/{src/data-structures → data-structures}/hash/coordinate-map.js +1 -5
- package/dist/mjs/{src/data-structures → data-structures}/hash/coordinate-set.js +1 -5
- package/dist/mjs/{src/data-structures → data-structures}/hash/hash-map.js +1 -5
- package/dist/mjs/{src/data-structures → data-structures}/hash/hash-table.js +2 -7
- package/dist/mjs/data-structures/hash/index.js +6 -0
- package/dist/mjs/data-structures/hash/tree-map.js +2 -0
- package/dist/mjs/data-structures/hash/tree-set.js +2 -0
- package/dist/mjs/{src/data-structures → data-structures}/heap/heap.js +3 -9
- package/dist/mjs/data-structures/heap/index.js +3 -0
- package/dist/mjs/{src/data-structures → data-structures}/heap/max-heap.js +2 -6
- package/dist/mjs/{src/data-structures → data-structures}/heap/min-heap.js +2 -6
- package/dist/mjs/data-structures/index.js +11 -0
- package/dist/mjs/{src/data-structures → data-structures}/linked-list/doubly-linked-list.js +2 -7
- package/dist/mjs/data-structures/linked-list/index.js +3 -0
- package/dist/mjs/{src/data-structures → data-structures}/linked-list/singly-linked-list.js +2 -7
- package/dist/mjs/{src/data-structures → data-structures}/linked-list/skip-linked-list.js +2 -7
- package/dist/mjs/data-structures/matrix/index.js +4 -0
- package/dist/mjs/{src/data-structures → data-structures}/matrix/matrix.js +1 -5
- package/dist/mjs/{src/data-structures → data-structures}/matrix/matrix2d.js +4 -8
- package/dist/mjs/{src/data-structures → data-structures}/matrix/navigator.js +2 -7
- package/dist/mjs/{src/data-structures → data-structures}/matrix/vector2d.js +1 -5
- package/dist/mjs/{src/data-structures → data-structures}/priority-queue/max-priority-queue.js +2 -6
- package/dist/mjs/{src/data-structures → data-structures}/priority-queue/min-priority-queue.js +2 -6
- package/dist/mjs/data-structures/priority-queue/priority-queue.js +13 -0
- package/dist/mjs/{src/data-structures → data-structures}/queue/deque.js +4 -10
- package/dist/mjs/{src/data-structures → data-structures}/queue/queue.js +3 -8
- package/dist/mjs/{src/data-structures → data-structures}/stack/stack.js +1 -5
- package/dist/mjs/{src/data-structures → data-structures}/tree/tree.js +1 -5
- package/dist/mjs/{src/data-structures → data-structures}/trie/trie.js +2 -7
- package/dist/mjs/index.js +4 -0
- package/dist/mjs/interfaces/index.js +8 -0
- package/dist/mjs/{src/types → types}/data-structures/binary-tree/binary-tree.js +4 -7
- package/dist/mjs/types/data-structures/binary-tree/index.js +6 -0
- package/dist/mjs/types/data-structures/binary-tree/rb-tree.js +5 -0
- package/dist/mjs/types/data-structures/graph/directed-graph.d.ts +1 -0
- package/dist/mjs/types/data-structures/graph/index.js +3 -0
- package/dist/mjs/types/data-structures/hash/hash-table.d.ts +1 -0
- package/dist/mjs/types/data-structures/hash/hash-table.js +1 -0
- package/dist/mjs/types/data-structures/hash/index.js +1 -0
- package/dist/mjs/types/data-structures/hash/tree-map.d.ts +1 -0
- package/dist/mjs/types/data-structures/hash/tree-map.js +1 -0
- package/dist/mjs/types/data-structures/hash/tree-set.d.ts +1 -0
- package/dist/mjs/types/data-structures/hash/tree-set.js +1 -0
- package/dist/mjs/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/mjs/types/data-structures/heap/heap.js +1 -0
- package/dist/mjs/types/data-structures/heap/index.js +1 -0
- package/dist/mjs/types/data-structures/heap/max-heap.d.ts +1 -0
- package/dist/mjs/types/data-structures/heap/max-heap.js +1 -0
- package/dist/mjs/types/data-structures/heap/min-heap.d.ts +1 -0
- package/dist/mjs/types/data-structures/heap/min-heap.js +1 -0
- package/dist/mjs/types/data-structures/index.js +11 -0
- package/dist/mjs/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -0
- package/dist/mjs/types/data-structures/linked-list/doubly-linked-list.js +1 -0
- package/dist/mjs/types/data-structures/linked-list/index.js +2 -0
- package/dist/mjs/types/data-structures/linked-list/singly-linked-list.d.ts +1 -0
- package/dist/mjs/types/data-structures/linked-list/singly-linked-list.js +1 -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 +1 -0
- package/dist/mjs/types/data-structures/matrix/index.js +1 -0
- package/dist/mjs/types/data-structures/matrix/matrix.d.ts +1 -0
- package/dist/mjs/types/data-structures/matrix/matrix.js +1 -0
- package/dist/mjs/types/data-structures/matrix/matrix2d.d.ts +1 -0
- package/dist/mjs/types/data-structures/matrix/matrix2d.js +1 -0
- package/dist/mjs/types/data-structures/matrix/navigator.js +1 -0
- package/dist/mjs/types/data-structures/matrix/vector2d.d.ts +1 -0
- package/dist/mjs/types/data-structures/matrix/vector2d.js +1 -0
- package/dist/mjs/types/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/mjs/types/data-structures/priority-queue/index.js +3 -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 +1 -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 +1 -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 +1 -0
- package/dist/mjs/types/data-structures/queue/deque.d.ts +1 -0
- package/dist/mjs/types/data-structures/queue/deque.js +1 -0
- package/dist/mjs/types/data-structures/queue/index.d.ts +2 -0
- package/dist/mjs/types/data-structures/queue/index.js +2 -0
- package/dist/mjs/types/data-structures/queue/queue.d.ts +1 -0
- package/dist/mjs/types/data-structures/queue/queue.js +1 -0
- package/dist/mjs/types/data-structures/stack/index.d.ts +1 -0
- package/dist/mjs/types/data-structures/stack/index.js +1 -0
- package/dist/mjs/types/data-structures/stack/stack.d.ts +1 -0
- package/dist/mjs/types/data-structures/stack/stack.js +1 -0
- package/dist/mjs/types/data-structures/tree/index.d.ts +1 -0
- package/dist/mjs/types/data-structures/tree/index.js +1 -0
- package/dist/mjs/types/data-structures/tree/tree.d.ts +1 -0
- package/dist/mjs/types/data-structures/tree/tree.js +1 -0
- package/dist/mjs/types/data-structures/trie/index.d.ts +1 -0
- package/dist/mjs/types/data-structures/trie/index.js +1 -0
- package/dist/mjs/types/data-structures/trie/trie.d.ts +1 -0
- package/dist/mjs/types/data-structures/trie/trie.js +1 -0
- package/dist/mjs/types/helpers.js +6 -0
- package/dist/mjs/types/index.js +3 -0
- package/dist/mjs/types/utils/index.js +2 -0
- package/dist/mjs/types/utils/utils.js +1 -0
- package/dist/mjs/types/utils/validate-type.js +1 -0
- package/dist/mjs/utils/index.js +1 -0
- package/dist/mjs/utils/utils.js +54 -0
- package/dist/umd/data-structure-typed.js +288 -201
- package/dist/umd/data-structure-typed.min.js +5 -10
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +21 -20
- package/src/types/data-structures/graph/directed-graph.ts +0 -6
- package/test/config.ts +1 -1
- package/test/integration/all-in-one.ts +110 -0
- package/test/performance/reportor.ts +2 -2
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +2 -2
- package/tsconfig-base.json +0 -1
- package/tsconfig-cjs.json +4 -3
- package/tsconfig-mjs.json +5 -3
- package/tsup.config.js +22 -18
- package/dist/cjs/src/data-structures/binary-tree/avl-tree.js.map +0 -1
- package/dist/cjs/src/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
- package/dist/cjs/src/data-structures/binary-tree/binary-tree.js.map +0 -1
- package/dist/cjs/src/data-structures/binary-tree/bst.js.map +0 -1
- package/dist/cjs/src/data-structures/binary-tree/index.js.map +0 -1
- package/dist/cjs/src/data-structures/binary-tree/rb-tree.js.map +0 -1
- package/dist/cjs/src/data-structures/binary-tree/segment-tree.js.map +0 -1
- package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js.map +0 -1
- package/dist/cjs/src/data-structures/graph/abstract-graph.js.map +0 -1
- package/dist/cjs/src/data-structures/graph/directed-graph.js.map +0 -1
- package/dist/cjs/src/data-structures/graph/index.js.map +0 -1
- package/dist/cjs/src/data-structures/graph/map-graph.js.map +0 -1
- package/dist/cjs/src/data-structures/graph/undirected-graph.js.map +0 -1
- package/dist/cjs/src/data-structures/hash/coordinate-map.js.map +0 -1
- package/dist/cjs/src/data-structures/hash/coordinate-set.js.map +0 -1
- package/dist/cjs/src/data-structures/hash/hash-map.js.map +0 -1
- package/dist/cjs/src/data-structures/hash/hash-table.js.map +0 -1
- package/dist/cjs/src/data-structures/hash/index.js.map +0 -1
- package/dist/cjs/src/data-structures/hash/tree-map.js.map +0 -1
- package/dist/cjs/src/data-structures/hash/tree-set.js.map +0 -1
- package/dist/cjs/src/data-structures/heap/heap.js.map +0 -1
- package/dist/cjs/src/data-structures/heap/index.js.map +0 -1
- package/dist/cjs/src/data-structures/heap/max-heap.js.map +0 -1
- package/dist/cjs/src/data-structures/heap/min-heap.js.map +0 -1
- package/dist/cjs/src/data-structures/index.js.map +0 -1
- package/dist/cjs/src/data-structures/linked-list/doubly-linked-list.js.map +0 -1
- package/dist/cjs/src/data-structures/linked-list/index.js.map +0 -1
- package/dist/cjs/src/data-structures/linked-list/singly-linked-list.js.map +0 -1
- package/dist/cjs/src/data-structures/linked-list/skip-linked-list.js.map +0 -1
- package/dist/cjs/src/data-structures/matrix/index.js.map +0 -1
- package/dist/cjs/src/data-structures/matrix/matrix.js.map +0 -1
- package/dist/cjs/src/data-structures/matrix/matrix2d.js.map +0 -1
- package/dist/cjs/src/data-structures/matrix/navigator.js.map +0 -1
- package/dist/cjs/src/data-structures/matrix/vector2d.js.map +0 -1
- package/dist/cjs/src/data-structures/priority-queue/index.js.map +0 -1
- package/dist/cjs/src/data-structures/priority-queue/max-priority-queue.js.map +0 -1
- package/dist/cjs/src/data-structures/priority-queue/min-priority-queue.js.map +0 -1
- package/dist/cjs/src/data-structures/priority-queue/priority-queue.js.map +0 -1
- package/dist/cjs/src/data-structures/queue/deque.js.map +0 -1
- package/dist/cjs/src/data-structures/queue/index.js.map +0 -1
- package/dist/cjs/src/data-structures/queue/queue.js.map +0 -1
- package/dist/cjs/src/data-structures/stack/index.js.map +0 -1
- package/dist/cjs/src/data-structures/stack/stack.js.map +0 -1
- package/dist/cjs/src/data-structures/tree/index.js.map +0 -1
- package/dist/cjs/src/data-structures/tree/tree.js.map +0 -1
- package/dist/cjs/src/data-structures/trie/index.js.map +0 -1
- package/dist/cjs/src/data-structures/trie/trie.js.map +0 -1
- package/dist/cjs/src/index.js.map +0 -1
- package/dist/cjs/src/interfaces/binary-tree.js.map +0 -1
- package/dist/cjs/src/interfaces/doubly-linked-list.js.map +0 -1
- package/dist/cjs/src/interfaces/index.js.map +0 -1
- package/dist/cjs/src/interfaces/navigator.js.map +0 -1
- package/dist/cjs/src/interfaces/priority-queue.js.map +0 -1
- package/dist/cjs/src/interfaces/segment-tree.js.map +0 -1
- package/dist/cjs/src/interfaces/singly-linked-list.js.map +0 -1
- package/dist/cjs/src/types/data-structures/binary-tree/avl-tree.js.map +0 -1
- package/dist/cjs/src/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
- package/dist/cjs/src/types/data-structures/binary-tree/binary-tree.js.map +0 -1
- package/dist/cjs/src/types/data-structures/binary-tree/bst.js.map +0 -1
- package/dist/cjs/src/types/data-structures/binary-tree/index.js.map +0 -1
- package/dist/cjs/src/types/data-structures/binary-tree/rb-tree.js.map +0 -1
- package/dist/cjs/src/types/data-structures/binary-tree/segment-tree.js.map +0 -1
- package/dist/cjs/src/types/data-structures/binary-tree/tree-multimap.js.map +0 -1
- package/dist/cjs/src/types/data-structures/graph/abstract-graph.js.map +0 -1
- package/dist/cjs/src/types/data-structures/graph/directed-graph.d.ts +0 -6
- package/dist/cjs/src/types/data-structures/graph/directed-graph.js +0 -10
- package/dist/cjs/src/types/data-structures/graph/directed-graph.js.map +0 -1
- package/dist/cjs/src/types/data-structures/graph/index.js.map +0 -1
- package/dist/cjs/src/types/data-structures/graph/map-graph.js.map +0 -1
- package/dist/cjs/src/types/data-structures/graph/undirected-graph.js.map +0 -1
- package/dist/cjs/src/types/data-structures/hash/coordinate-map.js.map +0 -1
- package/dist/cjs/src/types/data-structures/hash/coordinate-set.js.map +0 -1
- package/dist/cjs/src/types/data-structures/hash/hash-map.js.map +0 -1
- package/dist/cjs/src/types/data-structures/hash/hash-table.js.map +0 -1
- package/dist/cjs/src/types/data-structures/hash/index.js.map +0 -1
- package/dist/cjs/src/types/data-structures/hash/tree-map.js.map +0 -1
- package/dist/cjs/src/types/data-structures/hash/tree-set.js.map +0 -1
- package/dist/cjs/src/types/data-structures/heap/heap.js.map +0 -1
- package/dist/cjs/src/types/data-structures/heap/index.js.map +0 -1
- package/dist/cjs/src/types/data-structures/heap/max-heap.js.map +0 -1
- package/dist/cjs/src/types/data-structures/heap/min-heap.js.map +0 -1
- package/dist/cjs/src/types/data-structures/index.js.map +0 -1
- package/dist/cjs/src/types/data-structures/linked-list/doubly-linked-list.js.map +0 -1
- package/dist/cjs/src/types/data-structures/linked-list/index.js.map +0 -1
- package/dist/cjs/src/types/data-structures/linked-list/singly-linked-list.js.map +0 -1
- package/dist/cjs/src/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
- package/dist/cjs/src/types/data-structures/matrix/index.js.map +0 -1
- package/dist/cjs/src/types/data-structures/matrix/matrix.js.map +0 -1
- package/dist/cjs/src/types/data-structures/matrix/matrix2d.js.map +0 -1
- package/dist/cjs/src/types/data-structures/matrix/navigator.js.map +0 -1
- package/dist/cjs/src/types/data-structures/matrix/vector2d.js.map +0 -1
- package/dist/cjs/src/types/data-structures/priority-queue/index.js.map +0 -1
- package/dist/cjs/src/types/data-structures/priority-queue/max-priority-queue.js.map +0 -1
- package/dist/cjs/src/types/data-structures/priority-queue/min-priority-queue.js.map +0 -1
- package/dist/cjs/src/types/data-structures/priority-queue/priority-queue.js.map +0 -1
- package/dist/cjs/src/types/data-structures/queue/deque.js.map +0 -1
- package/dist/cjs/src/types/data-structures/queue/index.js.map +0 -1
- package/dist/cjs/src/types/data-structures/queue/queue.js.map +0 -1
- package/dist/cjs/src/types/data-structures/stack/index.js.map +0 -1
- package/dist/cjs/src/types/data-structures/stack/stack.js.map +0 -1
- package/dist/cjs/src/types/data-structures/tree/index.js.map +0 -1
- package/dist/cjs/src/types/data-structures/tree/tree.js.map +0 -1
- package/dist/cjs/src/types/data-structures/trie/index.js.map +0 -1
- package/dist/cjs/src/types/data-structures/trie/trie.js.map +0 -1
- package/dist/cjs/src/types/helpers.js.map +0 -1
- package/dist/cjs/src/types/index.js.map +0 -1
- package/dist/cjs/src/types/utils/index.js.map +0 -1
- package/dist/cjs/src/types/utils/validate-type.js.map +0 -1
- package/dist/cjs/src/utils/index.js.map +0 -1
- package/dist/cjs/src/utils/utils.js.map +0 -1
- package/dist/mjs/src/data-structures/binary-tree/index.js +0 -23
- package/dist/mjs/src/data-structures/graph/index.js +0 -20
- package/dist/mjs/src/data-structures/hash/index.js +0 -22
- package/dist/mjs/src/data-structures/hash/tree-map.js +0 -6
- package/dist/mjs/src/data-structures/hash/tree-set.js +0 -6
- package/dist/mjs/src/data-structures/heap/index.js +0 -19
- package/dist/mjs/src/data-structures/index.js +0 -27
- package/dist/mjs/src/data-structures/linked-list/index.js +0 -19
- package/dist/mjs/src/data-structures/matrix/index.js +0 -20
- package/dist/mjs/src/data-structures/priority-queue/index.js +0 -19
- package/dist/mjs/src/data-structures/priority-queue/priority-queue.js +0 -17
- package/dist/mjs/src/data-structures/queue/index.js +0 -18
- package/dist/mjs/src/data-structures/stack/index.js +0 -17
- package/dist/mjs/src/data-structures/tree/index.js +0 -17
- package/dist/mjs/src/data-structures/trie/index.js +0 -17
- package/dist/mjs/src/index.js +0 -20
- package/dist/mjs/src/interfaces/binary-tree.js +0 -2
- package/dist/mjs/src/interfaces/doubly-linked-list.js +0 -2
- package/dist/mjs/src/interfaces/graph.js +0 -2
- package/dist/mjs/src/interfaces/heap.js +0 -2
- package/dist/mjs/src/interfaces/index.js +0 -24
- package/dist/mjs/src/interfaces/navigator.js +0 -2
- package/dist/mjs/src/interfaces/priority-queue.js +0 -2
- package/dist/mjs/src/interfaces/segment-tree.js +0 -2
- package/dist/mjs/src/interfaces/singly-linked-list.js +0 -2
- package/dist/mjs/src/types/data-structures/binary-tree/avl-tree.js +0 -2
- package/dist/mjs/src/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
- package/dist/mjs/src/types/data-structures/binary-tree/bst.js +0 -2
- package/dist/mjs/src/types/data-structures/binary-tree/index.js +0 -22
- package/dist/mjs/src/types/data-structures/binary-tree/rb-tree.js +0 -8
- package/dist/mjs/src/types/data-structures/binary-tree/segment-tree.js +0 -2
- package/dist/mjs/src/types/data-structures/binary-tree/tree-multimap.js +0 -2
- package/dist/mjs/src/types/data-structures/graph/abstract-graph.js +0 -2
- package/dist/mjs/src/types/data-structures/graph/directed-graph.d.ts +0 -6
- package/dist/mjs/src/types/data-structures/graph/directed-graph.js +0 -9
- package/dist/mjs/src/types/data-structures/graph/index.js +0 -19
- package/dist/mjs/src/types/data-structures/graph/map-graph.js +0 -2
- package/dist/mjs/src/types/data-structures/graph/undirected-graph.js +0 -2
- package/dist/mjs/src/types/data-structures/hash/coordinate-map.js +0 -2
- package/dist/mjs/src/types/data-structures/hash/coordinate-set.js +0 -2
- package/dist/mjs/src/types/data-structures/hash/hash-map.js +0 -2
- package/dist/mjs/src/types/data-structures/hash/hash-table.js +0 -2
- package/dist/mjs/src/types/data-structures/hash/index.js +0 -2
- package/dist/mjs/src/types/data-structures/hash/tree-map.js +0 -2
- package/dist/mjs/src/types/data-structures/hash/tree-set.js +0 -2
- package/dist/mjs/src/types/data-structures/heap/heap.js +0 -2
- package/dist/mjs/src/types/data-structures/heap/index.js +0 -17
- package/dist/mjs/src/types/data-structures/heap/max-heap.js +0 -2
- package/dist/mjs/src/types/data-structures/heap/min-heap.js +0 -2
- package/dist/mjs/src/types/data-structures/index.js +0 -27
- package/dist/mjs/src/types/data-structures/linked-list/doubly-linked-list.js +0 -2
- package/dist/mjs/src/types/data-structures/linked-list/index.js +0 -18
- package/dist/mjs/src/types/data-structures/linked-list/singly-linked-list.js +0 -2
- package/dist/mjs/src/types/data-structures/linked-list/skip-linked-list.js +0 -2
- package/dist/mjs/src/types/data-structures/matrix/index.js +0 -17
- package/dist/mjs/src/types/data-structures/matrix/matrix.js +0 -2
- package/dist/mjs/src/types/data-structures/matrix/matrix2d.js +0 -2
- package/dist/mjs/src/types/data-structures/matrix/navigator.js +0 -2
- package/dist/mjs/src/types/data-structures/matrix/vector2d.js +0 -2
- package/dist/mjs/src/types/data-structures/priority-queue/index.js +0 -19
- package/dist/mjs/src/types/data-structures/priority-queue/max-priority-queue.js +0 -2
- package/dist/mjs/src/types/data-structures/priority-queue/min-priority-queue.js +0 -2
- package/dist/mjs/src/types/data-structures/priority-queue/priority-queue.js +0 -2
- package/dist/mjs/src/types/data-structures/queue/deque.js +0 -2
- package/dist/mjs/src/types/data-structures/queue/index.js +0 -18
- package/dist/mjs/src/types/data-structures/queue/queue.js +0 -2
- package/dist/mjs/src/types/data-structures/stack/index.js +0 -17
- package/dist/mjs/src/types/data-structures/stack/stack.js +0 -2
- package/dist/mjs/src/types/data-structures/tree/index.js +0 -17
- package/dist/mjs/src/types/data-structures/tree/tree.js +0 -2
- package/dist/mjs/src/types/data-structures/trie/index.js +0 -17
- package/dist/mjs/src/types/data-structures/trie/trie.js +0 -2
- package/dist/mjs/src/types/helpers.js +0 -9
- package/dist/mjs/src/types/index.js +0 -19
- package/dist/mjs/src/types/utils/index.js +0 -18
- package/dist/mjs/src/types/utils/utils.js +0 -2
- package/dist/mjs/src/types/utils/validate-type.js +0 -2
- package/dist/mjs/src/utils/index.js +0 -17
- package/dist/mjs/src/utils/utils.js +0 -64
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/avl-tree.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/avl-tree.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/binary-indexed-tree.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/binary-indexed-tree.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/binary-tree.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/binary-tree.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/bst.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/bst.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/index.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/index.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/rb-tree.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/rb-tree.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/segment-tree.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/segment-tree.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/tree-multimap.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/binary-tree/tree-multimap.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/graph/abstract-graph.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/graph/abstract-graph.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/graph/directed-graph.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/graph/directed-graph.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/graph/index.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/graph/index.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/graph/map-graph.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/graph/map-graph.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/graph/undirected-graph.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/graph/undirected-graph.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/coordinate-map.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/coordinate-map.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/coordinate-set.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/coordinate-set.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/hash-map.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/hash-map.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/hash-table.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/hash-table.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/index.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/index.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/tree-map.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/tree-map.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/tree-set.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/hash/tree-set.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/heap/heap.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/heap/heap.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/heap/index.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/heap/index.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/heap/max-heap.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/heap/max-heap.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/heap/min-heap.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/heap/min-heap.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/index.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/index.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/linked-list/doubly-linked-list.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/linked-list/doubly-linked-list.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/linked-list/index.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/linked-list/index.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/linked-list/singly-linked-list.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/linked-list/singly-linked-list.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/linked-list/skip-linked-list.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/linked-list/skip-linked-list.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/matrix/index.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/matrix/index.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/matrix/matrix.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/matrix/matrix.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/matrix/matrix2d.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/matrix/matrix2d.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/matrix/navigator.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/matrix/navigator.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/matrix/vector2d.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/matrix/vector2d.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/priority-queue/index.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/priority-queue/index.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/priority-queue/max-priority-queue.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/priority-queue/max-priority-queue.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/priority-queue/min-priority-queue.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/priority-queue/min-priority-queue.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/priority-queue/priority-queue.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/priority-queue/priority-queue.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/queue/deque.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/queue/deque.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/queue/index.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/queue/index.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/queue/queue.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/queue/queue.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/stack/index.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/stack/index.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/stack/stack.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/stack/stack.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/tree/index.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/tree/index.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/tree/tree.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/tree/tree.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/trie/index.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/trie/index.js +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/trie/trie.d.ts +0 -0
- /package/dist/cjs/{src/data-structures → data-structures}/trie/trie.js +0 -0
- /package/dist/cjs/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/cjs/{src/index.js → index.js} +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/binary-tree.d.ts +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/binary-tree.js +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/doubly-linked-list.d.ts +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/doubly-linked-list.js +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/graph.d.ts +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/graph.js +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/heap.d.ts +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/heap.js +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/index.d.ts +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/index.js +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/navigator.d.ts +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/navigator.js +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/priority-queue.d.ts +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/priority-queue.js +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/segment-tree.d.ts +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/segment-tree.js +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/singly-linked-list.d.ts +0 -0
- /package/dist/cjs/{src/interfaces → interfaces}/singly-linked-list.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/avl-tree.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/avl-tree.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/binary-indexed-tree.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/binary-tree.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/binary-tree.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/bst.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/bst.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/index.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/rb-tree.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/rb-tree.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/segment-tree.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/segment-tree.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/tree-multimap.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/binary-tree/tree-multimap.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/graph/abstract-graph.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/graph/abstract-graph.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/graph/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/graph/index.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/graph/map-graph.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/graph/map-graph.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/graph/undirected-graph.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/graph/undirected-graph.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/coordinate-map.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/coordinate-map.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/coordinate-set.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/coordinate-set.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/hash-map.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/hash-map.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/hash-table.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/hash-table.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/index.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/tree-map.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/tree-map.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/tree-set.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/hash/tree-set.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/heap/heap.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/heap/heap.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/heap/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/heap/index.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/heap/max-heap.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/heap/max-heap.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/heap/min-heap.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/heap/min-heap.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/index.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/linked-list/doubly-linked-list.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/linked-list/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/linked-list/index.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/linked-list/singly-linked-list.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/linked-list/singly-linked-list.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/linked-list/skip-linked-list.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/linked-list/skip-linked-list.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/matrix/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/matrix/index.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/matrix/matrix.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/matrix/matrix.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/matrix/matrix2d.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/matrix/matrix2d.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/matrix/navigator.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/matrix/navigator.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/matrix/vector2d.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/matrix/vector2d.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/priority-queue/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/priority-queue/index.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/priority-queue/max-priority-queue.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/priority-queue/min-priority-queue.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/priority-queue/priority-queue.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/priority-queue/priority-queue.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/queue/deque.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/queue/deque.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/queue/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/queue/index.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/queue/queue.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/queue/queue.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/stack/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/stack/index.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/stack/stack.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/stack/stack.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/tree/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/tree/index.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/tree/tree.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/tree/tree.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/trie/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/trie/index.js +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/trie/trie.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/data-structures/trie/trie.js +0 -0
- /package/dist/cjs/{src/types → types}/helpers.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/helpers.js +0 -0
- /package/dist/cjs/{src/types → types}/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/index.js +0 -0
- /package/dist/cjs/{src/types → types}/utils/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/utils/index.js +0 -0
- /package/dist/cjs/{src/types → types}/utils/utils.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/utils/utils.js +0 -0
- /package/dist/cjs/{src/types → types}/utils/validate-type.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/utils/validate-type.js +0 -0
- /package/dist/cjs/{src/utils → utils}/index.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/index.js +0 -0
- /package/dist/cjs/{src/utils → utils}/utils.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/utils.js +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/binary-tree/avl-tree.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/binary-tree/binary-indexed-tree.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/binary-tree/binary-tree.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/binary-tree/bst.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/binary-tree/index.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/binary-tree/rb-tree.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/binary-tree/segment-tree.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/binary-tree/tree-multimap.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/graph/abstract-graph.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/graph/directed-graph.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/graph/index.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/graph/map-graph.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/graph/undirected-graph.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/hash/coordinate-map.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/hash/coordinate-set.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/hash/hash-map.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/hash/hash-table.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/hash/index.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/hash/tree-map.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/hash/tree-set.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/heap/heap.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/heap/index.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/heap/max-heap.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/heap/min-heap.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/index.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/linked-list/doubly-linked-list.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/linked-list/index.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/linked-list/singly-linked-list.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/linked-list/skip-linked-list.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/matrix/index.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/matrix/matrix.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/matrix/matrix2d.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/matrix/navigator.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/matrix/vector2d.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/priority-queue/index.d.ts +0 -0
- /package/dist/mjs/{src/types/data-structures/priority-queue/index.d.ts → data-structures/priority-queue/index.js} +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/priority-queue/max-priority-queue.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/priority-queue/min-priority-queue.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/priority-queue/priority-queue.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/queue/deque.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/queue/index.d.ts +0 -0
- /package/dist/mjs/{src/types/data-structures/queue/index.d.ts → data-structures/queue/index.js} +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/queue/queue.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/stack/index.d.ts +0 -0
- /package/dist/mjs/{src/types/data-structures/stack/index.d.ts → data-structures/stack/index.js} +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/stack/stack.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/tree/index.d.ts +0 -0
- /package/dist/mjs/{src/types/data-structures/tree/index.d.ts → data-structures/tree/index.js} +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/tree/tree.d.ts +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/trie/index.d.ts +0 -0
- /package/dist/mjs/{src/types/data-structures/trie/index.d.ts → data-structures/trie/index.js} +0 -0
- /package/dist/mjs/{src/data-structures → data-structures}/trie/trie.d.ts +0 -0
- /package/dist/mjs/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/mjs/{src/interfaces → interfaces}/binary-tree.d.ts +0 -0
- /package/dist/mjs/{src/interfaces/doubly-linked-list.d.ts → interfaces/binary-tree.js} +0 -0
- /package/dist/mjs/{src/types/data-structures/linked-list → interfaces}/doubly-linked-list.d.ts +0 -0
- /package/dist/mjs/{src/interfaces/heap.d.ts → interfaces/doubly-linked-list.js} +0 -0
- /package/dist/mjs/{src/interfaces → interfaces}/graph.d.ts +0 -0
- /package/dist/mjs/{src/interfaces/navigator.d.ts → interfaces/graph.js} +0 -0
- /package/dist/mjs/{src/types/data-structures/heap → interfaces}/heap.d.ts +0 -0
- /package/dist/mjs/{src/interfaces/priority-queue.d.ts → interfaces/heap.js} +0 -0
- /package/dist/mjs/{src/interfaces → interfaces}/index.d.ts +0 -0
- /package/dist/mjs/{src/interfaces/segment-tree.d.ts → interfaces/navigator.d.ts} +0 -0
- /package/dist/mjs/{src/interfaces/singly-linked-list.d.ts → interfaces/navigator.js} +0 -0
- /package/dist/mjs/{src/types/data-structures/priority-queue → interfaces}/priority-queue.d.ts +0 -0
- /package/dist/mjs/{src/types/data-structures/binary-tree/binary-indexed-tree.d.ts → interfaces/priority-queue.js} +0 -0
- /package/dist/mjs/{src/types/data-structures/graph/undirected-graph.d.ts → interfaces/segment-tree.d.ts} +0 -0
- /package/dist/mjs/{src/types/data-structures/hash/coordinate-map.d.ts → interfaces/segment-tree.js} +0 -0
- /package/dist/mjs/{src/types/data-structures/linked-list → interfaces}/singly-linked-list.d.ts +0 -0
- /package/dist/mjs/{src/types/data-structures/hash/coordinate-set.d.ts → interfaces/singly-linked-list.js} +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/binary-tree/avl-tree.d.ts +0 -0
- /package/dist/mjs/{src/types/data-structures/hash/hash-map.d.ts → types/data-structures/binary-tree/avl-tree.js} +0 -0
- /package/dist/mjs/{src/types/data-structures/hash/hash-table.d.ts → types/data-structures/binary-tree/binary-indexed-tree.d.ts} +0 -0
- /package/dist/mjs/{src/types/data-structures/hash/tree-map.d.ts → types/data-structures/binary-tree/binary-indexed-tree.js} +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/binary-tree/binary-tree.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/binary-tree/bst.d.ts +0 -0
- /package/dist/mjs/{src/types/data-structures/hash/tree-set.d.ts → types/data-structures/binary-tree/bst.js} +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/binary-tree/index.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/binary-tree/rb-tree.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/binary-tree/segment-tree.d.ts +0 -0
- /package/dist/mjs/{src/types/data-structures/heap/max-heap.d.ts → types/data-structures/binary-tree/segment-tree.js} +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/binary-tree/tree-multimap.d.ts +0 -0
- /package/dist/mjs/{src/types/data-structures/heap/min-heap.d.ts → types/data-structures/binary-tree/tree-multimap.js} +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/graph/abstract-graph.d.ts +0 -0
- /package/dist/mjs/{src/types/data-structures/linked-list/skip-linked-list.d.ts → types/data-structures/graph/abstract-graph.js} +0 -0
- /package/dist/mjs/{src/types/data-structures/matrix/matrix.d.ts → types/data-structures/graph/directed-graph.js} +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/graph/index.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/graph/map-graph.d.ts +0 -0
- /package/dist/mjs/{src/types/data-structures/matrix/matrix2d.d.ts → types/data-structures/graph/map-graph.js} +0 -0
- /package/dist/mjs/{src/types/data-structures/matrix/vector2d.d.ts → types/data-structures/graph/undirected-graph.d.ts} +0 -0
- /package/dist/mjs/{src/types/data-structures/priority-queue/max-priority-queue.d.ts → types/data-structures/graph/undirected-graph.js} +0 -0
- /package/dist/mjs/{src/types/data-structures/priority-queue/min-priority-queue.d.ts → types/data-structures/hash/coordinate-map.d.ts} +0 -0
- /package/dist/mjs/{src/types/data-structures/queue/deque.d.ts → types/data-structures/hash/coordinate-map.js} +0 -0
- /package/dist/mjs/{src/types/data-structures/queue/queue.d.ts → types/data-structures/hash/coordinate-set.d.ts} +0 -0
- /package/dist/mjs/{src/types/data-structures/stack/stack.d.ts → types/data-structures/hash/coordinate-set.js} +0 -0
- /package/dist/mjs/{src/types/data-structures/tree/tree.d.ts → types/data-structures/hash/hash-map.d.ts} +0 -0
- /package/dist/mjs/{src/types/data-structures/trie/trie.d.ts → types/data-structures/hash/hash-map.js} +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/hash/index.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/heap/index.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/index.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/linked-list/index.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/matrix/index.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/data-structures/matrix/navigator.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/helpers.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/index.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/utils/index.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/utils/utils.d.ts +0 -0
- /package/dist/mjs/{src/types → types}/utils/validate-type.d.ts +0 -0
- /package/dist/mjs/{src/utils → utils}/index.d.ts +0 -0
- /package/dist/mjs/{src/utils → utils}/utils.d.ts +0 -0
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const binary_tree_1 = require("./binary-tree");
|
|
6
|
-
const queue_1 = require("../queue");
|
|
7
|
-
class BSTNode extends binary_tree_1.BinaryTreeNode {
|
|
1
|
+
import { CP, IterationType } from '../../types';
|
|
2
|
+
import { BinaryTree, BinaryTreeNode } from './binary-tree';
|
|
3
|
+
import { Queue } from '../queue';
|
|
4
|
+
export class BSTNode extends BinaryTreeNode {
|
|
8
5
|
parent;
|
|
9
6
|
constructor(key, value) {
|
|
10
7
|
super(key, value);
|
|
@@ -47,8 +44,7 @@ class BSTNode extends binary_tree_1.BinaryTreeNode {
|
|
|
47
44
|
this._right = v;
|
|
48
45
|
}
|
|
49
46
|
}
|
|
50
|
-
|
|
51
|
-
class BST extends binary_tree_1.BinaryTree {
|
|
47
|
+
export class BST extends BinaryTree {
|
|
52
48
|
/**
|
|
53
49
|
* The constructor function initializes a binary search tree with an optional comparator function.
|
|
54
50
|
* @param {BSTOptions} [options] - An optional object that contains additional configuration options
|
|
@@ -123,7 +119,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
123
119
|
let traversing = true;
|
|
124
120
|
while (traversing) {
|
|
125
121
|
if (cur !== undefined && newNode !== undefined) {
|
|
126
|
-
if (this._compare(cur.key, newNode.key) ===
|
|
122
|
+
if (this._compare(cur.key, newNode.key) === CP.eq) {
|
|
127
123
|
if (newNode) {
|
|
128
124
|
cur.value = newNode.value;
|
|
129
125
|
}
|
|
@@ -131,7 +127,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
131
127
|
traversing = false;
|
|
132
128
|
inserted = cur;
|
|
133
129
|
}
|
|
134
|
-
else if (this._compare(cur.key, newNode.key) ===
|
|
130
|
+
else if (this._compare(cur.key, newNode.key) === CP.gt) {
|
|
135
131
|
// Traverse left of the node
|
|
136
132
|
if (cur.left === undefined) {
|
|
137
133
|
if (newNode) {
|
|
@@ -149,7 +145,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
149
145
|
cur = cur.left;
|
|
150
146
|
}
|
|
151
147
|
}
|
|
152
|
-
else if (this._compare(cur.key, newNode.key) ===
|
|
148
|
+
else if (this._compare(cur.key, newNode.key) === CP.lt) {
|
|
153
149
|
// Traverse right of the node
|
|
154
150
|
if (cur.right === undefined) {
|
|
155
151
|
if (newNode) {
|
|
@@ -260,7 +256,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
260
256
|
}
|
|
261
257
|
}
|
|
262
258
|
};
|
|
263
|
-
if (iterationType ===
|
|
259
|
+
if (iterationType === IterationType.RECURSIVE) {
|
|
264
260
|
_dfs(sortedKeysOrNodes, sortedData);
|
|
265
261
|
}
|
|
266
262
|
else {
|
|
@@ -288,9 +284,9 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
288
284
|
* rightmost node otherwise. If no node is found, it returns 0.
|
|
289
285
|
*/
|
|
290
286
|
lastKey(beginRoot = this.root, iterationType = this.iterationType) {
|
|
291
|
-
if (this._compare(0, 1) ===
|
|
287
|
+
if (this._compare(0, 1) === CP.lt)
|
|
292
288
|
return this.getRightMost(beginRoot, iterationType)?.key ?? 0;
|
|
293
|
-
else if (this._compare(0, 1) ===
|
|
289
|
+
else if (this._compare(0, 1) === CP.gt)
|
|
294
290
|
return this.getLeftMost(beginRoot, iterationType)?.key ?? 0;
|
|
295
291
|
else
|
|
296
292
|
return this.getRightMost(beginRoot, iterationType)?.key ?? 0;
|
|
@@ -313,32 +309,32 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
313
309
|
* @returns The function `getNodeByKey` returns a node (`N`) if a node with the specified key is
|
|
314
310
|
* found in the binary tree. If no node is found, it returns `undefined`.
|
|
315
311
|
*/
|
|
316
|
-
getNodeByKey(key, iterationType =
|
|
312
|
+
getNodeByKey(key, iterationType = IterationType.ITERATIVE) {
|
|
317
313
|
if (!this.root)
|
|
318
314
|
return undefined;
|
|
319
|
-
if (iterationType ===
|
|
315
|
+
if (iterationType === IterationType.RECURSIVE) {
|
|
320
316
|
const _dfs = (cur) => {
|
|
321
317
|
if (cur.key === key)
|
|
322
318
|
return cur;
|
|
323
319
|
if (!cur.left && !cur.right)
|
|
324
320
|
return;
|
|
325
|
-
if (this._compare(cur.key, key) ===
|
|
321
|
+
if (this._compare(cur.key, key) === CP.gt && cur.left)
|
|
326
322
|
return _dfs(cur.left);
|
|
327
|
-
if (this._compare(cur.key, key) ===
|
|
323
|
+
if (this._compare(cur.key, key) === CP.lt && cur.right)
|
|
328
324
|
return _dfs(cur.right);
|
|
329
325
|
};
|
|
330
326
|
return _dfs(this.root);
|
|
331
327
|
}
|
|
332
328
|
else {
|
|
333
|
-
const queue = new
|
|
329
|
+
const queue = new Queue([this.root]);
|
|
334
330
|
while (queue.size > 0) {
|
|
335
331
|
const cur = queue.shift();
|
|
336
332
|
if (cur) {
|
|
337
|
-
if (this._compare(cur.key, key) ===
|
|
333
|
+
if (this._compare(cur.key, key) === CP.eq)
|
|
338
334
|
return cur;
|
|
339
|
-
if (this._compare(cur.key, key) ===
|
|
335
|
+
if (this._compare(cur.key, key) === CP.gt)
|
|
340
336
|
cur.left && queue.push(cur.left);
|
|
341
|
-
if (this._compare(cur.key, key) ===
|
|
337
|
+
if (this._compare(cur.key, key) === CP.lt)
|
|
342
338
|
cur.right && queue.push(cur.right);
|
|
343
339
|
}
|
|
344
340
|
}
|
|
@@ -353,7 +349,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
353
349
|
* type of iteration to be performed. It has a default value of `IterationType.ITERATIVE`.
|
|
354
350
|
* @returns either a node object (N) or undefined.
|
|
355
351
|
*/
|
|
356
|
-
ensureNotKey(key, iterationType =
|
|
352
|
+
ensureNotKey(key, iterationType = IterationType.ITERATIVE) {
|
|
357
353
|
return this.isNodeKey(key) ? this.getNodeByKey(key, iterationType) : key;
|
|
358
354
|
}
|
|
359
355
|
/**
|
|
@@ -388,7 +384,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
388
384
|
if (!beginRoot)
|
|
389
385
|
return [];
|
|
390
386
|
const ans = [];
|
|
391
|
-
if (iterationType ===
|
|
387
|
+
if (iterationType === IterationType.RECURSIVE) {
|
|
392
388
|
const _traverse = (cur) => {
|
|
393
389
|
const callbackResult = callback(cur);
|
|
394
390
|
if (callbackResult === identifier) {
|
|
@@ -400,9 +396,9 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
400
396
|
return;
|
|
401
397
|
// TODO potential bug
|
|
402
398
|
if (callback === this._defaultOneParamCallback) {
|
|
403
|
-
if (this._compare(cur.key, identifier) ===
|
|
399
|
+
if (this._compare(cur.key, identifier) === CP.gt)
|
|
404
400
|
cur.left && _traverse(cur.left);
|
|
405
|
-
if (this._compare(cur.key, identifier) ===
|
|
401
|
+
if (this._compare(cur.key, identifier) === CP.lt)
|
|
406
402
|
cur.right && _traverse(cur.right);
|
|
407
403
|
}
|
|
408
404
|
else {
|
|
@@ -413,7 +409,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
413
409
|
_traverse(beginRoot);
|
|
414
410
|
}
|
|
415
411
|
else {
|
|
416
|
-
const queue = new
|
|
412
|
+
const queue = new Queue([beginRoot]);
|
|
417
413
|
while (queue.size > 0) {
|
|
418
414
|
const cur = queue.shift();
|
|
419
415
|
if (cur) {
|
|
@@ -425,9 +421,9 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
425
421
|
}
|
|
426
422
|
// TODO potential bug
|
|
427
423
|
if (callback === this._defaultOneParamCallback) {
|
|
428
|
-
if (this._compare(cur.key, identifier) ===
|
|
424
|
+
if (this._compare(cur.key, identifier) === CP.gt)
|
|
429
425
|
cur.left && queue.push(cur.left);
|
|
430
|
-
if (this._compare(cur.key, identifier) ===
|
|
426
|
+
if (this._compare(cur.key, identifier) === CP.lt)
|
|
431
427
|
cur.right && queue.push(cur.right);
|
|
432
428
|
}
|
|
433
429
|
else {
|
|
@@ -464,7 +460,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
464
460
|
* @returns The function `lesserOrGreaterTraverse` returns an array of values of type
|
|
465
461
|
* `ReturnType<C>`, which is the return type of the callback function passed as an argument.
|
|
466
462
|
*/
|
|
467
|
-
lesserOrGreaterTraverse(callback = this._defaultOneParamCallback, lesserOrGreater =
|
|
463
|
+
lesserOrGreaterTraverse(callback = this._defaultOneParamCallback, lesserOrGreater = CP.lt, targetNode = this.root, iterationType = this.iterationType) {
|
|
468
464
|
targetNode = this.ensureNotKey(targetNode);
|
|
469
465
|
const ans = [];
|
|
470
466
|
if (!targetNode)
|
|
@@ -472,7 +468,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
472
468
|
if (!this.root)
|
|
473
469
|
return ans;
|
|
474
470
|
const targetKey = targetNode.key;
|
|
475
|
-
if (iterationType ===
|
|
471
|
+
if (iterationType === IterationType.RECURSIVE) {
|
|
476
472
|
const _traverse = (cur) => {
|
|
477
473
|
const compared = this._compare(cur.key, targetKey);
|
|
478
474
|
if (compared === lesserOrGreater)
|
|
@@ -488,7 +484,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
488
484
|
return ans;
|
|
489
485
|
}
|
|
490
486
|
else {
|
|
491
|
-
const queue = new
|
|
487
|
+
const queue = new Queue([this.root]);
|
|
492
488
|
while (queue.size > 0) {
|
|
493
489
|
const cur = queue.shift();
|
|
494
490
|
if (cur) {
|
|
@@ -533,7 +529,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
533
529
|
this.clear();
|
|
534
530
|
if (sorted.length < 1)
|
|
535
531
|
return false;
|
|
536
|
-
if (iterationType ===
|
|
532
|
+
if (iterationType === IterationType.RECURSIVE) {
|
|
537
533
|
const buildBalanceBST = (l, r) => {
|
|
538
534
|
if (l > r)
|
|
539
535
|
return;
|
|
@@ -582,7 +578,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
582
578
|
if (!this.root)
|
|
583
579
|
return true;
|
|
584
580
|
let balanced = true;
|
|
585
|
-
if (iterationType ===
|
|
581
|
+
if (iterationType === IterationType.RECURSIVE) {
|
|
586
582
|
const _height = (cur) => {
|
|
587
583
|
if (!cur)
|
|
588
584
|
return 0;
|
|
@@ -641,11 +637,10 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
641
637
|
_compare(a, b) {
|
|
642
638
|
const compared = this._comparator(a, b);
|
|
643
639
|
if (compared > 0)
|
|
644
|
-
return
|
|
640
|
+
return CP.gt;
|
|
645
641
|
else if (compared < 0)
|
|
646
|
-
return
|
|
642
|
+
return CP.lt;
|
|
647
643
|
else
|
|
648
|
-
return
|
|
644
|
+
return CP.eq;
|
|
649
645
|
}
|
|
650
646
|
}
|
|
651
|
-
exports.BST = BST;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* data-structure-typed
|
|
4
3
|
*
|
|
@@ -6,19 +5,16 @@
|
|
|
6
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
7
6
|
* @license MIT License
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const binary_tree_1 = require("./binary-tree");
|
|
14
|
-
class RedBlackTreeNode extends bst_1.BSTNode {
|
|
8
|
+
import { RBTNColor } from '../../types';
|
|
9
|
+
import { BST, BSTNode } from './bst';
|
|
10
|
+
import { BinaryTreeNode } from './binary-tree';
|
|
11
|
+
export class RedBlackTreeNode extends BSTNode {
|
|
15
12
|
color;
|
|
16
|
-
constructor(key, value, color =
|
|
13
|
+
constructor(key, value, color = RBTNColor.BLACK) {
|
|
17
14
|
super(key, value);
|
|
18
15
|
this.color = color;
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
|
-
exports.RedBlackTreeNode = RedBlackTreeNode;
|
|
22
18
|
/**
|
|
23
19
|
* 1. Each node is either red or black.
|
|
24
20
|
* 2. The root node is always black.
|
|
@@ -26,7 +22,7 @@ exports.RedBlackTreeNode = RedBlackTreeNode;
|
|
|
26
22
|
* 4. Red nodes must have black children.
|
|
27
23
|
* 5. Black balance: Every path from any node to each of its leaf nodes contains the same number of black nodes.
|
|
28
24
|
*/
|
|
29
|
-
class RedBlackTree extends
|
|
25
|
+
export class RedBlackTree extends BST {
|
|
30
26
|
NIL = new RedBlackTreeNode(NaN);
|
|
31
27
|
/**
|
|
32
28
|
* The constructor function initializes a Red-Black Tree with an optional set of options.
|
|
@@ -63,7 +59,7 @@ class RedBlackTree extends bst_1.BST {
|
|
|
63
59
|
add(keyOrNode, value) {
|
|
64
60
|
let node;
|
|
65
61
|
if (this.isNodeKey(keyOrNode)) {
|
|
66
|
-
node = this.createNode(keyOrNode, value,
|
|
62
|
+
node = this.createNode(keyOrNode, value, RBTNColor.RED);
|
|
67
63
|
}
|
|
68
64
|
else if (keyOrNode instanceof RedBlackTreeNode) {
|
|
69
65
|
node = keyOrNode;
|
|
@@ -101,7 +97,7 @@ class RedBlackTree extends bst_1.BST {
|
|
|
101
97
|
y.right = node;
|
|
102
98
|
}
|
|
103
99
|
if (node.parent === undefined) {
|
|
104
|
-
node.color =
|
|
100
|
+
node.color = RBTNColor.BLACK;
|
|
105
101
|
this._size++;
|
|
106
102
|
return;
|
|
107
103
|
}
|
|
@@ -112,7 +108,7 @@ class RedBlackTree extends bst_1.BST {
|
|
|
112
108
|
this._fixInsert(node);
|
|
113
109
|
this._size++;
|
|
114
110
|
}
|
|
115
|
-
createNode(key, value, color =
|
|
111
|
+
createNode(key, value, color = RBTNColor.BLACK) {
|
|
116
112
|
return new RedBlackTreeNode(key, value, color);
|
|
117
113
|
}
|
|
118
114
|
/**
|
|
@@ -183,7 +179,7 @@ class RedBlackTree extends bst_1.BST {
|
|
|
183
179
|
y.left.parent = y;
|
|
184
180
|
y.color = z.color;
|
|
185
181
|
}
|
|
186
|
-
if (yOriginalColor ===
|
|
182
|
+
if (yOriginalColor === RBTNColor.BLACK) {
|
|
187
183
|
this._fixDelete(x);
|
|
188
184
|
}
|
|
189
185
|
this._size--;
|
|
@@ -221,7 +217,7 @@ class RedBlackTree extends bst_1.BST {
|
|
|
221
217
|
* @returns a value of type `N`, `null`, or `undefined`.
|
|
222
218
|
*/
|
|
223
219
|
getNode(identifier, callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType) {
|
|
224
|
-
if (identifier instanceof
|
|
220
|
+
if (identifier instanceof BinaryTreeNode)
|
|
225
221
|
callback = (node => node);
|
|
226
222
|
beginRoot = this.ensureNotKey(beginRoot);
|
|
227
223
|
return this.getNodes(identifier, callback, true, beginRoot, iterationType)[0] ?? undefined;
|
|
@@ -363,32 +359,32 @@ class RedBlackTree extends bst_1.BST {
|
|
|
363
359
|
*/
|
|
364
360
|
_fixDelete(x) {
|
|
365
361
|
let s;
|
|
366
|
-
while (x !== this.root && x.color ===
|
|
362
|
+
while (x !== this.root && x.color === RBTNColor.BLACK) {
|
|
367
363
|
if (x.parent && x === x.parent.left) {
|
|
368
364
|
s = x.parent.right;
|
|
369
365
|
if (s.color === 1) {
|
|
370
|
-
s.color =
|
|
371
|
-
x.parent.color =
|
|
366
|
+
s.color = RBTNColor.BLACK;
|
|
367
|
+
x.parent.color = RBTNColor.RED;
|
|
372
368
|
this._leftRotate(x.parent);
|
|
373
369
|
s = x.parent.right;
|
|
374
370
|
}
|
|
375
|
-
if (s.left !== undefined && s.left.color ===
|
|
376
|
-
s.color =
|
|
371
|
+
if (s.left !== undefined && s.left.color === RBTNColor.BLACK && s.right && s.right.color === RBTNColor.BLACK) {
|
|
372
|
+
s.color = RBTNColor.RED;
|
|
377
373
|
x = x.parent;
|
|
378
374
|
}
|
|
379
375
|
else {
|
|
380
|
-
if (s.right && s.right.color ===
|
|
376
|
+
if (s.right && s.right.color === RBTNColor.BLACK) {
|
|
381
377
|
if (s.left)
|
|
382
|
-
s.left.color =
|
|
383
|
-
s.color =
|
|
378
|
+
s.left.color = RBTNColor.BLACK;
|
|
379
|
+
s.color = RBTNColor.RED;
|
|
384
380
|
this._rightRotate(s);
|
|
385
381
|
s = x.parent.right;
|
|
386
382
|
}
|
|
387
383
|
if (s)
|
|
388
384
|
s.color = x.parent.color;
|
|
389
|
-
x.parent.color =
|
|
385
|
+
x.parent.color = RBTNColor.BLACK;
|
|
390
386
|
if (s && s.right)
|
|
391
|
-
s.right.color =
|
|
387
|
+
s.right.color = RBTNColor.BLACK;
|
|
392
388
|
this._leftRotate(x.parent);
|
|
393
389
|
x = this.root;
|
|
394
390
|
}
|
|
@@ -396,34 +392,34 @@ class RedBlackTree extends bst_1.BST {
|
|
|
396
392
|
else {
|
|
397
393
|
s = x.parent.left;
|
|
398
394
|
if (s.color === 1) {
|
|
399
|
-
s.color =
|
|
400
|
-
x.parent.color =
|
|
395
|
+
s.color = RBTNColor.BLACK;
|
|
396
|
+
x.parent.color = RBTNColor.RED;
|
|
401
397
|
this._rightRotate(x.parent);
|
|
402
398
|
s = x.parent.left;
|
|
403
399
|
}
|
|
404
|
-
if (s && s.right && s.right.color ===
|
|
405
|
-
s.color =
|
|
400
|
+
if (s && s.right && s.right.color === RBTNColor.BLACK && s.right.color === RBTNColor.BLACK) {
|
|
401
|
+
s.color = RBTNColor.RED;
|
|
406
402
|
x = x.parent;
|
|
407
403
|
}
|
|
408
404
|
else {
|
|
409
|
-
if (s && s.left && s.left.color ===
|
|
405
|
+
if (s && s.left && s.left.color === RBTNColor.BLACK) {
|
|
410
406
|
if (s.right)
|
|
411
|
-
s.right.color =
|
|
412
|
-
s.color =
|
|
407
|
+
s.right.color = RBTNColor.BLACK;
|
|
408
|
+
s.color = RBTNColor.RED;
|
|
413
409
|
this._leftRotate(s);
|
|
414
410
|
s = x.parent.left;
|
|
415
411
|
}
|
|
416
412
|
if (s)
|
|
417
413
|
s.color = x.parent.color;
|
|
418
|
-
x.parent.color =
|
|
414
|
+
x.parent.color = RBTNColor.BLACK;
|
|
419
415
|
if (s && s.left)
|
|
420
|
-
s.left.color =
|
|
416
|
+
s.left.color = RBTNColor.BLACK;
|
|
421
417
|
this._rightRotate(x.parent);
|
|
422
418
|
x = this.root;
|
|
423
419
|
}
|
|
424
420
|
}
|
|
425
421
|
}
|
|
426
|
-
x.color =
|
|
422
|
+
x.color = RBTNColor.BLACK;
|
|
427
423
|
}
|
|
428
424
|
/**
|
|
429
425
|
* Time Complexity: O(1)
|
|
@@ -467,9 +463,9 @@ class RedBlackTree extends bst_1.BST {
|
|
|
467
463
|
if (k.parent.parent && k.parent === k.parent.parent.right) {
|
|
468
464
|
u = k.parent.parent.left;
|
|
469
465
|
if (u && u.color === 1) {
|
|
470
|
-
u.color =
|
|
471
|
-
k.parent.color =
|
|
472
|
-
k.parent.parent.color =
|
|
466
|
+
u.color = RBTNColor.BLACK;
|
|
467
|
+
k.parent.color = RBTNColor.BLACK;
|
|
468
|
+
k.parent.parent.color = RBTNColor.RED;
|
|
473
469
|
k = k.parent.parent;
|
|
474
470
|
}
|
|
475
471
|
else {
|
|
@@ -477,17 +473,17 @@ class RedBlackTree extends bst_1.BST {
|
|
|
477
473
|
k = k.parent;
|
|
478
474
|
this._rightRotate(k);
|
|
479
475
|
}
|
|
480
|
-
k.parent.color =
|
|
481
|
-
k.parent.parent.color =
|
|
476
|
+
k.parent.color = RBTNColor.BLACK;
|
|
477
|
+
k.parent.parent.color = RBTNColor.RED;
|
|
482
478
|
this._leftRotate(k.parent.parent);
|
|
483
479
|
}
|
|
484
480
|
}
|
|
485
481
|
else {
|
|
486
482
|
u = k.parent.parent.right;
|
|
487
483
|
if (u && u.color === 1) {
|
|
488
|
-
u.color =
|
|
489
|
-
k.parent.color =
|
|
490
|
-
k.parent.parent.color =
|
|
484
|
+
u.color = RBTNColor.BLACK;
|
|
485
|
+
k.parent.color = RBTNColor.BLACK;
|
|
486
|
+
k.parent.parent.color = RBTNColor.RED;
|
|
491
487
|
k = k.parent.parent;
|
|
492
488
|
}
|
|
493
489
|
else {
|
|
@@ -495,8 +491,8 @@ class RedBlackTree extends bst_1.BST {
|
|
|
495
491
|
k = k.parent;
|
|
496
492
|
this._leftRotate(k);
|
|
497
493
|
}
|
|
498
|
-
k.parent.color =
|
|
499
|
-
k.parent.parent.color =
|
|
494
|
+
k.parent.color = RBTNColor.BLACK;
|
|
495
|
+
k.parent.parent.color = RBTNColor.RED;
|
|
500
496
|
this._rightRotate(k.parent.parent);
|
|
501
497
|
}
|
|
502
498
|
}
|
|
@@ -504,7 +500,6 @@ class RedBlackTree extends bst_1.BST {
|
|
|
504
500
|
break;
|
|
505
501
|
}
|
|
506
502
|
}
|
|
507
|
-
this.root.color =
|
|
503
|
+
this.root.color = RBTNColor.BLACK;
|
|
508
504
|
}
|
|
509
505
|
}
|
|
510
|
-
exports.RedBlackTree = RedBlackTree;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* data-structure-typed
|
|
4
3
|
*
|
|
@@ -6,9 +5,7 @@
|
|
|
6
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
7
6
|
* @license MIT License
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
exports.SegmentTree = exports.SegmentTreeNode = void 0;
|
|
11
|
-
class SegmentTreeNode {
|
|
8
|
+
export class SegmentTreeNode {
|
|
12
9
|
start = 0;
|
|
13
10
|
end = 0;
|
|
14
11
|
value = null;
|
|
@@ -22,8 +19,7 @@ class SegmentTreeNode {
|
|
|
22
19
|
this.value = value || null;
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
|
|
26
|
-
class SegmentTree {
|
|
22
|
+
export class SegmentTree {
|
|
27
23
|
/**
|
|
28
24
|
* The constructor initializes the values, start, end, and root properties of an object.
|
|
29
25
|
* @param {number[]} values - An array of numbers that will be used to build a binary search tree.
|
|
@@ -179,4 +175,3 @@ class SegmentTree {
|
|
|
179
175
|
return dfs(root, indexA, indexB);
|
|
180
176
|
}
|
|
181
177
|
}
|
|
182
|
-
exports.SegmentTree = SegmentTree;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const types_1 = require("../../types");
|
|
5
|
-
const avl_tree_1 = require("./avl-tree");
|
|
6
|
-
class TreeMultimapNode extends avl_tree_1.AVLTreeNode {
|
|
1
|
+
import { CP, FamilyPosition, IterationType } from '../../types';
|
|
2
|
+
import { AVLTree, AVLTreeNode } from './avl-tree';
|
|
3
|
+
export class TreeMultimapNode extends AVLTreeNode {
|
|
7
4
|
count;
|
|
8
5
|
/**
|
|
9
6
|
* The constructor function initializes a BinaryTreeNode object with a key, value, and count.
|
|
@@ -20,11 +17,10 @@ class TreeMultimapNode extends avl_tree_1.AVLTreeNode {
|
|
|
20
17
|
this.count = count;
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
|
-
exports.TreeMultimapNode = TreeMultimapNode;
|
|
24
20
|
/**
|
|
25
21
|
* The only distinction between a TreeMultimap and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
|
|
26
22
|
*/
|
|
27
|
-
class TreeMultimap extends
|
|
23
|
+
export class TreeMultimap extends AVLTree {
|
|
28
24
|
/**
|
|
29
25
|
* The constructor function for a TreeMultimap class in TypeScript, which extends another class and sets an option to
|
|
30
26
|
* merge duplicated values.
|
|
@@ -94,14 +90,14 @@ class TreeMultimap extends avl_tree_1.AVLTree {
|
|
|
94
90
|
while (traversing) {
|
|
95
91
|
if (cur) {
|
|
96
92
|
if (newNode) {
|
|
97
|
-
if (this._compare(cur.key, newNode.key) ===
|
|
93
|
+
if (this._compare(cur.key, newNode.key) === CP.eq) {
|
|
98
94
|
cur.value = newNode.value;
|
|
99
95
|
cur.count += newNode.count;
|
|
100
96
|
this._count += newNode.count;
|
|
101
97
|
traversing = false;
|
|
102
98
|
inserted = cur;
|
|
103
99
|
}
|
|
104
|
-
else if (this._compare(cur.key, newNode.key) ===
|
|
100
|
+
else if (this._compare(cur.key, newNode.key) === CP.gt) {
|
|
105
101
|
// Traverse left of the node
|
|
106
102
|
if (cur.left === undefined) {
|
|
107
103
|
//Add to the left of the current node
|
|
@@ -117,7 +113,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
|
|
|
117
113
|
cur = cur.left;
|
|
118
114
|
}
|
|
119
115
|
}
|
|
120
|
-
else if (this._compare(cur.key, newNode.key) ===
|
|
116
|
+
else if (this._compare(cur.key, newNode.key) === CP.lt) {
|
|
121
117
|
// Traverse right of the node
|
|
122
118
|
if (cur.right === undefined) {
|
|
123
119
|
//Add to the right of the current node
|
|
@@ -200,7 +196,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
|
|
|
200
196
|
if (sorted.length < 1)
|
|
201
197
|
return false;
|
|
202
198
|
this.clear();
|
|
203
|
-
if (iterationType ===
|
|
199
|
+
if (iterationType === IterationType.RECURSIVE) {
|
|
204
200
|
const buildBalanceBST = (l, r) => {
|
|
205
201
|
if (l > r)
|
|
206
202
|
return;
|
|
@@ -275,10 +271,10 @@ class TreeMultimap extends avl_tree_1.AVLTree {
|
|
|
275
271
|
}
|
|
276
272
|
else {
|
|
277
273
|
const { familyPosition: fp } = curr;
|
|
278
|
-
if (fp ===
|
|
274
|
+
if (fp === FamilyPosition.LEFT || fp === FamilyPosition.ROOT_LEFT) {
|
|
279
275
|
parent.left = curr.right;
|
|
280
276
|
}
|
|
281
|
-
else if (fp ===
|
|
277
|
+
else if (fp === FamilyPosition.RIGHT || fp === FamilyPosition.ROOT_RIGHT) {
|
|
282
278
|
parent.right = curr.right;
|
|
283
279
|
}
|
|
284
280
|
needBalanced = parent;
|
|
@@ -395,4 +391,3 @@ class TreeMultimap extends avl_tree_1.AVLTree {
|
|
|
395
391
|
return undefined;
|
|
396
392
|
}
|
|
397
393
|
}
|
|
398
|
-
exports.TreeMultimap = TreeMultimap;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractGraph = exports.AbstractEdge = exports.AbstractVertex = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* data-structure-typed
|
|
6
3
|
*
|
|
@@ -8,10 +5,10 @@ exports.AbstractGraph = exports.AbstractEdge = exports.AbstractVertex = void 0;
|
|
|
8
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
9
6
|
* @license MIT License
|
|
10
7
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class AbstractVertex {
|
|
8
|
+
import { uuidV4 } from '../../utils';
|
|
9
|
+
import { PriorityQueue } from '../priority-queue';
|
|
10
|
+
import { Queue } from '../queue';
|
|
11
|
+
export class AbstractVertex {
|
|
15
12
|
key;
|
|
16
13
|
value;
|
|
17
14
|
/**
|
|
@@ -26,8 +23,7 @@ class AbstractVertex {
|
|
|
26
23
|
this.value = value;
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
|
-
|
|
30
|
-
class AbstractEdge {
|
|
26
|
+
export class AbstractEdge {
|
|
31
27
|
value;
|
|
32
28
|
weight;
|
|
33
29
|
/**
|
|
@@ -42,15 +38,14 @@ class AbstractEdge {
|
|
|
42
38
|
constructor(weight, value) {
|
|
43
39
|
this.weight = weight !== undefined ? weight : 1;
|
|
44
40
|
this.value = value;
|
|
45
|
-
this._hashCode =
|
|
41
|
+
this._hashCode = uuidV4();
|
|
46
42
|
}
|
|
47
43
|
_hashCode;
|
|
48
44
|
get hashCode() {
|
|
49
45
|
return this._hashCode;
|
|
50
46
|
}
|
|
51
47
|
}
|
|
52
|
-
|
|
53
|
-
class AbstractGraph {
|
|
48
|
+
export class AbstractGraph {
|
|
54
49
|
_vertices = new Map();
|
|
55
50
|
get vertices() {
|
|
56
51
|
return this._vertices;
|
|
@@ -310,7 +305,7 @@ class AbstractGraph {
|
|
|
310
305
|
return null;
|
|
311
306
|
}
|
|
312
307
|
const visited = new Map();
|
|
313
|
-
const queue = new
|
|
308
|
+
const queue = new Queue([vertex1]);
|
|
314
309
|
visited.set(vertex1, true);
|
|
315
310
|
let cost = 0;
|
|
316
311
|
while (queue.size > 0) {
|
|
@@ -594,7 +589,7 @@ class AbstractGraph {
|
|
|
594
589
|
if (vertexOrKey instanceof AbstractVertex)
|
|
595
590
|
distMap.set(vertexOrKey, Infinity);
|
|
596
591
|
}
|
|
597
|
-
const heap = new
|
|
592
|
+
const heap = new PriorityQueue({ comparator: (a, b) => a.key - b.key });
|
|
598
593
|
heap.add({ key: 0, value: srcVertex });
|
|
599
594
|
distMap.set(srcVertex, 0);
|
|
600
595
|
preMap.set(srcVertex, null);
|
|
@@ -1042,4 +1037,3 @@ class AbstractGraph {
|
|
|
1042
1037
|
return vertexOrKey instanceof AbstractVertex ? vertexOrKey.key : vertexOrKey;
|
|
1043
1038
|
}
|
|
1044
1039
|
}
|
|
1045
|
-
exports.AbstractGraph = AbstractGraph;
|