data-structure-typed 1.41.5 → 1.41.6
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 -535
- package/benchmark/report.html +14 -12
- package/benchmark/report.json +117 -117
- package/dist/cjs/{data-structures → src/data-structures}/binary-tree/avl-tree.d.ts +1 -1
- package/dist/cjs/{data-structures → src/data-structures}/binary-tree/avl-tree.js +2 -2
- package/dist/cjs/src/data-structures/binary-tree/avl-tree.js.map +1 -0
- package/dist/cjs/src/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
- package/dist/cjs/{data-structures → src/data-structures}/binary-tree/binary-tree.d.ts +4 -3
- package/dist/cjs/{data-structures → src/data-structures}/binary-tree/binary-tree.js +19 -18
- package/dist/cjs/src/data-structures/binary-tree/binary-tree.js.map +1 -0
- package/dist/{mjs → cjs/src}/data-structures/binary-tree/bst.d.ts +1 -20
- package/dist/cjs/{data-structures → src/data-structures}/binary-tree/bst.js +5 -27
- package/dist/cjs/src/data-structures/binary-tree/bst.js.map +1 -0
- package/dist/cjs/src/data-structures/binary-tree/index.js.map +1 -0
- package/dist/cjs/src/data-structures/binary-tree/rb-tree.js.map +1 -0
- package/dist/cjs/src/data-structures/binary-tree/segment-tree.js.map +1 -0
- package/dist/{mjs → cjs/src}/data-structures/binary-tree/tree-multiset.d.ts +1 -1
- package/dist/cjs/{data-structures → src/data-structures}/binary-tree/tree-multiset.js +2 -2
- package/dist/cjs/src/data-structures/binary-tree/tree-multiset.js.map +1 -0
- package/dist/cjs/src/data-structures/graph/abstract-graph.js.map +1 -0
- package/dist/cjs/src/data-structures/graph/directed-graph.js.map +1 -0
- package/dist/cjs/src/data-structures/graph/index.js.map +1 -0
- package/dist/cjs/src/data-structures/graph/map-graph.js.map +1 -0
- package/dist/cjs/src/data-structures/graph/undirected-graph.js.map +1 -0
- package/dist/cjs/src/data-structures/hash/coordinate-map.js.map +1 -0
- package/dist/cjs/src/data-structures/hash/coordinate-set.js.map +1 -0
- package/dist/cjs/src/data-structures/hash/hash-map.js.map +1 -0
- package/dist/cjs/src/data-structures/hash/hash-table.js.map +1 -0
- package/dist/cjs/src/data-structures/hash/index.js.map +1 -0
- package/dist/cjs/src/data-structures/hash/tree-map.js.map +1 -0
- package/dist/cjs/src/data-structures/hash/tree-set.js.map +1 -0
- package/dist/cjs/src/data-structures/heap/heap.js.map +1 -0
- package/dist/cjs/src/data-structures/heap/index.js.map +1 -0
- package/dist/cjs/src/data-structures/heap/max-heap.js.map +1 -0
- package/dist/cjs/src/data-structures/heap/min-heap.js.map +1 -0
- package/dist/cjs/src/data-structures/index.js.map +1 -0
- package/dist/cjs/src/data-structures/linked-list/doubly-linked-list.js.map +1 -0
- package/dist/cjs/src/data-structures/linked-list/index.js.map +1 -0
- package/dist/cjs/src/data-structures/linked-list/singly-linked-list.js.map +1 -0
- package/dist/cjs/src/data-structures/linked-list/skip-linked-list.js.map +1 -0
- package/dist/cjs/src/data-structures/matrix/index.js.map +1 -0
- package/dist/cjs/src/data-structures/matrix/matrix.js.map +1 -0
- package/dist/cjs/src/data-structures/matrix/matrix2d.js.map +1 -0
- package/dist/cjs/src/data-structures/matrix/navigator.js.map +1 -0
- package/dist/cjs/src/data-structures/matrix/vector2d.js.map +1 -0
- package/dist/cjs/src/data-structures/priority-queue/index.js.map +1 -0
- package/dist/cjs/src/data-structures/priority-queue/max-priority-queue.js.map +1 -0
- package/dist/cjs/src/data-structures/priority-queue/min-priority-queue.js.map +1 -0
- package/dist/cjs/src/data-structures/priority-queue/priority-queue.js.map +1 -0
- package/dist/cjs/src/data-structures/queue/deque.js.map +1 -0
- package/dist/cjs/src/data-structures/queue/index.js.map +1 -0
- package/dist/cjs/src/data-structures/queue/queue.js.map +1 -0
- package/dist/cjs/src/data-structures/stack/index.js.map +1 -0
- package/dist/cjs/src/data-structures/stack/stack.js.map +1 -0
- package/dist/cjs/src/data-structures/tree/index.js.map +1 -0
- package/dist/cjs/src/data-structures/tree/tree.js.map +1 -0
- package/dist/cjs/src/data-structures/trie/index.js.map +1 -0
- package/dist/cjs/src/data-structures/trie/trie.js.map +1 -0
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/cjs/src/interfaces/binary-tree.js.map +1 -0
- package/dist/cjs/src/interfaces/doubly-linked-list.js.map +1 -0
- package/dist/cjs/{interfaces → src/interfaces}/graph.js.map +1 -1
- package/dist/cjs/{interfaces → src/interfaces}/heap.js.map +1 -1
- package/dist/cjs/src/interfaces/index.js.map +1 -0
- package/dist/cjs/src/interfaces/navigator.js.map +1 -0
- package/dist/cjs/src/interfaces/priority-queue.js.map +1 -0
- package/dist/cjs/src/interfaces/segment-tree.js.map +1 -0
- package/dist/cjs/src/interfaces/singly-linked-list.js.map +1 -0
- package/dist/cjs/src/types/data-structures/binary-tree/avl-tree.js.map +1 -0
- package/dist/cjs/src/types/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
- package/dist/cjs/src/types/data-structures/binary-tree/binary-tree.js.map +1 -0
- package/dist/cjs/src/types/data-structures/binary-tree/bst.js.map +1 -0
- package/dist/cjs/src/types/data-structures/binary-tree/index.js.map +1 -0
- package/dist/cjs/src/types/data-structures/binary-tree/rb-tree.js.map +1 -0
- package/dist/cjs/src/types/data-structures/binary-tree/segment-tree.js.map +1 -0
- package/dist/cjs/src/types/data-structures/binary-tree/tree-multiset.js.map +1 -0
- package/dist/cjs/src/types/data-structures/graph/abstract-graph.js.map +1 -0
- package/dist/cjs/src/types/data-structures/graph/directed-graph.js.map +1 -0
- package/dist/cjs/src/types/data-structures/graph/index.js.map +1 -0
- package/dist/cjs/src/types/data-structures/graph/map-graph.js.map +1 -0
- package/dist/cjs/src/types/data-structures/graph/undirected-graph.js.map +1 -0
- package/dist/cjs/src/types/data-structures/hash/coordinate-map.js.map +1 -0
- package/dist/cjs/src/types/data-structures/hash/coordinate-set.js.map +1 -0
- package/dist/cjs/src/types/data-structures/hash/hash-map.js.map +1 -0
- package/dist/cjs/src/types/data-structures/hash/hash-table.js.map +1 -0
- package/dist/cjs/src/types/data-structures/hash/index.js.map +1 -0
- package/dist/cjs/src/types/data-structures/hash/tree-map.js.map +1 -0
- package/dist/cjs/src/types/data-structures/hash/tree-set.js.map +1 -0
- package/dist/cjs/src/types/data-structures/heap/heap.js.map +1 -0
- package/dist/cjs/src/types/data-structures/heap/index.js.map +1 -0
- package/dist/cjs/src/types/data-structures/heap/max-heap.js.map +1 -0
- package/dist/cjs/src/types/data-structures/heap/min-heap.js.map +1 -0
- package/dist/cjs/src/types/data-structures/index.js.map +1 -0
- package/dist/cjs/src/types/data-structures/linked-list/doubly-linked-list.js.map +1 -0
- package/dist/cjs/src/types/data-structures/linked-list/index.js.map +1 -0
- package/dist/cjs/src/types/data-structures/linked-list/singly-linked-list.js.map +1 -0
- package/dist/cjs/src/types/data-structures/linked-list/skip-linked-list.js.map +1 -0
- package/dist/cjs/src/types/data-structures/matrix/index.js.map +1 -0
- package/dist/cjs/src/types/data-structures/matrix/matrix.js.map +1 -0
- package/dist/cjs/src/types/data-structures/matrix/matrix2d.js.map +1 -0
- package/dist/cjs/src/types/data-structures/matrix/navigator.js.map +1 -0
- package/dist/cjs/src/types/data-structures/matrix/vector2d.js.map +1 -0
- package/dist/cjs/src/types/data-structures/priority-queue/index.js.map +1 -0
- package/dist/cjs/src/types/data-structures/priority-queue/max-priority-queue.js.map +1 -0
- package/dist/cjs/src/types/data-structures/priority-queue/min-priority-queue.js.map +1 -0
- package/dist/cjs/src/types/data-structures/priority-queue/priority-queue.js.map +1 -0
- package/dist/cjs/src/types/data-structures/queue/deque.js.map +1 -0
- package/dist/cjs/src/types/data-structures/queue/index.js.map +1 -0
- package/dist/cjs/src/types/data-structures/queue/queue.js.map +1 -0
- package/dist/cjs/src/types/data-structures/stack/index.js.map +1 -0
- package/dist/cjs/src/types/data-structures/stack/stack.js.map +1 -0
- package/dist/cjs/src/types/data-structures/tree/index.js.map +1 -0
- package/dist/cjs/src/types/data-structures/tree/tree.js.map +1 -0
- package/dist/cjs/src/types/data-structures/trie/index.js.map +1 -0
- package/dist/cjs/src/types/data-structures/trie/trie.js.map +1 -0
- package/dist/cjs/src/types/helpers.js.map +1 -0
- package/dist/cjs/src/types/index.js.map +1 -0
- package/dist/cjs/src/types/utils/index.js.map +1 -0
- package/dist/cjs/{types → src/types}/utils/utils.js.map +1 -1
- package/dist/cjs/src/types/utils/validate-type.js.map +1 -0
- package/dist/cjs/src/utils/index.js.map +1 -0
- package/dist/cjs/src/utils/utils.js.map +1 -0
- package/dist/mjs/{data-structures → src/data-structures}/binary-tree/avl-tree.d.ts +1 -1
- package/dist/mjs/{data-structures → src/data-structures}/binary-tree/avl-tree.js +2 -2
- package/dist/mjs/{data-structures → src/data-structures}/binary-tree/binary-tree.d.ts +4 -3
- package/dist/mjs/{data-structures → src/data-structures}/binary-tree/binary-tree.js +19 -18
- package/dist/{cjs → mjs/src}/data-structures/binary-tree/bst.d.ts +1 -20
- package/dist/mjs/{data-structures → src/data-structures}/binary-tree/bst.js +5 -26
- package/dist/{cjs → mjs/src}/data-structures/binary-tree/tree-multiset.d.ts +1 -1
- package/dist/mjs/{data-structures → src/data-structures}/binary-tree/tree-multiset.js +2 -2
- package/dist/umd/data-structure-typed.min.js +1 -1
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +8 -8
- package/src/data-structures/binary-tree/avl-tree.ts +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +20 -18
- package/src/data-structures/binary-tree/bst.ts +6 -33
- package/src/data-structures/binary-tree/tree-multiset.ts +2 -2
- package/tsconfig-base.json +20 -24
- package/tsconfig-cjs.json +5 -1
- package/tsconfig-mjs.json +12 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/bst.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/index.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/tree-multiset.js.map +0 -1
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +0 -1
- package/dist/cjs/data-structures/graph/directed-graph.js.map +0 -1
- package/dist/cjs/data-structures/graph/index.js.map +0 -1
- package/dist/cjs/data-structures/graph/map-graph.js.map +0 -1
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +0 -1
- package/dist/cjs/data-structures/hash/coordinate-map.js.map +0 -1
- package/dist/cjs/data-structures/hash/coordinate-set.js.map +0 -1
- package/dist/cjs/data-structures/hash/hash-map.js.map +0 -1
- package/dist/cjs/data-structures/hash/hash-table.js.map +0 -1
- package/dist/cjs/data-structures/hash/index.js.map +0 -1
- package/dist/cjs/data-structures/hash/tree-map.js.map +0 -1
- package/dist/cjs/data-structures/hash/tree-set.js.map +0 -1
- package/dist/cjs/data-structures/heap/heap.js.map +0 -1
- package/dist/cjs/data-structures/heap/index.js.map +0 -1
- package/dist/cjs/data-structures/heap/max-heap.js.map +0 -1
- package/dist/cjs/data-structures/heap/min-heap.js.map +0 -1
- package/dist/cjs/data-structures/index.js.map +0 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +0 -1
- package/dist/cjs/data-structures/linked-list/index.js.map +0 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +0 -1
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +0 -1
- package/dist/cjs/data-structures/matrix/index.js.map +0 -1
- package/dist/cjs/data-structures/matrix/matrix.js.map +0 -1
- package/dist/cjs/data-structures/matrix/matrix2d.js.map +0 -1
- package/dist/cjs/data-structures/matrix/navigator.js.map +0 -1
- package/dist/cjs/data-structures/matrix/vector2d.js.map +0 -1
- package/dist/cjs/data-structures/priority-queue/index.js.map +0 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +0 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +0 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +0 -1
- package/dist/cjs/data-structures/queue/deque.js.map +0 -1
- package/dist/cjs/data-structures/queue/index.js.map +0 -1
- package/dist/cjs/data-structures/queue/queue.js.map +0 -1
- package/dist/cjs/data-structures/stack/index.js.map +0 -1
- package/dist/cjs/data-structures/stack/stack.js.map +0 -1
- package/dist/cjs/data-structures/tree/index.js.map +0 -1
- package/dist/cjs/data-structures/tree/tree.js.map +0 -1
- package/dist/cjs/data-structures/trie/index.js.map +0 -1
- package/dist/cjs/data-structures/trie/trie.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/interfaces/binary-tree.js.map +0 -1
- package/dist/cjs/interfaces/doubly-linked-list.js.map +0 -1
- package/dist/cjs/interfaces/index.js.map +0 -1
- package/dist/cjs/interfaces/navigator.js.map +0 -1
- package/dist/cjs/interfaces/priority-queue.js.map +0 -1
- package/dist/cjs/interfaces/segment-tree.js.map +0 -1
- package/dist/cjs/interfaces/singly-linked-list.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/avl-tree.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/bst.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/index.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/rb-tree.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/segment-tree.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/tree-multiset.js.map +0 -1
- package/dist/cjs/types/data-structures/graph/abstract-graph.js.map +0 -1
- package/dist/cjs/types/data-structures/graph/directed-graph.js.map +0 -1
- package/dist/cjs/types/data-structures/graph/index.js.map +0 -1
- package/dist/cjs/types/data-structures/graph/map-graph.js.map +0 -1
- package/dist/cjs/types/data-structures/graph/undirected-graph.js.map +0 -1
- package/dist/cjs/types/data-structures/hash/coordinate-map.js.map +0 -1
- package/dist/cjs/types/data-structures/hash/coordinate-set.js.map +0 -1
- package/dist/cjs/types/data-structures/hash/hash-map.js.map +0 -1
- package/dist/cjs/types/data-structures/hash/hash-table.js.map +0 -1
- package/dist/cjs/types/data-structures/hash/index.js.map +0 -1
- package/dist/cjs/types/data-structures/hash/tree-map.js.map +0 -1
- package/dist/cjs/types/data-structures/hash/tree-set.js.map +0 -1
- package/dist/cjs/types/data-structures/heap/heap.js.map +0 -1
- package/dist/cjs/types/data-structures/heap/index.js.map +0 -1
- package/dist/cjs/types/data-structures/heap/max-heap.js.map +0 -1
- package/dist/cjs/types/data-structures/heap/min-heap.js.map +0 -1
- package/dist/cjs/types/data-structures/index.js.map +0 -1
- package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.js.map +0 -1
- package/dist/cjs/types/data-structures/linked-list/index.js.map +0 -1
- package/dist/cjs/types/data-structures/linked-list/singly-linked-list.js.map +0 -1
- package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
- package/dist/cjs/types/data-structures/matrix/index.js.map +0 -1
- package/dist/cjs/types/data-structures/matrix/matrix.js.map +0 -1
- package/dist/cjs/types/data-structures/matrix/matrix2d.js.map +0 -1
- package/dist/cjs/types/data-structures/matrix/navigator.js.map +0 -1
- package/dist/cjs/types/data-structures/matrix/vector2d.js.map +0 -1
- package/dist/cjs/types/data-structures/priority-queue/index.js.map +0 -1
- package/dist/cjs/types/data-structures/priority-queue/max-priority-queue.js.map +0 -1
- package/dist/cjs/types/data-structures/priority-queue/min-priority-queue.js.map +0 -1
- package/dist/cjs/types/data-structures/priority-queue/priority-queue.js.map +0 -1
- package/dist/cjs/types/data-structures/queue/deque.js.map +0 -1
- package/dist/cjs/types/data-structures/queue/index.js.map +0 -1
- package/dist/cjs/types/data-structures/queue/queue.js.map +0 -1
- package/dist/cjs/types/data-structures/stack/index.js.map +0 -1
- package/dist/cjs/types/data-structures/stack/stack.js.map +0 -1
- package/dist/cjs/types/data-structures/tree/index.js.map +0 -1
- package/dist/cjs/types/data-structures/tree/tree.js.map +0 -1
- package/dist/cjs/types/data-structures/trie/index.js.map +0 -1
- package/dist/cjs/types/data-structures/trie/trie.js.map +0 -1
- package/dist/cjs/types/helpers.js.map +0 -1
- package/dist/cjs/types/index.js.map +0 -1
- package/dist/cjs/types/utils/index.js.map +0 -1
- package/dist/cjs/types/utils/validate-type.js.map +0 -1
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/utils.js.map +0 -1
- package/test/config.ts +0 -1
- package/test/integration/avl-tree.test.ts +0 -110
- package/test/integration/bst.test.ts +0 -385
- package/test/integration/heap.test.js +0 -16
- package/test/integration/index.html +0 -51
- package/test/performance/data-structures/binary-tree/avl-tree.test.ts +0 -36
- package/test/performance/data-structures/binary-tree/binary-index-tree.test.ts +0 -0
- package/test/performance/data-structures/binary-tree/binary-tree.test.ts +0 -45
- package/test/performance/data-structures/binary-tree/bst.test.ts +0 -36
- package/test/performance/data-structures/binary-tree/overall.test.ts +0 -0
- package/test/performance/data-structures/binary-tree/rb-tree.test.ts +0 -0
- package/test/performance/data-structures/binary-tree/segment-tree.test.ts +0 -0
- package/test/performance/data-structures/binary-tree/tree-multiset.test.ts +0 -0
- package/test/performance/data-structures/graph/abstract-graph.test.ts +0 -0
- package/test/performance/data-structures/graph/directed-graph.test.ts +0 -49
- package/test/performance/data-structures/graph/map-graph.test.ts +0 -0
- package/test/performance/data-structures/graph/overall.test.ts +0 -0
- package/test/performance/data-structures/graph/undirected-graph.test.ts +0 -0
- package/test/performance/data-structures/hash/coordinate-map.test.ts +0 -0
- package/test/performance/data-structures/hash/coordinate-set.test.ts +0 -0
- package/test/performance/data-structures/hash/hash-map.test.ts +0 -0
- package/test/performance/data-structures/hash/hash-table.test.ts +0 -0
- package/test/performance/data-structures/heap/heap.test.ts +0 -30
- package/test/performance/data-structures/heap/max-heap.test.ts +0 -0
- package/test/performance/data-structures/heap/min-heap.test.ts +0 -0
- package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +0 -40
- package/test/performance/data-structures/linked-list/linked-list.test.ts +0 -0
- package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +0 -34
- package/test/performance/data-structures/linked-list/skip-linked-list.test.ts +0 -0
- package/test/performance/data-structures/linked-list/skip-list.test.ts +0 -0
- package/test/performance/data-structures/matrix/matrix.test.ts +0 -0
- package/test/performance/data-structures/matrix/matrix2d.test.ts +0 -0
- package/test/performance/data-structures/matrix/navigator.test.ts +0 -0
- package/test/performance/data-structures/matrix/vector2d.test.ts +0 -0
- package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +0 -19
- package/test/performance/data-structures/priority-queue/min-priority-queue.test.ts +0 -0
- package/test/performance/data-structures/priority-queue/priority-queue.test.ts +0 -0
- package/test/performance/data-structures/queue/deque.test.ts +0 -21
- package/test/performance/data-structures/queue/queue.test.ts +0 -25
- package/test/performance/data-structures/stack/stack.test.ts +0 -0
- package/test/performance/data-structures/tree/tree.test.ts +0 -0
- package/test/performance/data-structures/trie/trie.test.ts +0 -22
- package/test/performance/reportor.ts +0 -183
- package/test/performance/types/index.ts +0 -1
- package/test/performance/types/reportor.ts +0 -3
- package/test/types/index.ts +0 -1
- package/test/types/utils/big-o.ts +0 -1
- package/test/types/utils/index.ts +0 -2
- package/test/types/utils/json2html.ts +0 -1
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +0 -269
- package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +0 -320
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +0 -486
- package/test/unit/data-structures/binary-tree/bst.test.ts +0 -840
- package/test/unit/data-structures/binary-tree/overall.test.ts +0 -66
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +0 -435
- package/test/unit/data-structures/binary-tree/segment-tree.test.ts +0 -50
- package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +0 -542
- package/test/unit/data-structures/graph/abstract-graph.test.ts +0 -100
- package/test/unit/data-structures/graph/directed-graph.test.ts +0 -564
- package/test/unit/data-structures/graph/map-graph.test.ts +0 -126
- package/test/unit/data-structures/graph/overall.test.ts +0 -49
- package/test/unit/data-structures/graph/undirected-graph.test.ts +0 -149
- package/test/unit/data-structures/hash/coordinate-map.test.ts +0 -74
- package/test/unit/data-structures/hash/coordinate-set.test.ts +0 -66
- package/test/unit/data-structures/hash/hash-map.test.ts +0 -103
- package/test/unit/data-structures/hash/hash-table.test.ts +0 -186
- package/test/unit/data-structures/heap/heap.test.ts +0 -254
- package/test/unit/data-structures/heap/max-heap.test.ts +0 -52
- package/test/unit/data-structures/heap/min-heap.test.ts +0 -52
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +0 -400
- package/test/unit/data-structures/linked-list/linked-list.test.ts +0 -8
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +0 -474
- package/test/unit/data-structures/linked-list/skip-linked-list.test.ts +0 -13
- package/test/unit/data-structures/linked-list/skip-list.test.ts +0 -86
- package/test/unit/data-structures/matrix/matrix.test.ts +0 -54
- package/test/unit/data-structures/matrix/matrix2d.test.ts +0 -345
- package/test/unit/data-structures/matrix/navigator.test.ts +0 -244
- package/test/unit/data-structures/matrix/vector2d.test.ts +0 -171
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +0 -73
- package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +0 -63
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +0 -53
- package/test/unit/data-structures/queue/deque.test.ts +0 -410
- package/test/unit/data-structures/queue/queue.test.ts +0 -207
- package/test/unit/data-structures/stack/stack.test.ts +0 -67
- package/test/unit/data-structures/tree/tree.test.ts +0 -39
- package/test/unit/data-structures/trie/trie.test.ts +0 -825
- package/test/utils/array.ts +0 -5514
- package/test/utils/big-o.ts +0 -207
- package/test/utils/console.ts +0 -31
- package/test/utils/index.ts +0 -7
- package/test/utils/is.ts +0 -56
- package/test/utils/json2html.ts +0 -322
- package/test/utils/number.ts +0 -13
- package/test/utils/string.ts +0 -1
- package/umd/bundle.min.js +0 -3
- package/umd/bundle.min.js.LICENSE.txt +0 -28
- package/umd/bundle.min.js.map +0 -1
- /package/dist/cjs/{data-structures → src/data-structures}/binary-tree/binary-indexed-tree.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/binary-tree/binary-indexed-tree.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/binary-tree/index.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/binary-tree/index.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/binary-tree/rb-tree.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/binary-tree/rb-tree.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/binary-tree/segment-tree.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/binary-tree/segment-tree.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/graph/abstract-graph.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/graph/abstract-graph.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/graph/directed-graph.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/graph/directed-graph.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/graph/index.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/graph/index.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/graph/map-graph.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/graph/map-graph.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/graph/undirected-graph.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/graph/undirected-graph.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/coordinate-map.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/coordinate-map.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/coordinate-set.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/coordinate-set.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/hash-map.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/hash-map.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/hash-table.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/hash-table.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/index.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/index.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/tree-map.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/tree-map.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/tree-set.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/hash/tree-set.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/heap/heap.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/heap/heap.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/heap/index.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/heap/index.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/heap/max-heap.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/heap/max-heap.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/heap/min-heap.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/heap/min-heap.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/index.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/index.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/linked-list/doubly-linked-list.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/linked-list/doubly-linked-list.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/linked-list/index.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/linked-list/index.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/linked-list/singly-linked-list.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/linked-list/singly-linked-list.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/linked-list/skip-linked-list.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/linked-list/skip-linked-list.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/matrix/index.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/matrix/index.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/matrix/matrix.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/matrix/matrix.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/matrix/matrix2d.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/matrix/matrix2d.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/matrix/navigator.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/matrix/navigator.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/matrix/vector2d.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/matrix/vector2d.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/priority-queue/index.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/priority-queue/index.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/priority-queue/max-priority-queue.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/priority-queue/max-priority-queue.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/priority-queue/min-priority-queue.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/priority-queue/min-priority-queue.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/priority-queue/priority-queue.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/priority-queue/priority-queue.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/queue/deque.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/queue/deque.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/queue/index.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/queue/index.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/queue/queue.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/queue/queue.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/stack/index.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/stack/index.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/stack/stack.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/stack/stack.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/tree/index.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/tree/index.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/tree/tree.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/tree/tree.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/trie/index.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/trie/index.js +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/trie/trie.d.ts +0 -0
- /package/dist/cjs/{data-structures → src/data-structures}/trie/trie.js +0 -0
- /package/dist/cjs/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/cjs/{index.js → src/index.js} +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/binary-tree.d.ts +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/binary-tree.js +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/doubly-linked-list.d.ts +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/doubly-linked-list.js +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/graph.d.ts +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/graph.js +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/heap.d.ts +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/heap.js +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/index.d.ts +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/index.js +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/navigator.d.ts +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/navigator.js +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/priority-queue.d.ts +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/priority-queue.js +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/segment-tree.d.ts +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/segment-tree.js +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/singly-linked-list.d.ts +0 -0
- /package/dist/cjs/{interfaces → src/interfaces}/singly-linked-list.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/avl-tree.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/avl-tree.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/binary-indexed-tree.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/binary-tree.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/binary-tree.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/bst.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/bst.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/index.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/rb-tree.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/rb-tree.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/segment-tree.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/segment-tree.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/tree-multiset.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/binary-tree/tree-multiset.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/graph/abstract-graph.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/graph/abstract-graph.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/graph/directed-graph.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/graph/directed-graph.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/graph/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/graph/index.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/graph/map-graph.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/graph/map-graph.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/graph/undirected-graph.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/graph/undirected-graph.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/coordinate-map.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/coordinate-map.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/coordinate-set.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/coordinate-set.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/hash-map.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/hash-map.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/hash-table.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/hash-table.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/index.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/tree-map.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/tree-map.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/tree-set.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/hash/tree-set.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/heap/heap.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/heap/heap.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/heap/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/heap/index.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/heap/max-heap.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/heap/max-heap.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/heap/min-heap.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/heap/min-heap.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/index.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/linked-list/doubly-linked-list.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/linked-list/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/linked-list/index.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/linked-list/singly-linked-list.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/linked-list/singly-linked-list.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/linked-list/skip-linked-list.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/linked-list/skip-linked-list.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/matrix/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/matrix/index.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/matrix/matrix.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/matrix/matrix.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/matrix/matrix2d.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/matrix/matrix2d.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/matrix/navigator.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/matrix/navigator.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/matrix/vector2d.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/matrix/vector2d.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/priority-queue/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/priority-queue/index.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/priority-queue/max-priority-queue.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/priority-queue/min-priority-queue.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/priority-queue/priority-queue.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/priority-queue/priority-queue.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/queue/deque.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/queue/deque.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/queue/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/queue/index.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/queue/queue.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/queue/queue.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/stack/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/stack/index.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/stack/stack.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/stack/stack.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/tree/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/tree/index.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/tree/tree.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/tree/tree.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/trie/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/trie/index.js +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/trie/trie.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/data-structures/trie/trie.js +0 -0
- /package/dist/cjs/{types → src/types}/helpers.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/helpers.js +0 -0
- /package/dist/cjs/{types → src/types}/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/index.js +0 -0
- /package/dist/cjs/{types → src/types}/utils/index.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/utils/index.js +0 -0
- /package/dist/cjs/{types → src/types}/utils/utils.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/utils/utils.js +0 -0
- /package/dist/cjs/{types → src/types}/utils/validate-type.d.ts +0 -0
- /package/dist/cjs/{types → src/types}/utils/validate-type.js +0 -0
- /package/dist/cjs/{utils → src/utils}/index.d.ts +0 -0
- /package/dist/cjs/{utils → src/utils}/index.js +0 -0
- /package/dist/cjs/{utils → src/utils}/utils.d.ts +0 -0
- /package/dist/cjs/{utils → src/utils}/utils.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/binary-tree/binary-indexed-tree.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/binary-tree/binary-indexed-tree.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/binary-tree/index.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/binary-tree/index.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/binary-tree/rb-tree.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/binary-tree/rb-tree.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/binary-tree/segment-tree.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/binary-tree/segment-tree.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/graph/abstract-graph.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/graph/abstract-graph.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/graph/directed-graph.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/graph/directed-graph.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/graph/index.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/graph/index.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/graph/map-graph.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/graph/map-graph.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/graph/undirected-graph.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/graph/undirected-graph.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/coordinate-map.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/coordinate-map.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/coordinate-set.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/coordinate-set.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/hash-map.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/hash-map.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/hash-table.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/hash-table.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/index.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/index.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/tree-map.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/tree-map.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/tree-set.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/hash/tree-set.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/heap/heap.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/heap/heap.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/heap/index.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/heap/index.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/heap/max-heap.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/heap/max-heap.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/heap/min-heap.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/heap/min-heap.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/index.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/index.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/linked-list/doubly-linked-list.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/linked-list/doubly-linked-list.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/linked-list/index.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/linked-list/index.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/linked-list/singly-linked-list.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/linked-list/singly-linked-list.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/linked-list/skip-linked-list.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/linked-list/skip-linked-list.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/matrix/index.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/matrix/index.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/matrix/matrix.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/matrix/matrix.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/matrix/matrix2d.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/matrix/matrix2d.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/matrix/navigator.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/matrix/navigator.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/matrix/vector2d.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/matrix/vector2d.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/priority-queue/index.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/priority-queue/index.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/priority-queue/max-priority-queue.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/priority-queue/max-priority-queue.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/priority-queue/min-priority-queue.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/priority-queue/min-priority-queue.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/priority-queue/priority-queue.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/priority-queue/priority-queue.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/queue/deque.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/queue/deque.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/queue/index.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/queue/index.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/queue/queue.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/queue/queue.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/stack/index.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/stack/index.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/stack/stack.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/stack/stack.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/tree/index.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/tree/index.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/tree/tree.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/tree/tree.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/trie/index.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/trie/index.js +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/trie/trie.d.ts +0 -0
- /package/dist/mjs/{data-structures → src/data-structures}/trie/trie.js +0 -0
- /package/dist/mjs/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/mjs/{index.js → src/index.js} +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/binary-tree.d.ts +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/binary-tree.js +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/doubly-linked-list.d.ts +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/doubly-linked-list.js +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/graph.d.ts +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/graph.js +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/heap.d.ts +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/heap.js +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/index.d.ts +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/index.js +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/navigator.d.ts +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/navigator.js +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/priority-queue.d.ts +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/priority-queue.js +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/segment-tree.d.ts +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/segment-tree.js +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/singly-linked-list.d.ts +0 -0
- /package/dist/mjs/{interfaces → src/interfaces}/singly-linked-list.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/avl-tree.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/avl-tree.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/binary-indexed-tree.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/binary-tree.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/binary-tree.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/bst.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/bst.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/index.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/rb-tree.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/rb-tree.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/segment-tree.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/segment-tree.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/tree-multiset.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/binary-tree/tree-multiset.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/graph/abstract-graph.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/graph/abstract-graph.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/graph/directed-graph.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/graph/directed-graph.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/graph/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/graph/index.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/graph/map-graph.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/graph/map-graph.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/graph/undirected-graph.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/graph/undirected-graph.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/coordinate-map.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/coordinate-map.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/coordinate-set.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/coordinate-set.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/hash-map.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/hash-map.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/hash-table.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/hash-table.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/index.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/tree-map.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/tree-map.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/tree-set.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/hash/tree-set.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/heap/heap.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/heap/heap.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/heap/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/heap/index.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/heap/max-heap.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/heap/max-heap.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/heap/min-heap.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/heap/min-heap.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/index.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/linked-list/doubly-linked-list.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/linked-list/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/linked-list/index.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/linked-list/singly-linked-list.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/linked-list/singly-linked-list.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/linked-list/skip-linked-list.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/linked-list/skip-linked-list.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/matrix/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/matrix/index.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/matrix/matrix.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/matrix/matrix.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/matrix/matrix2d.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/matrix/matrix2d.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/matrix/navigator.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/matrix/navigator.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/matrix/vector2d.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/matrix/vector2d.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/priority-queue/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/priority-queue/index.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/priority-queue/max-priority-queue.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/priority-queue/min-priority-queue.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/priority-queue/priority-queue.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/priority-queue/priority-queue.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/queue/deque.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/queue/deque.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/queue/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/queue/index.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/queue/queue.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/queue/queue.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/stack/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/stack/index.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/stack/stack.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/stack/stack.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/tree/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/tree/index.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/tree/tree.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/tree/tree.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/trie/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/trie/index.js +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/trie/trie.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/data-structures/trie/trie.js +0 -0
- /package/dist/mjs/{types → src/types}/helpers.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/helpers.js +0 -0
- /package/dist/mjs/{types → src/types}/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/index.js +0 -0
- /package/dist/mjs/{types → src/types}/utils/index.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/utils/index.js +0 -0
- /package/dist/mjs/{types → src/types}/utils/utils.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/utils/utils.js +0 -0
- /package/dist/mjs/{types → src/types}/utils/validate-type.d.ts +0 -0
- /package/dist/mjs/{types → src/types}/utils/validate-type.js +0 -0
- /package/dist/mjs/{utils → src/utils}/index.d.ts +0 -0
- /package/dist/mjs/{utils → src/utils}/index.js +0 -0
- /package/dist/mjs/{utils → src/utils}/utils.d.ts +0 -0
- /package/dist/mjs/{utils → src/utils}/utils.js +0 -0
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {DirectedGraph, UndirectedGraph} from '../../../../src';
|
|
2
|
-
|
|
3
|
-
describe('Overall Graph Operation Test', () => {
|
|
4
|
-
it('Overall DirectedGraph Operation Test', () => {
|
|
5
|
-
const graph = new DirectedGraph();
|
|
6
|
-
|
|
7
|
-
graph.addVertex('A');
|
|
8
|
-
graph.addVertex('B');
|
|
9
|
-
|
|
10
|
-
graph.hasVertex('A'); // true
|
|
11
|
-
graph.hasVertex('B'); // true
|
|
12
|
-
graph.hasVertex('C'); // false
|
|
13
|
-
expect(graph.hasVertex('A')).toBe(true); // true
|
|
14
|
-
expect(graph.hasVertex('B')).toBe(true); // true
|
|
15
|
-
expect(graph.hasVertex('C')).toBe(false); // false
|
|
16
|
-
|
|
17
|
-
graph.addEdge('A', 'B');
|
|
18
|
-
graph.hasEdge('A', 'B'); // true
|
|
19
|
-
graph.hasEdge('B', 'A'); // false
|
|
20
|
-
expect(graph.hasEdge('A', 'B')).toBe(true); // true
|
|
21
|
-
expect(graph.hasEdge('B', 'A')).toBe(false); // false
|
|
22
|
-
|
|
23
|
-
graph.deleteEdgeSrcToDest('A', 'B');
|
|
24
|
-
graph.hasEdge('A', 'B'); // false
|
|
25
|
-
expect(graph.hasEdge('A', 'B')).toBe(false); // false
|
|
26
|
-
|
|
27
|
-
graph.addVertex('C');
|
|
28
|
-
|
|
29
|
-
graph.addEdge('A', 'B');
|
|
30
|
-
graph.addEdge('B', 'C');
|
|
31
|
-
|
|
32
|
-
const topologicalOrderKeys = graph.topologicalSort();
|
|
33
|
-
expect(topologicalOrderKeys).toEqual(['A', 'B', 'C']);
|
|
34
|
-
});
|
|
35
|
-
it('Overall UndirectedGraph Operation Test', () => {
|
|
36
|
-
const graph = new UndirectedGraph();
|
|
37
|
-
graph.addVertex('A');
|
|
38
|
-
graph.addVertex('B');
|
|
39
|
-
graph.addVertex('C');
|
|
40
|
-
graph.addVertex('D');
|
|
41
|
-
graph.deleteVertex('C');
|
|
42
|
-
graph.addEdge('A', 'B');
|
|
43
|
-
graph.addEdge('B', 'D');
|
|
44
|
-
|
|
45
|
-
const dijkstraResult = graph.dijkstra('A');
|
|
46
|
-
Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.key); // ['A', 'B', 'D']
|
|
47
|
-
expect(Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.key)).toEqual(['A', 'B', 'D']);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import {UndirectedEdge, UndirectedGraph, UndirectedVertex} from '../../../../src';
|
|
2
|
-
|
|
3
|
-
describe('UndirectedGraph Operation Test', () => {
|
|
4
|
-
let graph: UndirectedGraph;
|
|
5
|
-
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
graph = new UndirectedGraph();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('should edge cases', () => {
|
|
11
|
-
expect(graph.deleteEdge(new UndirectedEdge('c', 'd'))).toBe(null);
|
|
12
|
-
expect(graph.deleteEdgeBetween('c', 'd')).toBe(null);
|
|
13
|
-
expect(graph.degreeOf('c')).toBe(0);
|
|
14
|
-
expect(graph.edgesOf('c').length).toBe(0);
|
|
15
|
-
expect(graph.getEndsOfEdge(new UndirectedEdge('c', 'd'))).toBe(null);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should add vertices', () => {
|
|
19
|
-
const vertex1 = new UndirectedVertex('A');
|
|
20
|
-
const vertex2 = new UndirectedVertex('B');
|
|
21
|
-
|
|
22
|
-
graph.addVertex(vertex1);
|
|
23
|
-
graph.addVertex(vertex2);
|
|
24
|
-
|
|
25
|
-
expect(graph.hasVertex(vertex1)).toBe(true);
|
|
26
|
-
expect(graph.hasVertex(vertex2)).toBe(true);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should add edges', () => {
|
|
30
|
-
const vertex1 = new UndirectedVertex('A');
|
|
31
|
-
const vertex2 = new UndirectedVertex('B');
|
|
32
|
-
const edge = new UndirectedEdge('A', 'B');
|
|
33
|
-
|
|
34
|
-
graph.addVertex(vertex1);
|
|
35
|
-
graph.addVertex(vertex2);
|
|
36
|
-
graph.addEdge(edge);
|
|
37
|
-
|
|
38
|
-
expect(graph.hasEdge('A', 'B')).toBe(true);
|
|
39
|
-
expect(graph.hasEdge('B', 'A')).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should delete edges', () => {
|
|
43
|
-
const vertex1 = new UndirectedVertex('A');
|
|
44
|
-
const vertex2 = new UndirectedVertex('B');
|
|
45
|
-
const edge = new UndirectedEdge('A', 'B');
|
|
46
|
-
|
|
47
|
-
graph.addVertex(vertex1);
|
|
48
|
-
graph.addVertex(vertex2);
|
|
49
|
-
graph.addEdge(edge);
|
|
50
|
-
|
|
51
|
-
expect(graph.deleteEdge(edge)).toBe(edge);
|
|
52
|
-
expect(graph.hasEdge('A', 'B')).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should perform topological sort', () => {
|
|
56
|
-
graph.addVertex('A');
|
|
57
|
-
graph.addVertex('B');
|
|
58
|
-
graph.addVertex('C');
|
|
59
|
-
graph.addVertex('D');
|
|
60
|
-
graph.deleteVertex('C');
|
|
61
|
-
graph.addEdge('A', 'B');
|
|
62
|
-
graph.addEdge('B', 'D');
|
|
63
|
-
|
|
64
|
-
const dijkstraResult = graph.dijkstra('A');
|
|
65
|
-
expect(Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.key)).toEqual(['A', 'B', 'D']);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe('UndirectedGraph', () => {
|
|
70
|
-
let undirectedGraph: UndirectedGraph<string, string>;
|
|
71
|
-
|
|
72
|
-
beforeEach(() => {
|
|
73
|
-
// Create a new UndirectedGraph instance before each test
|
|
74
|
-
undirectedGraph = new UndirectedGraph<string, string>();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Test adding vertices to the graph
|
|
78
|
-
it('should add vertices to the graph', () => {
|
|
79
|
-
const vertexA = new UndirectedVertex('A', 'Location A');
|
|
80
|
-
const vertexB = new UndirectedVertex('B', 'Location B');
|
|
81
|
-
|
|
82
|
-
undirectedGraph.addVertex(vertexA);
|
|
83
|
-
undirectedGraph.addVertex(vertexB);
|
|
84
|
-
|
|
85
|
-
expect(undirectedGraph.hasVertex('A')).toBe(true);
|
|
86
|
-
expect(undirectedGraph.hasVertex('B')).toBe(true);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// Test adding edges to the graph
|
|
90
|
-
it('should add edges to the graph', () => {
|
|
91
|
-
const vertexA = new UndirectedVertex('A', 'Location A');
|
|
92
|
-
const vertexB = new UndirectedVertex('B', 'Location B');
|
|
93
|
-
const edgeAB = new UndirectedEdge('A', 'B', 1, 'Edge between A and B');
|
|
94
|
-
|
|
95
|
-
undirectedGraph.addVertex(vertexA);
|
|
96
|
-
undirectedGraph.addVertex(vertexB);
|
|
97
|
-
undirectedGraph.addEdge(edgeAB);
|
|
98
|
-
|
|
99
|
-
expect(undirectedGraph.hasEdge('A', 'B')).toBe(true);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// Test getting neighbors of a vertex
|
|
103
|
-
it('should return the neighbors of a vertex', () => {
|
|
104
|
-
const vertexA = new UndirectedVertex('A', 'Location A');
|
|
105
|
-
const vertexB = new UndirectedVertex('B', 'Location B');
|
|
106
|
-
const vertexC = new UndirectedVertex('C', 'Location C');
|
|
107
|
-
const edgeAB = new UndirectedEdge('A', 'B', 1, 'Edge between A and B');
|
|
108
|
-
const edgeBC = new UndirectedEdge('B', 'C', 2, 'Edge between B and C');
|
|
109
|
-
|
|
110
|
-
undirectedGraph.addVertex(vertexA);
|
|
111
|
-
undirectedGraph.addVertex(vertexB);
|
|
112
|
-
undirectedGraph.addVertex(vertexC);
|
|
113
|
-
undirectedGraph.addEdge(edgeAB);
|
|
114
|
-
undirectedGraph.addEdge(edgeBC);
|
|
115
|
-
|
|
116
|
-
const neighborsOfA = undirectedGraph.getNeighbors('A');
|
|
117
|
-
const neighborsOfB = undirectedGraph.getNeighbors('B');
|
|
118
|
-
|
|
119
|
-
expect(neighborsOfA).toEqual([vertexB]);
|
|
120
|
-
expect(neighborsOfB).toEqual([vertexA, vertexC]);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// Test degree of a vertex
|
|
124
|
-
it('should return the degree of a vertex', () => {
|
|
125
|
-
const vertexA = new UndirectedVertex('A', 'Location A');
|
|
126
|
-
const vertexB = new UndirectedVertex('B', 'Location B');
|
|
127
|
-
const vertexC = new UndirectedVertex('C', 'Location C');
|
|
128
|
-
const edgeAB = new UndirectedEdge('A', 'B', 3, 'Edge between A and B');
|
|
129
|
-
const edgeBC = new UndirectedEdge('B', 'C', 4, 'Edge between B and C');
|
|
130
|
-
|
|
131
|
-
edgeAB.vertices = edgeAB.vertices;
|
|
132
|
-
expect(undirectedGraph.edges.size).toBe(0);
|
|
133
|
-
undirectedGraph.addVertex(vertexA);
|
|
134
|
-
undirectedGraph.addVertex(vertexB);
|
|
135
|
-
undirectedGraph.addVertex(vertexC);
|
|
136
|
-
undirectedGraph.addEdge(edgeAB);
|
|
137
|
-
undirectedGraph.addEdge(edgeBC);
|
|
138
|
-
|
|
139
|
-
const degreeOfA = undirectedGraph.degreeOf('A');
|
|
140
|
-
const degreeOfB = undirectedGraph.degreeOf('B');
|
|
141
|
-
const degreeOfC = undirectedGraph.degreeOf('C');
|
|
142
|
-
expect(undirectedGraph.edgeSet().length).toBe(2);
|
|
143
|
-
expect(undirectedGraph.getEndsOfEdge(edgeBC)?.length).toBe(2);
|
|
144
|
-
|
|
145
|
-
expect(degreeOfA).toBe(1);
|
|
146
|
-
expect(degreeOfB).toBe(2);
|
|
147
|
-
expect(degreeOfC).toBe(1);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import {CoordinateMap} from '../../../../src';
|
|
2
|
-
|
|
3
|
-
describe('CoordinateMap', () => {
|
|
4
|
-
it('should set and get values correctly', () => {
|
|
5
|
-
const coordinateMap = new CoordinateMap<string>();
|
|
6
|
-
const key = [1, 2, 3];
|
|
7
|
-
const value = 'TestValue';
|
|
8
|
-
|
|
9
|
-
coordinateMap.set(key, value);
|
|
10
|
-
const retrievedValue = coordinateMap.get(key);
|
|
11
|
-
|
|
12
|
-
expect(retrievedValue).toBe(value);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should return true when key exists', () => {
|
|
16
|
-
const coordinateMap = new CoordinateMap<string>();
|
|
17
|
-
const key = [1, 2, 3];
|
|
18
|
-
const value = 'TestValue';
|
|
19
|
-
|
|
20
|
-
coordinateMap.set(key, value);
|
|
21
|
-
|
|
22
|
-
expect(coordinateMap.has(key)).toBe(true);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should return false when key does not exist', () => {
|
|
26
|
-
const coordinateMap = new CoordinateMap<string>();
|
|
27
|
-
const key = [1, 2, 3];
|
|
28
|
-
|
|
29
|
-
expect(coordinateMap.has(key)).toBe(false);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should delete key-value pair correctly', () => {
|
|
33
|
-
const coordinateMap = new CoordinateMap<string>();
|
|
34
|
-
const key = [1, 2, 3];
|
|
35
|
-
const value = 'TestValue';
|
|
36
|
-
|
|
37
|
-
coordinateMap.set(key, value);
|
|
38
|
-
coordinateMap.delete(key);
|
|
39
|
-
|
|
40
|
-
expect(coordinateMap.has(key)).toBe(false);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should allow changing the joint character', () => {
|
|
44
|
-
const coordinateMap = new CoordinateMap<string>();
|
|
45
|
-
const key = [1, 2, 3];
|
|
46
|
-
const value = 'TestValue';
|
|
47
|
-
|
|
48
|
-
coordinateMap.set(key, value);
|
|
49
|
-
const newKey = [1, 2, 3];
|
|
50
|
-
const retrievedValue = coordinateMap.get(newKey);
|
|
51
|
-
|
|
52
|
-
expect(retrievedValue).toBe(value);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe('CoordinateMap', () => {
|
|
57
|
-
class MyCoordinateMap<V = any> extends CoordinateMap<V> {
|
|
58
|
-
constructor(joint?: string) {
|
|
59
|
-
super(joint);
|
|
60
|
-
this._joint = joint += '-';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const cMap = new MyCoordinateMap<number>('*');
|
|
65
|
-
|
|
66
|
-
beforeEach(() => {
|
|
67
|
-
cMap.set([0, 0], 0);
|
|
68
|
-
cMap.set([0, 1], 1);
|
|
69
|
-
cMap.set([1, 1], 11);
|
|
70
|
-
});
|
|
71
|
-
it('should joint to be *-', () => {
|
|
72
|
-
expect(cMap.joint).toBe('*-');
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {CoordinateSet} from '../../../../src';
|
|
2
|
-
|
|
3
|
-
describe('CoordinateSet', () => {
|
|
4
|
-
it('should add and check values correctly', () => {
|
|
5
|
-
const coordinateSet = new CoordinateSet();
|
|
6
|
-
const value = [1, 2, 3];
|
|
7
|
-
|
|
8
|
-
coordinateSet.add(value);
|
|
9
|
-
const hasValue = coordinateSet.has(value);
|
|
10
|
-
|
|
11
|
-
expect(hasValue).toBe(true);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('should return false when value does not exist', () => {
|
|
15
|
-
const coordinateSet = new CoordinateSet();
|
|
16
|
-
const value = [1, 2, 3];
|
|
17
|
-
|
|
18
|
-
expect(coordinateSet.has(value)).toBe(false);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('should delete value correctly', () => {
|
|
22
|
-
const coordinateSet = new CoordinateSet();
|
|
23
|
-
const value = [1, 2, 3];
|
|
24
|
-
|
|
25
|
-
coordinateSet.add(value);
|
|
26
|
-
coordinateSet.delete(value);
|
|
27
|
-
|
|
28
|
-
expect(coordinateSet.has(value)).toBe(false);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should allow changing the joint character', () => {
|
|
32
|
-
const coordinateSet = new CoordinateSet();
|
|
33
|
-
const value = [1, 2, 3];
|
|
34
|
-
|
|
35
|
-
coordinateSet.add(value);
|
|
36
|
-
const newValue = [1, 2, 3];
|
|
37
|
-
const hasValue = coordinateSet.has(newValue);
|
|
38
|
-
|
|
39
|
-
expect(hasValue).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('MyCoordinateSet', () => {
|
|
44
|
-
class MyCoordinateSet extends CoordinateSet {
|
|
45
|
-
constructor(joint?: string) {
|
|
46
|
-
super(joint);
|
|
47
|
-
this._joint = joint += '-';
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const mySet = new MyCoordinateSet('*');
|
|
52
|
-
|
|
53
|
-
beforeEach(() => {
|
|
54
|
-
mySet.add([0, 0]);
|
|
55
|
-
mySet.add([0, 1]);
|
|
56
|
-
mySet.add([1, 1]);
|
|
57
|
-
});
|
|
58
|
-
it('should joint to be *-', () => {
|
|
59
|
-
expect(mySet.joint).toBe('*-');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('should has, delete', () => {
|
|
63
|
-
mySet.delete([0, 1]);
|
|
64
|
-
expect(mySet.has([0, 1])).toBe(false);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import {HashMap} from '../../../../src';
|
|
2
|
-
|
|
3
|
-
describe('HashMap', () => {
|
|
4
|
-
let hashMap: HashMap<string, number>;
|
|
5
|
-
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
hashMap = new HashMap<string, number>();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('should initialize correctly', () => {
|
|
11
|
-
expect(hashMap.size).toBe(0);
|
|
12
|
-
expect(hashMap.table.length).toBe(16);
|
|
13
|
-
expect(hashMap.loadFactor).toBe(0.75);
|
|
14
|
-
expect(hashMap.capacityMultiplier).toBe(2);
|
|
15
|
-
expect(hashMap.initialCapacity).toBe(16);
|
|
16
|
-
expect(hashMap.isEmpty()).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should put and get values', () => {
|
|
20
|
-
hashMap.set('one', 1);
|
|
21
|
-
hashMap.set('two', 2);
|
|
22
|
-
hashMap.set('three', 3);
|
|
23
|
-
|
|
24
|
-
expect(hashMap.get('one')).toBe(1);
|
|
25
|
-
expect(hashMap.get('two')).toBe(2);
|
|
26
|
-
expect(hashMap.get('three')).toBe(3);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should handle key collisions', () => {
|
|
30
|
-
// Force a collision by setting two different keys to the same bucket
|
|
31
|
-
hashMap.set('key1', 1);
|
|
32
|
-
hashMap.set('key2', 2);
|
|
33
|
-
|
|
34
|
-
expect(hashMap.get('key1')).toBe(1);
|
|
35
|
-
expect(hashMap.get('key2')).toBe(2);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should delete values', () => {
|
|
39
|
-
hashMap.set('one', 1);
|
|
40
|
-
hashMap.set('two', 2);
|
|
41
|
-
|
|
42
|
-
hashMap.delete('one');
|
|
43
|
-
expect(hashMap.get('one')).toBeUndefined();
|
|
44
|
-
expect(hashMap.size).toBe(1);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should clear the HashMap', () => {
|
|
48
|
-
hashMap.set('one', 1);
|
|
49
|
-
hashMap.set('two', 2);
|
|
50
|
-
|
|
51
|
-
hashMap.clear();
|
|
52
|
-
expect(hashMap.size).toBe(0);
|
|
53
|
-
expect(hashMap.isEmpty()).toBe(true);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('should iterate over entries', () => {
|
|
57
|
-
hashMap.set('one', 1);
|
|
58
|
-
hashMap.set('two', 2);
|
|
59
|
-
hashMap.set('three', 3);
|
|
60
|
-
|
|
61
|
-
const entries = Array.from(hashMap.entries());
|
|
62
|
-
expect(entries).toEqual(
|
|
63
|
-
expect.arrayContaining([
|
|
64
|
-
['one', 1],
|
|
65
|
-
['two', 2],
|
|
66
|
-
['three', 3]
|
|
67
|
-
])
|
|
68
|
-
);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('should resize the table when load factor is exceeded', () => {
|
|
72
|
-
// Set a small initial capacity for testing resizing
|
|
73
|
-
hashMap = new HashMap<string, number>(4, 0.5);
|
|
74
|
-
|
|
75
|
-
hashMap.set('one', 1);
|
|
76
|
-
hashMap.set('two', 2);
|
|
77
|
-
hashMap.set('three', 3);
|
|
78
|
-
hashMap.set('four', 4); // This should trigger a resize
|
|
79
|
-
|
|
80
|
-
expect(hashMap.table.length).toBe(8);
|
|
81
|
-
expect(hashMap.get('one')).toBe(1);
|
|
82
|
-
expect(hashMap.get('two')).toBe(2);
|
|
83
|
-
expect(hashMap.get('three')).toBe(3);
|
|
84
|
-
expect(hashMap.get('four')).toBe(4);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('should allow using a custom hash function', () => {
|
|
88
|
-
const customHashFn = () => {
|
|
89
|
-
// A simple custom hash function that always returns 0
|
|
90
|
-
return 0;
|
|
91
|
-
};
|
|
92
|
-
hashMap = new HashMap<string, number>(16, 0.75, customHashFn);
|
|
93
|
-
|
|
94
|
-
hashMap.set('one', 1);
|
|
95
|
-
hashMap.set('two', 2);
|
|
96
|
-
|
|
97
|
-
expect(hashMap.get('one')).toBe(1);
|
|
98
|
-
expect(hashMap.get('two')).toBe(2);
|
|
99
|
-
// Since the custom hash function always returns 0, these keys will collide.
|
|
100
|
-
// Make sure they are stored separately.
|
|
101
|
-
expect(hashMap.table[0].length).toBe(2);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import {HashTable, HashTableNode} from '../../../../src';
|
|
2
|
-
|
|
3
|
-
describe('HashNode', () => {
|
|
4
|
-
it('should create a HashNode with key and value', () => {
|
|
5
|
-
const key = 'testKey';
|
|
6
|
-
const value = 'testValue';
|
|
7
|
-
const hashNode = new HashTableNode(key, value);
|
|
8
|
-
|
|
9
|
-
expect(hashNode.key).toBe(key);
|
|
10
|
-
expect(hashNode.value).toBe(value);
|
|
11
|
-
expect(hashNode.next).toBe(null);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
describe('HashTable', () => {
|
|
16
|
-
it('should initialize with default capacity', () => {
|
|
17
|
-
const hashTable = new HashTable<string, string>();
|
|
18
|
-
expect(hashTable.capacity).toBe(16);
|
|
19
|
-
expect(hashTable.buckets).toEqual(new Array(16).fill(null));
|
|
20
|
-
expect(hashTable.hashFn('a')).toBe(6);
|
|
21
|
-
expect(hashTable.capacity).toBe(16);
|
|
22
|
-
expect(hashTable.size).toBe(0);
|
|
23
|
-
expect(hashTable.buckets.length).toBe(16);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should initialize with custom capacity', () => {
|
|
27
|
-
const customCapacity = 500;
|
|
28
|
-
const hashTable = new HashTable<string, string>(customCapacity);
|
|
29
|
-
|
|
30
|
-
expect(hashTable.capacity).toBe(customCapacity);
|
|
31
|
-
expect(hashTable.size).toBe(0);
|
|
32
|
-
expect(hashTable.buckets.length).toBe(customCapacity);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should put and get values correctly', () => {
|
|
36
|
-
const hashTable = new HashTable<string, string>();
|
|
37
|
-
const key = 'testKey';
|
|
38
|
-
const value = 'testValue';
|
|
39
|
-
|
|
40
|
-
hashTable.set(key, value);
|
|
41
|
-
const retrievedValue = hashTable.get(key);
|
|
42
|
-
|
|
43
|
-
expect(retrievedValue).toBe(value);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should handle collisions by chaining', () => {
|
|
47
|
-
const hashTable = new HashTable<string, string>();
|
|
48
|
-
const key1 = 'testKey1';
|
|
49
|
-
const value1 = 'testValue1';
|
|
50
|
-
const key2 = 'testKey2';
|
|
51
|
-
const value2 = 'testValue2';
|
|
52
|
-
|
|
53
|
-
hashTable.set(key1, value1);
|
|
54
|
-
hashTable.set(key2, value2);
|
|
55
|
-
|
|
56
|
-
const retrievedValue1 = hashTable.get(key1);
|
|
57
|
-
const retrievedValue2 = hashTable.get(key2);
|
|
58
|
-
|
|
59
|
-
expect(retrievedValue1).toBe(value1);
|
|
60
|
-
expect(retrievedValue2).toBe(value2);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should update value for an existing key', () => {
|
|
64
|
-
const hashTable = new HashTable<string, string>();
|
|
65
|
-
const key = 'testKey';
|
|
66
|
-
const initialValue = 'testValue1';
|
|
67
|
-
const updatedValue = 'testValue2';
|
|
68
|
-
|
|
69
|
-
hashTable.set(key, initialValue);
|
|
70
|
-
hashTable.set(key, updatedValue);
|
|
71
|
-
|
|
72
|
-
const retrievedValue = hashTable.get(key);
|
|
73
|
-
|
|
74
|
-
expect(retrievedValue).toBe(updatedValue);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should return undefined for non-existent key', () => {
|
|
78
|
-
const hashTable = new HashTable<string, string>();
|
|
79
|
-
const key = 'nonExistentKey';
|
|
80
|
-
|
|
81
|
-
const retrievedValue = hashTable.get(key);
|
|
82
|
-
|
|
83
|
-
expect(retrievedValue).toBeUndefined();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('should delete key-value pair correctly', () => {
|
|
87
|
-
const hashTable = new HashTable<string, string>();
|
|
88
|
-
const key = 'testKey';
|
|
89
|
-
const value = 'testValue';
|
|
90
|
-
|
|
91
|
-
hashTable.set(key, value);
|
|
92
|
-
hashTable.delete(key);
|
|
93
|
-
|
|
94
|
-
const retrievedValue = hashTable.get(key);
|
|
95
|
-
|
|
96
|
-
expect(retrievedValue).toBeUndefined();
|
|
97
|
-
expect(hashTable.size).toBe(0);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
describe('HashTable', () => {
|
|
102
|
-
let hashTable: HashTable<string, number>;
|
|
103
|
-
|
|
104
|
-
beforeEach(() => {
|
|
105
|
-
hashTable = new HashTable<string, number>();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('should insert and retrieve values correctly', () => {
|
|
109
|
-
hashTable.set('one', 1);
|
|
110
|
-
hashTable.set('two', 2);
|
|
111
|
-
|
|
112
|
-
expect(hashTable.get('one')).toBe(1);
|
|
113
|
-
expect(hashTable.get('two')).toBe(2);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('should update values correctly', () => {
|
|
117
|
-
hashTable.set('one', 1);
|
|
118
|
-
expect(hashTable.get('one')).toBe(1);
|
|
119
|
-
|
|
120
|
-
hashTable.set('one', 100); // Update the value
|
|
121
|
-
expect(hashTable.get('one')).toBe(100);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('should handle collisions correctly', () => {
|
|
125
|
-
hashTable = new HashTable<string, number>(1); // Set a small capacity to force collisions
|
|
126
|
-
hashTable.set('one', 1);
|
|
127
|
-
hashTable.set('two', 2);
|
|
128
|
-
|
|
129
|
-
expect(hashTable.get('one')).toBe(1);
|
|
130
|
-
expect(hashTable.get('two')).toBe(2);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('should delete values correctly', () => {
|
|
134
|
-
hashTable.set('one', 1);
|
|
135
|
-
hashTable.set('two', 2);
|
|
136
|
-
hashTable.delete('one');
|
|
137
|
-
|
|
138
|
-
expect(hashTable.get('one')).toBeUndefined();
|
|
139
|
-
expect(hashTable.get('two')).toBe(2);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('should handle non-existent keys correctly', () => {
|
|
143
|
-
expect(hashTable.get('non-existent')).toBeUndefined();
|
|
144
|
-
hashTable.delete('non-existent'); // Removing a non-existent key should not cause errors
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('should handle custom hash function correctly', () => {
|
|
148
|
-
// const customHashFn = () => {
|
|
149
|
-
// // Custom hash function that returns a fixed value for all keys
|
|
150
|
-
// return 42;
|
|
151
|
-
// };
|
|
152
|
-
|
|
153
|
-
hashTable = new HashTable<string, number>(16);
|
|
154
|
-
hashTable.set('one', 1);
|
|
155
|
-
expect(hashTable.get('one')).toBe(1);
|
|
156
|
-
expect(hashTable.get('two')).toBeUndefined();
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('should expand when load factor exceeds threshold', () => {
|
|
160
|
-
hashTable = new HashTable<string, number>(2); // Set a small capacity to trigger expansion
|
|
161
|
-
hashTable.set('one', 1);
|
|
162
|
-
hashTable.set('two', 2);
|
|
163
|
-
hashTable.set('three', 3); // This should trigger an expansion
|
|
164
|
-
|
|
165
|
-
expect(hashTable.capacity).toBe(16);
|
|
166
|
-
expect(hashTable.get('one')).toBe(1);
|
|
167
|
-
expect(hashTable.get('two')).toBe(2);
|
|
168
|
-
expect(hashTable.get('three')).toBe(3);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
describe('HashTable performance', function () {
|
|
173
|
-
it('Items set performance', function () {
|
|
174
|
-
const mag = 100000;
|
|
175
|
-
const ht = new HashTable();
|
|
176
|
-
// const s = performance.now();
|
|
177
|
-
for (let i = 0; i < mag; i++) {
|
|
178
|
-
ht.set(i, i);
|
|
179
|
-
}
|
|
180
|
-
// const s1 = performance.now();
|
|
181
|
-
const map = new Map();
|
|
182
|
-
for (let i = 0; i < mag; i++) {
|
|
183
|
-
map.set(i, i);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
});
|