data-structure-typed 2.1.0 → 2.1.2
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 +5 -1
- package/COMMANDS.md +13 -3
- package/README.md +21 -38
- package/benchmark/report.html +1 -1
- package/benchmark/report.json +101 -101
- package/dist/cjs/index.cjs +13062 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/esm/index.mjs +12984 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/{cjs → types}/data-structures/binary-tree/avl-tree-counter.d.ts +5 -5
- package/dist/{esm → types}/data-structures/binary-tree/avl-tree-multi-map.d.ts +6 -6
- package/dist/{esm → types}/data-structures/binary-tree/avl-tree.d.ts +5 -5
- package/dist/{esm → types}/data-structures/binary-tree/binary-tree.d.ts +6 -6
- package/dist/{esm → types}/data-structures/binary-tree/bst.d.ts +6 -6
- package/dist/{esm → types}/data-structures/binary-tree/red-black-tree.d.ts +6 -6
- package/dist/{cjs → types}/data-structures/binary-tree/tree-counter.d.ts +5 -5
- package/dist/{cjs → types}/data-structures/binary-tree/tree-multi-map.d.ts +6 -6
- package/dist/{esm → types}/data-structures/heap/heap.d.ts +4 -4
- package/dist/{esm → types}/data-structures/linked-list/singly-linked-list.d.ts +1 -1
- package/dist/{esm → types}/interfaces/binary-tree.d.ts +3 -3
- package/dist/umd/data-structure-typed.js +97 -174
- package/dist/umd/data-structure-typed.js.map +1 -0
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/jest.integration.config.js +8 -1
- package/package.json +20 -14
- package/src/data-structures/binary-tree/avl-tree-counter.ts +8 -11
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +6 -11
- package/src/data-structures/binary-tree/avl-tree.ts +6 -8
- package/src/data-structures/binary-tree/binary-tree.ts +18 -20
- package/src/data-structures/binary-tree/bst.ts +6 -11
- package/src/data-structures/binary-tree/red-black-tree.ts +6 -11
- package/src/data-structures/binary-tree/tree-counter.ts +8 -13
- package/src/data-structures/binary-tree/tree-multi-map.ts +6 -11
- package/src/data-structures/heap/heap.ts +5 -5
- package/src/data-structures/linked-list/singly-linked-list.ts +2 -2
- package/src/interfaces/binary-tree.ts +3 -3
- package/test/integration/all-in-one.test.ts +1 -1
- package/test/integration/compile.test.mjs +159 -0
- package/test/integration/compile.test.ts +176 -0
- package/test/integration/heap.test.js +1 -1
- package/test/integration/index.html +1 -1
- package/test/performance/data-structures/comparison/comparison.test.ts +27 -57
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +3 -3
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +109 -1
- package/tsconfig.base.json +23 -0
- package/tsconfig.test.json +9 -0
- package/tsconfig.types.json +15 -0
- package/tsup.config.js +12 -24
- package/tsup.node.config.js +37 -0
- package/dist/cjs/common/index.js +0 -29
- package/dist/cjs/common/index.js.map +0 -1
- package/dist/cjs/data-structures/base/index.js +0 -19
- package/dist/cjs/data-structures/base/index.js.map +0 -1
- package/dist/cjs/data-structures/base/iterable-element-base.js +0 -244
- package/dist/cjs/data-structures/base/iterable-element-base.js.map +0 -1
- package/dist/cjs/data-structures/base/iterable-entry-base.js +0 -184
- package/dist/cjs/data-structures/base/iterable-entry-base.js.map +0 -1
- package/dist/cjs/data-structures/base/linear-base.js +0 -416
- package/dist/cjs/data-structures/base/linear-base.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js +0 -375
- package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -135
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +0 -251
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +0 -291
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -612
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +0 -295
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +0 -754
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +0 -1926
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +0 -413
- package/dist/cjs/data-structures/binary-tree/bst.js +0 -904
- package/dist/cjs/data-structures/binary-tree/bst.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/index.js +0 -27
- package/dist/cjs/data-structures/binary-tree/index.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +0 -208
- package/dist/cjs/data-structures/binary-tree/red-black-tree.js +0 -547
- package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/segment-tree.js +0 -298
- package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/tree-counter.js +0 -414
- package/dist/cjs/data-structures/binary-tree/tree-counter.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +0 -385
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +0 -1
- package/dist/cjs/data-structures/graph/abstract-graph.js +0 -897
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +0 -1
- package/dist/cjs/data-structures/graph/directed-graph.js +0 -526
- package/dist/cjs/data-structures/graph/directed-graph.js.map +0 -1
- package/dist/cjs/data-structures/graph/index.js +0 -21
- package/dist/cjs/data-structures/graph/index.js.map +0 -1
- package/dist/cjs/data-structures/graph/map-graph.js +0 -108
- package/dist/cjs/data-structures/graph/map-graph.js.map +0 -1
- package/dist/cjs/data-structures/graph/undirected-graph.js +0 -425
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +0 -1
- package/dist/cjs/data-structures/hash/hash-map.js +0 -693
- package/dist/cjs/data-structures/hash/hash-map.js.map +0 -1
- package/dist/cjs/data-structures/hash/index.js +0 -18
- package/dist/cjs/data-structures/hash/index.js.map +0 -1
- package/dist/cjs/data-structures/heap/heap.d.ts +0 -503
- package/dist/cjs/data-structures/heap/heap.js +0 -902
- package/dist/cjs/data-structures/heap/heap.js.map +0 -1
- package/dist/cjs/data-structures/heap/index.js +0 -20
- package/dist/cjs/data-structures/heap/index.js.map +0 -1
- package/dist/cjs/data-structures/heap/max-heap.js +0 -41
- package/dist/cjs/data-structures/heap/max-heap.js.map +0 -1
- package/dist/cjs/data-structures/heap/min-heap.js +0 -32
- package/dist/cjs/data-structures/heap/min-heap.js.map +0 -1
- package/dist/cjs/data-structures/index.js +0 -29
- package/dist/cjs/data-structures/index.js.map +0 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +0 -1112
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +0 -1
- package/dist/cjs/data-structures/linked-list/index.js +0 -20
- package/dist/cjs/data-structures/linked-list/index.js.map +0 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +0 -451
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +0 -851
- 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 +0 -145
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +0 -1
- package/dist/cjs/data-structures/matrix/index.js +0 -19
- package/dist/cjs/data-structures/matrix/index.js.map +0 -1
- package/dist/cjs/data-structures/matrix/matrix.js +0 -449
- package/dist/cjs/data-structures/matrix/matrix.js.map +0 -1
- package/dist/cjs/data-structures/matrix/navigator.js +0 -112
- package/dist/cjs/data-structures/matrix/navigator.js.map +0 -1
- package/dist/cjs/data-structures/priority-queue/index.js +0 -20
- package/dist/cjs/data-structures/priority-queue/index.js.map +0 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +0 -35
- 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 +0 -25
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +0 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.js +0 -21
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +0 -1
- package/dist/cjs/data-structures/queue/deque.js +0 -880
- package/dist/cjs/data-structures/queue/deque.js.map +0 -1
- package/dist/cjs/data-structures/queue/index.js +0 -19
- package/dist/cjs/data-structures/queue/index.js.map +0 -1
- package/dist/cjs/data-structures/queue/queue.js +0 -474
- package/dist/cjs/data-structures/queue/queue.js.map +0 -1
- package/dist/cjs/data-structures/stack/index.js +0 -18
- package/dist/cjs/data-structures/stack/index.js.map +0 -1
- package/dist/cjs/data-structures/stack/stack.js +0 -402
- package/dist/cjs/data-structures/stack/stack.js.map +0 -1
- package/dist/cjs/data-structures/tree/index.js +0 -18
- package/dist/cjs/data-structures/tree/index.js.map +0 -1
- package/dist/cjs/data-structures/tree/tree.js +0 -108
- package/dist/cjs/data-structures/tree/tree.js.map +0 -1
- package/dist/cjs/data-structures/trie/index.js +0 -18
- package/dist/cjs/data-structures/trie/index.js.map +0 -1
- package/dist/cjs/data-structures/trie/trie.js +0 -611
- package/dist/cjs/data-structures/trie/trie.js.map +0 -1
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/interfaces/binary-tree.d.ts +0 -59
- package/dist/cjs/interfaces/binary-tree.js +0 -3
- package/dist/cjs/interfaces/binary-tree.js.map +0 -1
- package/dist/cjs/interfaces/doubly-linked-list.js +0 -3
- package/dist/cjs/interfaces/doubly-linked-list.js.map +0 -1
- package/dist/cjs/interfaces/graph.js +0 -3
- package/dist/cjs/interfaces/graph.js.map +0 -1
- package/dist/cjs/interfaces/heap.js +0 -3
- package/dist/cjs/interfaces/heap.js.map +0 -1
- package/dist/cjs/interfaces/index.js +0 -25
- package/dist/cjs/interfaces/index.js.map +0 -1
- package/dist/cjs/interfaces/navigator.js +0 -3
- package/dist/cjs/interfaces/navigator.js.map +0 -1
- package/dist/cjs/interfaces/priority-queue.js +0 -3
- package/dist/cjs/interfaces/priority-queue.js.map +0 -1
- package/dist/cjs/interfaces/segment-tree.js +0 -3
- package/dist/cjs/interfaces/segment-tree.js.map +0 -1
- package/dist/cjs/interfaces/singly-linked-list.js +0 -3
- package/dist/cjs/interfaces/singly-linked-list.js.map +0 -1
- package/dist/cjs/types/common.js +0 -3
- package/dist/cjs/types/common.js.map +0 -1
- package/dist/cjs/types/data-structures/base/base.js +0 -3
- package/dist/cjs/types/data-structures/base/base.js.map +0 -1
- package/dist/cjs/types/data-structures/base/index.js +0 -18
- package/dist/cjs/types/data-structures/base/index.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js +0 -3
- package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -3
- package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/avl-tree.js +0 -3
- 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 +0 -3
- 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 +0 -3
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/bst.js +0 -3
- package/dist/cjs/types/data-structures/binary-tree/bst.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/index.js +0 -26
- package/dist/cjs/types/data-structures/binary-tree/index.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js +0 -3
- package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/segment-tree.js +0 -3
- package/dist/cjs/types/data-structures/binary-tree/segment-tree.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/tree-counter.js +0 -3
- package/dist/cjs/types/data-structures/binary-tree/tree-counter.js.map +0 -1
- package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js +0 -3
- package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js.map +0 -1
- package/dist/cjs/types/data-structures/graph/abstract-graph.js +0 -3
- package/dist/cjs/types/data-structures/graph/abstract-graph.js.map +0 -1
- package/dist/cjs/types/data-structures/graph/directed-graph.js +0 -3
- package/dist/cjs/types/data-structures/graph/directed-graph.js.map +0 -1
- package/dist/cjs/types/data-structures/graph/index.js +0 -20
- package/dist/cjs/types/data-structures/graph/index.js.map +0 -1
- package/dist/cjs/types/data-structures/graph/map-graph.js +0 -3
- package/dist/cjs/types/data-structures/graph/map-graph.js.map +0 -1
- package/dist/cjs/types/data-structures/graph/undirected-graph.js +0 -3
- package/dist/cjs/types/data-structures/graph/undirected-graph.js.map +0 -1
- package/dist/cjs/types/data-structures/hash/hash-map.js +0 -3
- package/dist/cjs/types/data-structures/hash/hash-map.js.map +0 -1
- package/dist/cjs/types/data-structures/hash/index.js +0 -18
- package/dist/cjs/types/data-structures/hash/index.js.map +0 -1
- package/dist/cjs/types/data-structures/heap/heap.js +0 -3
- package/dist/cjs/types/data-structures/heap/heap.js.map +0 -1
- package/dist/cjs/types/data-structures/heap/index.js +0 -18
- package/dist/cjs/types/data-structures/heap/index.js.map +0 -1
- package/dist/cjs/types/data-structures/heap/max-heap.js +0 -3
- package/dist/cjs/types/data-structures/heap/max-heap.js.map +0 -1
- package/dist/cjs/types/data-structures/heap/min-heap.js +0 -3
- package/dist/cjs/types/data-structures/heap/min-heap.js.map +0 -1
- package/dist/cjs/types/data-structures/index.js +0 -29
- package/dist/cjs/types/data-structures/index.js.map +0 -1
- package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.js +0 -3
- 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 +0 -20
- 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 +0 -3
- 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 +0 -3
- package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
- package/dist/cjs/types/data-structures/matrix/index.js +0 -19
- package/dist/cjs/types/data-structures/matrix/index.js.map +0 -1
- package/dist/cjs/types/data-structures/matrix/matrix.js +0 -3
- package/dist/cjs/types/data-structures/matrix/matrix.js.map +0 -1
- package/dist/cjs/types/data-structures/matrix/navigator.js +0 -3
- package/dist/cjs/types/data-structures/matrix/navigator.js.map +0 -1
- package/dist/cjs/types/data-structures/priority-queue/index.js +0 -20
- 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 +0 -3
- 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 +0 -3
- 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 +0 -3
- package/dist/cjs/types/data-structures/priority-queue/priority-queue.js.map +0 -1
- package/dist/cjs/types/data-structures/queue/deque.js +0 -3
- package/dist/cjs/types/data-structures/queue/deque.js.map +0 -1
- package/dist/cjs/types/data-structures/queue/index.js +0 -19
- package/dist/cjs/types/data-structures/queue/index.js.map +0 -1
- package/dist/cjs/types/data-structures/queue/queue.js +0 -3
- package/dist/cjs/types/data-structures/queue/queue.js.map +0 -1
- package/dist/cjs/types/data-structures/stack/index.js +0 -18
- package/dist/cjs/types/data-structures/stack/index.js.map +0 -1
- package/dist/cjs/types/data-structures/stack/stack.js +0 -3
- package/dist/cjs/types/data-structures/stack/stack.js.map +0 -1
- package/dist/cjs/types/data-structures/tree/index.js +0 -18
- package/dist/cjs/types/data-structures/tree/index.js.map +0 -1
- package/dist/cjs/types/data-structures/tree/tree.js +0 -3
- package/dist/cjs/types/data-structures/tree/tree.js.map +0 -1
- package/dist/cjs/types/data-structures/trie/index.js +0 -18
- package/dist/cjs/types/data-structures/trie/index.js.map +0 -1
- package/dist/cjs/types/data-structures/trie/trie.js +0 -3
- package/dist/cjs/types/data-structures/trie/trie.js.map +0 -1
- package/dist/cjs/types/index.js +0 -20
- package/dist/cjs/types/index.js.map +0 -1
- package/dist/cjs/types/utils/index.js +0 -19
- package/dist/cjs/types/utils/index.js.map +0 -1
- package/dist/cjs/types/utils/utils.js +0 -3
- package/dist/cjs/types/utils/utils.js.map +0 -1
- package/dist/cjs/types/utils/validate-type.js +0 -3
- package/dist/cjs/types/utils/validate-type.js.map +0 -1
- package/dist/cjs/utils/index.js +0 -19
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/number.js +0 -24
- package/dist/cjs/utils/number.js.map +0 -1
- package/dist/cjs/utils/utils.js +0 -354
- package/dist/cjs/utils/utils.js.map +0 -1
- package/dist/esm/common/index.d.ts +0 -12
- package/dist/esm/common/index.js +0 -29
- package/dist/esm/common/index.js.map +0 -1
- package/dist/esm/data-structures/base/index.d.ts +0 -2
- package/dist/esm/data-structures/base/index.js +0 -3
- package/dist/esm/data-structures/base/index.js.map +0 -1
- package/dist/esm/data-structures/base/iterable-element-base.d.ts +0 -219
- package/dist/esm/data-structures/base/iterable-element-base.js +0 -247
- package/dist/esm/data-structures/base/iterable-element-base.js.map +0 -1
- package/dist/esm/data-structures/base/iterable-entry-base.d.ts +0 -144
- package/dist/esm/data-structures/base/iterable-entry-base.js +0 -180
- package/dist/esm/data-structures/base/iterable-entry-base.js.map +0 -1
- package/dist/esm/data-structures/base/linear-base.d.ts +0 -335
- package/dist/esm/data-structures/base/linear-base.js +0 -412
- package/dist/esm/data-structures/base/linear-base.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/avl-tree-counter.d.ts +0 -182
- package/dist/esm/data-structures/binary-tree/avl-tree-counter.js +0 -369
- package/dist/esm/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +0 -244
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/avl-tree.js +0 -607
- package/dist/esm/data-structures/binary-tree/avl-tree.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -174
- package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js +0 -296
- package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/binary-tree.js +0 -1922
- package/dist/esm/data-structures/binary-tree/binary-tree.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/bst.js +0 -901
- package/dist/esm/data-structures/binary-tree/bst.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/index.d.ts +0 -10
- package/dist/esm/data-structures/binary-tree/index.js +0 -11
- package/dist/esm/data-structures/binary-tree/index.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/red-black-tree.js +0 -540
- package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/segment-tree.d.ts +0 -160
- package/dist/esm/data-structures/binary-tree/segment-tree.js +0 -295
- package/dist/esm/data-structures/binary-tree/segment-tree.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/tree-counter.d.ts +0 -190
- package/dist/esm/data-structures/binary-tree/tree-counter.js +0 -412
- package/dist/esm/data-structures/binary-tree/tree-counter.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +0 -270
- package/dist/esm/data-structures/binary-tree/tree-multi-map.js +0 -378
- package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +0 -1
- package/dist/esm/data-structures/graph/abstract-graph.d.ts +0 -340
- package/dist/esm/data-structures/graph/abstract-graph.js +0 -892
- package/dist/esm/data-structures/graph/abstract-graph.js.map +0 -1
- package/dist/esm/data-structures/graph/directed-graph.d.ts +0 -207
- package/dist/esm/data-structures/graph/directed-graph.js +0 -521
- package/dist/esm/data-structures/graph/directed-graph.js.map +0 -1
- package/dist/esm/data-structures/graph/index.d.ts +0 -4
- package/dist/esm/data-structures/graph/index.js +0 -5
- package/dist/esm/data-structures/graph/index.js.map +0 -1
- package/dist/esm/data-structures/graph/map-graph.d.ts +0 -78
- package/dist/esm/data-structures/graph/map-graph.js +0 -105
- package/dist/esm/data-structures/graph/map-graph.js.map +0 -1
- package/dist/esm/data-structures/graph/undirected-graph.d.ts +0 -188
- package/dist/esm/data-structures/graph/undirected-graph.js +0 -418
- package/dist/esm/data-structures/graph/undirected-graph.js.map +0 -1
- package/dist/esm/data-structures/hash/hash-map.d.ts +0 -345
- package/dist/esm/data-structures/hash/hash-map.js +0 -691
- package/dist/esm/data-structures/hash/hash-map.js.map +0 -1
- package/dist/esm/data-structures/hash/index.d.ts +0 -1
- package/dist/esm/data-structures/hash/index.js +0 -2
- package/dist/esm/data-structures/hash/index.js.map +0 -1
- package/dist/esm/data-structures/heap/heap.js +0 -894
- package/dist/esm/data-structures/heap/heap.js.map +0 -1
- package/dist/esm/data-structures/heap/index.d.ts +0 -3
- package/dist/esm/data-structures/heap/index.js +0 -4
- package/dist/esm/data-structures/heap/index.js.map +0 -1
- package/dist/esm/data-structures/heap/max-heap.d.ts +0 -32
- package/dist/esm/data-structures/heap/max-heap.js +0 -40
- package/dist/esm/data-structures/heap/max-heap.js.map +0 -1
- package/dist/esm/data-structures/heap/min-heap.d.ts +0 -33
- package/dist/esm/data-structures/heap/min-heap.js +0 -28
- package/dist/esm/data-structures/heap/min-heap.js.map +0 -1
- package/dist/esm/data-structures/index.d.ts +0 -12
- package/dist/esm/data-structures/index.js +0 -13
- package/dist/esm/data-structures/index.js.map +0 -1
- package/dist/esm/data-structures/linked-list/doubly-linked-list.d.ts +0 -769
- package/dist/esm/data-structures/linked-list/doubly-linked-list.js +0 -1109
- package/dist/esm/data-structures/linked-list/doubly-linked-list.js.map +0 -1
- package/dist/esm/data-structures/linked-list/index.d.ts +0 -3
- package/dist/esm/data-structures/linked-list/index.js +0 -4
- package/dist/esm/data-structures/linked-list/index.js.map +0 -1
- package/dist/esm/data-structures/linked-list/singly-linked-list.js +0 -847
- package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +0 -1
- package/dist/esm/data-structures/linked-list/skip-linked-list.d.ts +0 -27
- package/dist/esm/data-structures/linked-list/skip-linked-list.js +0 -143
- package/dist/esm/data-structures/linked-list/skip-linked-list.js.map +0 -1
- package/dist/esm/data-structures/matrix/index.d.ts +0 -2
- package/dist/esm/data-structures/matrix/index.js +0 -3
- package/dist/esm/data-structures/matrix/index.js.map +0 -1
- package/dist/esm/data-structures/matrix/matrix.d.ts +0 -168
- package/dist/esm/data-structures/matrix/matrix.js +0 -444
- package/dist/esm/data-structures/matrix/matrix.js.map +0 -1
- package/dist/esm/data-structures/matrix/navigator.d.ts +0 -55
- package/dist/esm/data-structures/matrix/navigator.js +0 -114
- package/dist/esm/data-structures/matrix/navigator.js.map +0 -1
- package/dist/esm/data-structures/priority-queue/index.d.ts +0 -3
- package/dist/esm/data-structures/priority-queue/index.js +0 -4
- package/dist/esm/data-structures/priority-queue/index.js.map +0 -1
- package/dist/esm/data-structures/priority-queue/max-priority-queue.d.ts +0 -27
- package/dist/esm/data-structures/priority-queue/max-priority-queue.js +0 -34
- package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +0 -1
- package/dist/esm/data-structures/priority-queue/min-priority-queue.d.ts +0 -26
- package/dist/esm/data-structures/priority-queue/min-priority-queue.js +0 -21
- package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +0 -1
- package/dist/esm/data-structures/priority-queue/priority-queue.d.ts +0 -15
- package/dist/esm/data-structures/priority-queue/priority-queue.js +0 -17
- package/dist/esm/data-structures/priority-queue/priority-queue.js.map +0 -1
- package/dist/esm/data-structures/queue/deque.d.ts +0 -431
- package/dist/esm/data-structures/queue/deque.js +0 -880
- package/dist/esm/data-structures/queue/deque.js.map +0 -1
- package/dist/esm/data-structures/queue/index.d.ts +0 -2
- package/dist/esm/data-structures/queue/index.js +0 -3
- package/dist/esm/data-structures/queue/index.js.map +0 -1
- package/dist/esm/data-structures/queue/queue.d.ts +0 -308
- package/dist/esm/data-structures/queue/queue.js +0 -467
- package/dist/esm/data-structures/queue/queue.js.map +0 -1
- package/dist/esm/data-structures/stack/index.d.ts +0 -1
- package/dist/esm/data-structures/stack/index.js +0 -2
- package/dist/esm/data-structures/stack/index.js.map +0 -1
- package/dist/esm/data-structures/stack/stack.d.ts +0 -306
- package/dist/esm/data-structures/stack/stack.js +0 -398
- package/dist/esm/data-structures/stack/stack.js.map +0 -1
- package/dist/esm/data-structures/tree/index.d.ts +0 -1
- package/dist/esm/data-structures/tree/index.js +0 -2
- package/dist/esm/data-structures/tree/index.js.map +0 -1
- package/dist/esm/data-structures/tree/tree.d.ts +0 -62
- package/dist/esm/data-structures/tree/tree.js +0 -107
- package/dist/esm/data-structures/tree/tree.js.map +0 -1
- package/dist/esm/data-structures/trie/index.d.ts +0 -1
- package/dist/esm/data-structures/trie/index.js +0 -2
- package/dist/esm/data-structures/trie/index.js.map +0 -1
- package/dist/esm/data-structures/trie/trie.d.ts +0 -350
- package/dist/esm/data-structures/trie/trie.js +0 -613
- package/dist/esm/data-structures/trie/trie.js.map +0 -1
- package/dist/esm/index.d.ts +0 -5
- package/dist/esm/index.js +0 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/interfaces/binary-tree.js +0 -2
- package/dist/esm/interfaces/binary-tree.js.map +0 -1
- package/dist/esm/interfaces/doubly-linked-list.d.ts +0 -1
- package/dist/esm/interfaces/doubly-linked-list.js +0 -2
- package/dist/esm/interfaces/doubly-linked-list.js.map +0 -1
- package/dist/esm/interfaces/graph.d.ts +0 -21
- package/dist/esm/interfaces/graph.js +0 -2
- package/dist/esm/interfaces/graph.js.map +0 -1
- package/dist/esm/interfaces/heap.d.ts +0 -1
- package/dist/esm/interfaces/heap.js +0 -2
- package/dist/esm/interfaces/heap.js.map +0 -1
- package/dist/esm/interfaces/index.d.ts +0 -8
- package/dist/esm/interfaces/index.js +0 -9
- package/dist/esm/interfaces/index.js.map +0 -1
- package/dist/esm/interfaces/navigator.d.ts +0 -1
- package/dist/esm/interfaces/navigator.js +0 -2
- package/dist/esm/interfaces/navigator.js.map +0 -1
- package/dist/esm/interfaces/priority-queue.d.ts +0 -1
- package/dist/esm/interfaces/priority-queue.js +0 -2
- package/dist/esm/interfaces/priority-queue.js.map +0 -1
- package/dist/esm/interfaces/segment-tree.d.ts +0 -1
- package/dist/esm/interfaces/segment-tree.js +0 -2
- package/dist/esm/interfaces/segment-tree.js.map +0 -1
- package/dist/esm/interfaces/singly-linked-list.d.ts +0 -1
- package/dist/esm/interfaces/singly-linked-list.js +0 -2
- package/dist/esm/interfaces/singly-linked-list.js.map +0 -1
- package/dist/esm/types/common.d.ts +0 -15
- package/dist/esm/types/common.js +0 -2
- package/dist/esm/types/common.js.map +0 -1
- package/dist/esm/types/data-structures/base/base.d.ts +0 -13
- package/dist/esm/types/data-structures/base/base.js +0 -2
- package/dist/esm/types/data-structures/base/base.js.map +0 -1
- package/dist/esm/types/data-structures/base/index.d.ts +0 -1
- package/dist/esm/types/data-structures/base/index.js +0 -2
- package/dist/esm/types/data-structures/base/index.js.map +0 -1
- package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -2
- package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js +0 -2
- package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
- package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -2
- package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -2
- package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
- package/dist/esm/types/data-structures/binary-tree/avl-tree.d.ts +0 -2
- package/dist/esm/types/data-structures/binary-tree/avl-tree.js +0 -2
- package/dist/esm/types/data-structures/binary-tree/avl-tree.js.map +0 -1
- package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -1
- package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
- package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
- package/dist/esm/types/data-structures/binary-tree/binary-tree.d.ts +0 -29
- package/dist/esm/types/data-structures/binary-tree/binary-tree.js +0 -2
- package/dist/esm/types/data-structures/binary-tree/binary-tree.js.map +0 -1
- package/dist/esm/types/data-structures/binary-tree/bst.d.ts +0 -12
- package/dist/esm/types/data-structures/binary-tree/bst.js +0 -2
- package/dist/esm/types/data-structures/binary-tree/bst.js.map +0 -1
- package/dist/esm/types/data-structures/binary-tree/index.d.ts +0 -9
- package/dist/esm/types/data-structures/binary-tree/index.js +0 -10
- package/dist/esm/types/data-structures/binary-tree/index.js.map +0 -1
- package/dist/esm/types/data-structures/binary-tree/red-black-tree.d.ts +0 -3
- package/dist/esm/types/data-structures/binary-tree/red-black-tree.js +0 -2
- package/dist/esm/types/data-structures/binary-tree/red-black-tree.js.map +0 -1
- package/dist/esm/types/data-structures/binary-tree/segment-tree.d.ts +0 -1
- package/dist/esm/types/data-structures/binary-tree/segment-tree.js +0 -2
- package/dist/esm/types/data-structures/binary-tree/segment-tree.js.map +0 -1
- package/dist/esm/types/data-structures/binary-tree/tree-counter.d.ts +0 -2
- package/dist/esm/types/data-structures/binary-tree/tree-counter.js +0 -2
- package/dist/esm/types/data-structures/binary-tree/tree-counter.js.map +0 -1
- package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -2
- package/dist/esm/types/data-structures/binary-tree/tree-multi-map.js +0 -2
- package/dist/esm/types/data-structures/binary-tree/tree-multi-map.js.map +0 -1
- package/dist/esm/types/data-structures/graph/abstract-graph.d.ts +0 -14
- package/dist/esm/types/data-structures/graph/abstract-graph.js +0 -2
- package/dist/esm/types/data-structures/graph/abstract-graph.js.map +0 -1
- package/dist/esm/types/data-structures/graph/directed-graph.d.ts +0 -1
- package/dist/esm/types/data-structures/graph/directed-graph.js +0 -2
- package/dist/esm/types/data-structures/graph/directed-graph.js.map +0 -1
- package/dist/esm/types/data-structures/graph/index.d.ts +0 -3
- package/dist/esm/types/data-structures/graph/index.js +0 -4
- package/dist/esm/types/data-structures/graph/index.js.map +0 -1
- package/dist/esm/types/data-structures/graph/map-graph.d.ts +0 -1
- package/dist/esm/types/data-structures/graph/map-graph.js +0 -2
- package/dist/esm/types/data-structures/graph/map-graph.js.map +0 -1
- package/dist/esm/types/data-structures/graph/undirected-graph.d.ts +0 -1
- package/dist/esm/types/data-structures/graph/undirected-graph.js +0 -2
- package/dist/esm/types/data-structures/graph/undirected-graph.js.map +0 -1
- package/dist/esm/types/data-structures/hash/hash-map.d.ts +0 -19
- package/dist/esm/types/data-structures/hash/hash-map.js +0 -2
- package/dist/esm/types/data-structures/hash/hash-map.js.map +0 -1
- package/dist/esm/types/data-structures/hash/index.d.ts +0 -2
- package/dist/esm/types/data-structures/hash/index.js +0 -2
- package/dist/esm/types/data-structures/hash/index.js.map +0 -1
- package/dist/esm/types/data-structures/heap/heap.d.ts +0 -5
- package/dist/esm/types/data-structures/heap/heap.js +0 -2
- package/dist/esm/types/data-structures/heap/heap.js.map +0 -1
- package/dist/esm/types/data-structures/heap/index.d.ts +0 -1
- package/dist/esm/types/data-structures/heap/index.js +0 -2
- package/dist/esm/types/data-structures/heap/index.js.map +0 -1
- package/dist/esm/types/data-structures/heap/max-heap.d.ts +0 -1
- package/dist/esm/types/data-structures/heap/max-heap.js +0 -2
- package/dist/esm/types/data-structures/heap/max-heap.js.map +0 -1
- package/dist/esm/types/data-structures/heap/min-heap.d.ts +0 -1
- package/dist/esm/types/data-structures/heap/min-heap.js +0 -2
- package/dist/esm/types/data-structures/heap/min-heap.js.map +0 -1
- package/dist/esm/types/data-structures/index.d.ts +0 -12
- package/dist/esm/types/data-structures/index.js +0 -13
- package/dist/esm/types/data-structures/index.js.map +0 -1
- package/dist/esm/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -2
- package/dist/esm/types/data-structures/linked-list/doubly-linked-list.js +0 -2
- package/dist/esm/types/data-structures/linked-list/doubly-linked-list.js.map +0 -1
- package/dist/esm/types/data-structures/linked-list/index.d.ts +0 -3
- package/dist/esm/types/data-structures/linked-list/index.js +0 -4
- package/dist/esm/types/data-structures/linked-list/index.js.map +0 -1
- package/dist/esm/types/data-structures/linked-list/singly-linked-list.d.ts +0 -2
- package/dist/esm/types/data-structures/linked-list/singly-linked-list.js +0 -2
- package/dist/esm/types/data-structures/linked-list/singly-linked-list.js.map +0 -1
- package/dist/esm/types/data-structures/linked-list/skip-linked-list.d.ts +0 -4
- package/dist/esm/types/data-structures/linked-list/skip-linked-list.js +0 -2
- package/dist/esm/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
- package/dist/esm/types/data-structures/matrix/index.d.ts +0 -2
- package/dist/esm/types/data-structures/matrix/index.js +0 -3
- package/dist/esm/types/data-structures/matrix/index.js.map +0 -1
- package/dist/esm/types/data-structures/matrix/matrix.d.ts +0 -7
- package/dist/esm/types/data-structures/matrix/matrix.js +0 -2
- package/dist/esm/types/data-structures/matrix/matrix.js.map +0 -1
- package/dist/esm/types/data-structures/matrix/navigator.d.ts +0 -14
- package/dist/esm/types/data-structures/matrix/navigator.js +0 -2
- package/dist/esm/types/data-structures/matrix/navigator.js.map +0 -1
- package/dist/esm/types/data-structures/priority-queue/index.d.ts +0 -3
- package/dist/esm/types/data-structures/priority-queue/index.js +0 -4
- package/dist/esm/types/data-structures/priority-queue/index.js.map +0 -1
- package/dist/esm/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -1
- package/dist/esm/types/data-structures/priority-queue/max-priority-queue.js +0 -2
- package/dist/esm/types/data-structures/priority-queue/max-priority-queue.js.map +0 -1
- package/dist/esm/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -1
- package/dist/esm/types/data-structures/priority-queue/min-priority-queue.js +0 -2
- package/dist/esm/types/data-structures/priority-queue/min-priority-queue.js.map +0 -1
- package/dist/esm/types/data-structures/priority-queue/priority-queue.d.ts +0 -2
- package/dist/esm/types/data-structures/priority-queue/priority-queue.js +0 -2
- package/dist/esm/types/data-structures/priority-queue/priority-queue.js.map +0 -1
- package/dist/esm/types/data-structures/queue/deque.d.ts +0 -4
- package/dist/esm/types/data-structures/queue/deque.js +0 -2
- package/dist/esm/types/data-structures/queue/deque.js.map +0 -1
- package/dist/esm/types/data-structures/queue/index.d.ts +0 -2
- package/dist/esm/types/data-structures/queue/index.js +0 -3
- package/dist/esm/types/data-structures/queue/index.js.map +0 -1
- package/dist/esm/types/data-structures/queue/queue.d.ts +0 -4
- package/dist/esm/types/data-structures/queue/queue.js +0 -2
- package/dist/esm/types/data-structures/queue/queue.js.map +0 -1
- package/dist/esm/types/data-structures/stack/index.d.ts +0 -1
- package/dist/esm/types/data-structures/stack/index.js +0 -2
- package/dist/esm/types/data-structures/stack/index.js.map +0 -1
- package/dist/esm/types/data-structures/stack/stack.d.ts +0 -2
- package/dist/esm/types/data-structures/stack/stack.js +0 -2
- package/dist/esm/types/data-structures/stack/stack.js.map +0 -1
- package/dist/esm/types/data-structures/tree/index.d.ts +0 -1
- package/dist/esm/types/data-structures/tree/index.js +0 -2
- package/dist/esm/types/data-structures/tree/index.js.map +0 -1
- package/dist/esm/types/data-structures/tree/tree.d.ts +0 -1
- package/dist/esm/types/data-structures/tree/tree.js +0 -2
- package/dist/esm/types/data-structures/tree/tree.js.map +0 -1
- package/dist/esm/types/data-structures/trie/index.d.ts +0 -1
- package/dist/esm/types/data-structures/trie/index.js +0 -2
- package/dist/esm/types/data-structures/trie/index.js.map +0 -1
- package/dist/esm/types/data-structures/trie/trie.d.ts +0 -4
- package/dist/esm/types/data-structures/trie/trie.js +0 -2
- package/dist/esm/types/data-structures/trie/trie.js.map +0 -1
- package/dist/esm/types/index.d.ts +0 -3
- package/dist/esm/types/index.js +0 -4
- package/dist/esm/types/index.js.map +0 -1
- package/dist/esm/types/utils/index.d.ts +0 -2
- package/dist/esm/types/utils/index.js +0 -3
- package/dist/esm/types/utils/index.js.map +0 -1
- package/dist/esm/types/utils/utils.d.ts +0 -22
- package/dist/esm/types/utils/utils.js +0 -2
- package/dist/esm/types/utils/utils.js.map +0 -1
- package/dist/esm/types/utils/validate-type.d.ts +0 -19
- package/dist/esm/types/utils/validate-type.js +0 -2
- package/dist/esm/types/utils/validate-type.js.map +0 -1
- package/dist/esm/utils/index.d.ts +0 -2
- package/dist/esm/utils/index.js +0 -3
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/esm/utils/number.d.ts +0 -14
- package/dist/esm/utils/number.js +0 -21
- package/dist/esm/utils/number.js.map +0 -1
- package/dist/esm/utils/utils.d.ts +0 -209
- package/dist/esm/utils/utils.js +0 -325
- package/dist/esm/utils/utils.js.map +0 -1
- package/test/integration/compile.js +0 -144
- package/test/integration/compile.mjs +0 -135
- package/test/integration/compile.ts +0 -171
- package/tsconfig-base.json +0 -24
- package/tsconfig-cjs.json +0 -14
- package/tsconfig-esm.json +0 -14
- /package/dist/{cjs → types}/common/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/base/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/base/iterable-element-base.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/base/iterable-entry-base.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/base/linear-base.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/binary-tree/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/binary-tree/segment-tree.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/graph/abstract-graph.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/graph/directed-graph.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/graph/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/graph/map-graph.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/graph/undirected-graph.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/hash/hash-map.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/hash/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/heap/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/heap/max-heap.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/heap/min-heap.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/linked-list/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/linked-list/skip-linked-list.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/matrix/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/matrix/matrix.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/matrix/navigator.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/priority-queue/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/priority-queue/priority-queue.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/queue/deque.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/queue/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/queue/queue.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/stack/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/stack/stack.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/tree/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/tree/tree.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/trie/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/trie/trie.d.ts +0 -0
- /package/dist/{cjs → types}/index.d.ts +0 -0
- /package/dist/{cjs → types}/interfaces/doubly-linked-list.d.ts +0 -0
- /package/dist/{cjs → types}/interfaces/graph.d.ts +0 -0
- /package/dist/{cjs → types}/interfaces/heap.d.ts +0 -0
- /package/dist/{cjs → types}/interfaces/index.d.ts +0 -0
- /package/dist/{cjs → types}/interfaces/navigator.d.ts +0 -0
- /package/dist/{cjs → types}/interfaces/priority-queue.d.ts +0 -0
- /package/dist/{cjs → types}/interfaces/segment-tree.d.ts +0 -0
- /package/dist/{cjs → types}/interfaces/singly-linked-list.d.ts +0 -0
- /package/dist/{cjs → types}/types/common.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/base/base.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/base/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/binary-tree/binary-tree.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/binary-tree/bst.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/binary-tree/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/binary-tree/red-black-tree.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/binary-tree/segment-tree.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/binary-tree/tree-counter.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/graph/abstract-graph.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/graph/directed-graph.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/graph/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/graph/map-graph.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/graph/undirected-graph.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/hash/hash-map.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/hash/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/heap/heap.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/heap/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/heap/max-heap.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/heap/min-heap.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/linked-list/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/linked-list/singly-linked-list.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/linked-list/skip-linked-list.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/matrix/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/matrix/matrix.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/matrix/navigator.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/priority-queue/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/priority-queue/priority-queue.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/queue/deque.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/queue/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/queue/queue.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/stack/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/stack/stack.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/tree/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/tree/tree.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/trie/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/data-structures/trie/trie.d.ts +0 -0
- /package/dist/{cjs → types}/types/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/utils/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/utils/utils.d.ts +0 -0
- /package/dist/{cjs → types}/types/utils/validate-type.d.ts +0 -0
- /package/dist/{cjs → types}/utils/index.d.ts +0 -0
- /package/dist/{cjs → types}/utils/number.d.ts +0 -0
- /package/dist/{cjs → types}/utils/utils.d.ts +0 -0
|
@@ -1,691 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* data-structure-typed
|
|
3
|
-
*
|
|
4
|
-
* @author Pablo Zeng
|
|
5
|
-
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
|
-
* @license MIT License
|
|
7
|
-
*/
|
|
8
|
-
import { IterableEntryBase } from '../base';
|
|
9
|
-
import { isWeakKey, rangeCheck } from '../../utils';
|
|
10
|
-
/**
|
|
11
|
-
* Hash-based map. Supports object keys and custom hashing; offers O(1) average set/get/has.
|
|
12
|
-
* @remarks Time O(1), Space O(1)
|
|
13
|
-
* @template K
|
|
14
|
-
* @template V
|
|
15
|
-
* @template R
|
|
16
|
-
* 1. Key-Value Pair Storage: HashMap stores key-value pairs. Each key map to a value.
|
|
17
|
-
* 2. Fast Lookup: It's used when you need to quickly find, insert, or delete entries based on a key.
|
|
18
|
-
* 3. Unique Keys: Keys are unique.
|
|
19
|
-
* If you try to insert another entry with the same key, the new one will replace the old entry.
|
|
20
|
-
* 4. Unordered Collection: HashMap does not guarantee the order of entries, and the order may change over time.
|
|
21
|
-
* @example
|
|
22
|
-
* // should maintain insertion order
|
|
23
|
-
* const linkedHashMap = new LinkedHashMap<number, string>();
|
|
24
|
-
* linkedHashMap.set(1, 'A');
|
|
25
|
-
* linkedHashMap.set(2, 'B');
|
|
26
|
-
* linkedHashMap.set(3, 'C');
|
|
27
|
-
*
|
|
28
|
-
* const result = Array.from(linkedHashMap);
|
|
29
|
-
* console.log(result); // [
|
|
30
|
-
* // [1, 'A'],
|
|
31
|
-
* // [2, 'B'],
|
|
32
|
-
* // [3, 'C']
|
|
33
|
-
* // ]
|
|
34
|
-
* @example
|
|
35
|
-
* // fast lookup of values by key
|
|
36
|
-
* const hashMap = new HashMap<number, string>();
|
|
37
|
-
* hashMap.set(1, 'A');
|
|
38
|
-
* hashMap.set(2, 'B');
|
|
39
|
-
* hashMap.set(3, 'C');
|
|
40
|
-
*
|
|
41
|
-
* console.log(hashMap.get(1)); // 'A'
|
|
42
|
-
* console.log(hashMap.get(2)); // 'B'
|
|
43
|
-
* console.log(hashMap.get(3)); // 'C'
|
|
44
|
-
* console.log(hashMap.get(99)); // undefined
|
|
45
|
-
* @example
|
|
46
|
-
* // remove duplicates when adding multiple entries
|
|
47
|
-
* const hashMap = new HashMap<number, string>();
|
|
48
|
-
* hashMap.set(1, 'A');
|
|
49
|
-
* hashMap.set(2, 'B');
|
|
50
|
-
* hashMap.set(1, 'C'); // Update value for key 1
|
|
51
|
-
*
|
|
52
|
-
* console.log(hashMap.size); // 2
|
|
53
|
-
* console.log(hashMap.get(1)); // 'C'
|
|
54
|
-
* console.log(hashMap.get(2)); // 'B'
|
|
55
|
-
* @example
|
|
56
|
-
* // count occurrences of keys
|
|
57
|
-
* const data = [1, 2, 1, 3, 2, 1];
|
|
58
|
-
*
|
|
59
|
-
* const countMap = new HashMap<number, number>();
|
|
60
|
-
* for (const key of data) {
|
|
61
|
-
* countMap.set(key, (countMap.get(key) || 0) + 1);
|
|
62
|
-
* }
|
|
63
|
-
*
|
|
64
|
-
* console.log(countMap.get(1)); // 3
|
|
65
|
-
* console.log(countMap.get(2)); // 2
|
|
66
|
-
* console.log(countMap.get(3)); // 1
|
|
67
|
-
*/
|
|
68
|
-
export class HashMap extends IterableEntryBase {
|
|
69
|
-
/**
|
|
70
|
-
* Create a HashMap and optionally bulk-insert entries.
|
|
71
|
-
* @remarks Time O(N), Space O(N)
|
|
72
|
-
* @param [entryOrRawElements] - Iterable of entries or raw elements to insert.
|
|
73
|
-
* @param [options] - Options: hash function and optional record-to-entry converter.
|
|
74
|
-
* @returns New HashMap instance.
|
|
75
|
-
*/
|
|
76
|
-
constructor(entryOrRawElements = [], options) {
|
|
77
|
-
super();
|
|
78
|
-
if (options) {
|
|
79
|
-
const { hashFn, toEntryFn } = options;
|
|
80
|
-
if (hashFn)
|
|
81
|
-
this._hashFn = hashFn;
|
|
82
|
-
if (toEntryFn)
|
|
83
|
-
this._toEntryFn = toEntryFn;
|
|
84
|
-
}
|
|
85
|
-
if (entryOrRawElements)
|
|
86
|
-
this.setMany(entryOrRawElements);
|
|
87
|
-
}
|
|
88
|
-
_store = {};
|
|
89
|
-
/**
|
|
90
|
-
* Get the internal store for non-object keys.
|
|
91
|
-
* @remarks Time O(1), Space O(1)
|
|
92
|
-
* @returns Internal record of string→{key,value}.
|
|
93
|
-
*/
|
|
94
|
-
get store() {
|
|
95
|
-
return this._store;
|
|
96
|
-
}
|
|
97
|
-
_objMap = new Map();
|
|
98
|
-
/**
|
|
99
|
-
* Get the internal Map used for object/function keys.
|
|
100
|
-
* @remarks Time O(1), Space O(1)
|
|
101
|
-
* @returns Map of object→value.
|
|
102
|
-
*/
|
|
103
|
-
get objMap() {
|
|
104
|
-
return this._objMap;
|
|
105
|
-
}
|
|
106
|
-
_toEntryFn;
|
|
107
|
-
/**
|
|
108
|
-
* Get the raw→entry converter function if present.
|
|
109
|
-
* @remarks Time O(1), Space O(1)
|
|
110
|
-
* @returns Converter function or undefined.
|
|
111
|
-
*/
|
|
112
|
-
get toEntryFn() {
|
|
113
|
-
return this._toEntryFn;
|
|
114
|
-
}
|
|
115
|
-
_size = 0;
|
|
116
|
-
/**
|
|
117
|
-
* Get the number of distinct keys stored.
|
|
118
|
-
* @remarks Time O(1), Space O(1)
|
|
119
|
-
* @returns Current size.
|
|
120
|
-
*/
|
|
121
|
-
get size() {
|
|
122
|
-
return this._size;
|
|
123
|
-
}
|
|
124
|
-
_hashFn = (key) => String(key);
|
|
125
|
-
/**
|
|
126
|
-
* Get the current hash function for non-object keys.
|
|
127
|
-
* @remarks Time O(1), Space O(1)
|
|
128
|
-
* @returns Hash function.
|
|
129
|
-
*/
|
|
130
|
-
get hashFn() {
|
|
131
|
-
return this._hashFn;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Check whether the map is empty.
|
|
135
|
-
* @remarks Time O(1), Space O(1)
|
|
136
|
-
* @returns True if size is 0.
|
|
137
|
-
*/
|
|
138
|
-
isEmpty() {
|
|
139
|
-
return this._size === 0;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Remove all entries and reset counters.
|
|
143
|
-
* @remarks Time O(N), Space O(1)
|
|
144
|
-
* @returns void
|
|
145
|
-
*/
|
|
146
|
-
clear() {
|
|
147
|
-
this._store = {};
|
|
148
|
-
this._objMap.clear();
|
|
149
|
-
this._size = 0;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Type guard: check if a raw value is a [key, value] entry.
|
|
153
|
-
* @remarks Time O(1), Space O(1)
|
|
154
|
-
* @returns True if the value is a 2-tuple.
|
|
155
|
-
*/
|
|
156
|
-
isEntry(rawElement) {
|
|
157
|
-
return Array.isArray(rawElement) && rawElement.length === 2;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Insert or replace a single entry.
|
|
161
|
-
* @remarks Time O(1), Space O(1)
|
|
162
|
-
* @param key - Key.
|
|
163
|
-
* @param value - Value.
|
|
164
|
-
* @returns True when the operation succeeds.
|
|
165
|
-
*/
|
|
166
|
-
set(key, value) {
|
|
167
|
-
if (this._isObjKey(key)) {
|
|
168
|
-
if (!this.objMap.has(key))
|
|
169
|
-
this._size++;
|
|
170
|
-
this.objMap.set(key, value);
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
const strKey = this._getNoObjKey(key);
|
|
174
|
-
if (this.store[strKey] === undefined)
|
|
175
|
-
this._size++;
|
|
176
|
-
this._store[strKey] = { key, value };
|
|
177
|
-
}
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Insert many entries from an iterable.
|
|
182
|
-
* @remarks Time O(N), Space O(N)
|
|
183
|
-
* @param entryOrRawElements - Iterable of entries or raw elements to insert.
|
|
184
|
-
* @returns Array of per-entry results.
|
|
185
|
-
*/
|
|
186
|
-
setMany(entryOrRawElements) {
|
|
187
|
-
const results = [];
|
|
188
|
-
for (const rawEle of entryOrRawElements) {
|
|
189
|
-
let key, value;
|
|
190
|
-
if (this.isEntry(rawEle))
|
|
191
|
-
[key, value] = rawEle;
|
|
192
|
-
else if (this._toEntryFn)
|
|
193
|
-
[key, value] = this._toEntryFn(rawEle);
|
|
194
|
-
if (key !== undefined && value !== undefined)
|
|
195
|
-
results.push(this.set(key, value));
|
|
196
|
-
}
|
|
197
|
-
return results;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Get the value for a key.
|
|
201
|
-
* @remarks Time O(1), Space O(1)
|
|
202
|
-
* @param key - Key to look up.
|
|
203
|
-
* @returns Value or undefined.
|
|
204
|
-
*/
|
|
205
|
-
get(key) {
|
|
206
|
-
if (this._isObjKey(key))
|
|
207
|
-
return this.objMap.get(key);
|
|
208
|
-
const strKey = this._getNoObjKey(key);
|
|
209
|
-
return this._store[strKey]?.value;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Check if a key exists.
|
|
213
|
-
* @remarks Time O(1), Space O(1)
|
|
214
|
-
* @param key - Key to test.
|
|
215
|
-
* @returns True if present.
|
|
216
|
-
*/
|
|
217
|
-
has(key) {
|
|
218
|
-
if (this._isObjKey(key))
|
|
219
|
-
return this.objMap.has(key);
|
|
220
|
-
const strKey = this._getNoObjKey(key);
|
|
221
|
-
return strKey in this.store;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Delete an entry by key.
|
|
225
|
-
* @remarks Time O(1), Space O(1)
|
|
226
|
-
* @param key - Key to delete.
|
|
227
|
-
* @returns True if the key was found and removed.
|
|
228
|
-
*/
|
|
229
|
-
delete(key) {
|
|
230
|
-
if (this._isObjKey(key)) {
|
|
231
|
-
if (this.objMap.has(key))
|
|
232
|
-
this._size--;
|
|
233
|
-
return this.objMap.delete(key);
|
|
234
|
-
}
|
|
235
|
-
const strKey = this._getNoObjKey(key);
|
|
236
|
-
if (strKey in this.store) {
|
|
237
|
-
delete this.store[strKey];
|
|
238
|
-
this._size--;
|
|
239
|
-
return true;
|
|
240
|
-
}
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Replace the hash function and rehash the non-object store.
|
|
245
|
-
* @remarks Time O(N), Space O(N)
|
|
246
|
-
* @param fn - New hash function for non-object keys.
|
|
247
|
-
* @returns This map instance.
|
|
248
|
-
*/
|
|
249
|
-
setHashFn(fn) {
|
|
250
|
-
if (this._hashFn === fn)
|
|
251
|
-
return this;
|
|
252
|
-
this._hashFn = fn;
|
|
253
|
-
this._rehashNoObj();
|
|
254
|
-
return this;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Deep clone this map, preserving hashing behavior.
|
|
258
|
-
* @remarks Time O(N), Space O(N)
|
|
259
|
-
* @returns A new map with the same content.
|
|
260
|
-
*/
|
|
261
|
-
clone() {
|
|
262
|
-
const opts = { hashFn: this._hashFn, toEntryFn: this._toEntryFn };
|
|
263
|
-
return this._createLike(this, opts);
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Map values to a new map with the same keys.
|
|
267
|
-
* @remarks Time O(N), Space O(N)
|
|
268
|
-
* @template VM
|
|
269
|
-
* @param callbackfn - Mapping function (key, value, index, map) → newValue.
|
|
270
|
-
* @param [thisArg] - Value for `this` inside the callback.
|
|
271
|
-
* @returns A new map with transformed values.
|
|
272
|
-
*/
|
|
273
|
-
map(callbackfn, thisArg) {
|
|
274
|
-
const out = this._createLike();
|
|
275
|
-
let index = 0;
|
|
276
|
-
for (const [key, value] of this)
|
|
277
|
-
out.set(key, callbackfn.call(thisArg, key, value, index++, this));
|
|
278
|
-
return out;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Filter entries into a new map.
|
|
282
|
-
* @remarks Time O(N), Space O(N)
|
|
283
|
-
* @param predicate - Predicate (key, value, index, map) → boolean.
|
|
284
|
-
* @param [thisArg] - Value for `this` inside the predicate.
|
|
285
|
-
* @returns A new map containing entries that satisfied the predicate.
|
|
286
|
-
*/
|
|
287
|
-
filter(predicate, thisArg) {
|
|
288
|
-
const out = this._createLike();
|
|
289
|
-
let index = 0;
|
|
290
|
-
for (const [key, value] of this)
|
|
291
|
-
if (predicate.call(thisArg, key, value, index++, this))
|
|
292
|
-
out.set(key, value);
|
|
293
|
-
return out;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* (Protected) Create a like-kind instance and seed it from an iterable.
|
|
297
|
-
* @remarks Time O(N), Space O(N)
|
|
298
|
-
* @template TK
|
|
299
|
-
* @template TV
|
|
300
|
-
* @template TR
|
|
301
|
-
* @param [entries] - Iterable used to seed the new map.
|
|
302
|
-
* @param [options] - Options forwarded to the constructor.
|
|
303
|
-
* @returns A like-kind map instance.
|
|
304
|
-
*/
|
|
305
|
-
_createLike(entries = [], options) {
|
|
306
|
-
const Ctor = this.constructor;
|
|
307
|
-
return new Ctor(entries, options);
|
|
308
|
-
}
|
|
309
|
-
_rehashNoObj() {
|
|
310
|
-
const fresh = {};
|
|
311
|
-
for (const { key, value } of Object.values(this._store)) {
|
|
312
|
-
const sk = this._getNoObjKey(key);
|
|
313
|
-
fresh[sk] = { key, value };
|
|
314
|
-
}
|
|
315
|
-
this._store = fresh;
|
|
316
|
-
}
|
|
317
|
-
*_getIterator() {
|
|
318
|
-
for (const node of Object.values(this.store))
|
|
319
|
-
yield [node.key, node.value];
|
|
320
|
-
for (const node of this.objMap)
|
|
321
|
-
yield node;
|
|
322
|
-
}
|
|
323
|
-
_isObjKey(key) {
|
|
324
|
-
const keyType = typeof key;
|
|
325
|
-
return (keyType === 'object' || keyType === 'function') && key !== null;
|
|
326
|
-
}
|
|
327
|
-
_getNoObjKey(key) {
|
|
328
|
-
const keyType = typeof key;
|
|
329
|
-
let strKey;
|
|
330
|
-
if (keyType !== 'string' && keyType !== 'number' && keyType !== 'symbol') {
|
|
331
|
-
strKey = this._hashFn(key);
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
if (keyType === 'number') {
|
|
335
|
-
strKey = key;
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
strKey = key;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
return strKey;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Hash-based map that preserves insertion order via a doubly-linked list.
|
|
346
|
-
* @remarks Time O(1), Space O(1)
|
|
347
|
-
* @template K
|
|
348
|
-
* @template V
|
|
349
|
-
* @template R
|
|
350
|
-
* @example examples will be generated by unit test
|
|
351
|
-
*/
|
|
352
|
-
export class LinkedHashMap extends IterableEntryBase {
|
|
353
|
-
_sentinel;
|
|
354
|
-
/**
|
|
355
|
-
* Create a LinkedHashMap and optionally bulk-insert entries.
|
|
356
|
-
* @remarks Time O(N), Space O(N)
|
|
357
|
-
* @param [entryOrRawElements] - Iterable of entries or raw elements to insert.
|
|
358
|
-
* @param [options] - Options: hash functions and optional record-to-entry converter.
|
|
359
|
-
* @returns New LinkedHashMap instance.
|
|
360
|
-
*/
|
|
361
|
-
constructor(entryOrRawElements = [], options) {
|
|
362
|
-
super();
|
|
363
|
-
this._sentinel = {};
|
|
364
|
-
this._sentinel.prev = this._sentinel.next = this._head = this._tail = this._sentinel;
|
|
365
|
-
if (options) {
|
|
366
|
-
const { hashFn, objHashFn, toEntryFn } = options;
|
|
367
|
-
if (hashFn)
|
|
368
|
-
this._hashFn = hashFn;
|
|
369
|
-
if (objHashFn)
|
|
370
|
-
this._objHashFn = objHashFn;
|
|
371
|
-
if (toEntryFn)
|
|
372
|
-
this._toEntryFn = toEntryFn;
|
|
373
|
-
}
|
|
374
|
-
if (entryOrRawElements)
|
|
375
|
-
this.setMany(entryOrRawElements);
|
|
376
|
-
}
|
|
377
|
-
_hashFn = (key) => String(key);
|
|
378
|
-
get hashFn() {
|
|
379
|
-
return this._hashFn;
|
|
380
|
-
}
|
|
381
|
-
_objHashFn = (key) => key;
|
|
382
|
-
/**
|
|
383
|
-
* Get the hash function for object/weak keys.
|
|
384
|
-
* @remarks Time O(1), Space O(1)
|
|
385
|
-
* @returns Object-hash function.
|
|
386
|
-
*/
|
|
387
|
-
get objHashFn() {
|
|
388
|
-
return this._objHashFn;
|
|
389
|
-
}
|
|
390
|
-
_noObjMap = {};
|
|
391
|
-
/**
|
|
392
|
-
* Get the internal record for non-object keys.
|
|
393
|
-
* @remarks Time O(1), Space O(1)
|
|
394
|
-
* @returns Record of hash→node.
|
|
395
|
-
*/
|
|
396
|
-
get noObjMap() {
|
|
397
|
-
return this._noObjMap;
|
|
398
|
-
}
|
|
399
|
-
_objMap = new WeakMap();
|
|
400
|
-
get objMap() {
|
|
401
|
-
return this._objMap;
|
|
402
|
-
}
|
|
403
|
-
_head;
|
|
404
|
-
/**
|
|
405
|
-
* Get the head node (first entry) sentinel link.
|
|
406
|
-
* @remarks Time O(1), Space O(1)
|
|
407
|
-
* @returns Head node or sentinel.
|
|
408
|
-
*/
|
|
409
|
-
get head() {
|
|
410
|
-
return this._head;
|
|
411
|
-
}
|
|
412
|
-
_tail;
|
|
413
|
-
/**
|
|
414
|
-
* Get the tail node (last entry) sentinel link.
|
|
415
|
-
* @remarks Time O(1), Space O(1)
|
|
416
|
-
* @returns Tail node or sentinel.
|
|
417
|
-
*/
|
|
418
|
-
get tail() {
|
|
419
|
-
return this._tail;
|
|
420
|
-
}
|
|
421
|
-
_toEntryFn = (rawElement) => {
|
|
422
|
-
if (this.isEntry(rawElement)) {
|
|
423
|
-
return rawElement;
|
|
424
|
-
}
|
|
425
|
-
throw new Error('If `entryOrRawElements` does not adhere to [key,value], provide `options.toEntryFn` to transform raw records.');
|
|
426
|
-
};
|
|
427
|
-
get toEntryFn() {
|
|
428
|
-
return this._toEntryFn;
|
|
429
|
-
}
|
|
430
|
-
_size = 0;
|
|
431
|
-
get size() {
|
|
432
|
-
return this._size;
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Get the first [key, value] pair.
|
|
436
|
-
* @remarks Time O(1), Space O(1)
|
|
437
|
-
* @returns First entry or undefined when empty.
|
|
438
|
-
*/
|
|
439
|
-
get first() {
|
|
440
|
-
if (this._size === 0)
|
|
441
|
-
return;
|
|
442
|
-
return [this.head.key, this.head.value];
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Get the last [key, value] pair.
|
|
446
|
-
* @remarks Time O(1), Space O(1)
|
|
447
|
-
* @returns Last entry or undefined when empty.
|
|
448
|
-
*/
|
|
449
|
-
get last() {
|
|
450
|
-
if (this._size === 0)
|
|
451
|
-
return;
|
|
452
|
-
return [this.tail.key, this.tail.value];
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* Iterate from head → tail.
|
|
456
|
-
* @remarks Time O(N), Space O(1)
|
|
457
|
-
* @returns Iterator of [key, value].
|
|
458
|
-
*/
|
|
459
|
-
*begin() {
|
|
460
|
-
let node = this.head;
|
|
461
|
-
while (node !== this._sentinel) {
|
|
462
|
-
yield [node.key, node.value];
|
|
463
|
-
node = node.next;
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Iterate from tail → head.
|
|
468
|
-
* @remarks Time O(N), Space O(1)
|
|
469
|
-
* @returns Iterator of [key, value].
|
|
470
|
-
*/
|
|
471
|
-
*reverseBegin() {
|
|
472
|
-
let node = this.tail;
|
|
473
|
-
while (node !== this._sentinel) {
|
|
474
|
-
yield [node.key, node.value];
|
|
475
|
-
node = node.prev;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Insert or replace a single entry; preserves insertion order.
|
|
480
|
-
* @remarks Time O(1), Space O(1)
|
|
481
|
-
* @param key - Key.
|
|
482
|
-
* @param [value] - Value.
|
|
483
|
-
* @returns True when the operation succeeds.
|
|
484
|
-
*/
|
|
485
|
-
set(key, value) {
|
|
486
|
-
let node;
|
|
487
|
-
const isNewKey = !this.has(key);
|
|
488
|
-
if (isWeakKey(key)) {
|
|
489
|
-
const hash = this._objHashFn(key);
|
|
490
|
-
node = this.objMap.get(hash);
|
|
491
|
-
if (!node && isNewKey) {
|
|
492
|
-
node = { key: hash, value, prev: this.tail, next: this._sentinel };
|
|
493
|
-
this.objMap.set(hash, node);
|
|
494
|
-
}
|
|
495
|
-
else if (node) {
|
|
496
|
-
node.value = value;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
else {
|
|
500
|
-
const hash = this._hashFn(key);
|
|
501
|
-
node = this.noObjMap[hash];
|
|
502
|
-
if (!node && isNewKey) {
|
|
503
|
-
this.noObjMap[hash] = node = { key, value, prev: this.tail, next: this._sentinel };
|
|
504
|
-
}
|
|
505
|
-
else if (node) {
|
|
506
|
-
node.value = value;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
if (node && isNewKey) {
|
|
510
|
-
if (this._size === 0) {
|
|
511
|
-
this._head = node;
|
|
512
|
-
this._sentinel.next = node;
|
|
513
|
-
}
|
|
514
|
-
else {
|
|
515
|
-
this.tail.next = node;
|
|
516
|
-
node.prev = this.tail;
|
|
517
|
-
}
|
|
518
|
-
this._tail = node;
|
|
519
|
-
this._sentinel.prev = node;
|
|
520
|
-
this._size++;
|
|
521
|
-
}
|
|
522
|
-
return true;
|
|
523
|
-
}
|
|
524
|
-
setMany(entryOrRawElements) {
|
|
525
|
-
const results = [];
|
|
526
|
-
for (const rawEle of entryOrRawElements) {
|
|
527
|
-
let key, value;
|
|
528
|
-
if (this.isEntry(rawEle))
|
|
529
|
-
[key, value] = rawEle;
|
|
530
|
-
else if (this._toEntryFn)
|
|
531
|
-
[key, value] = this._toEntryFn(rawEle);
|
|
532
|
-
if (key !== undefined && value !== undefined)
|
|
533
|
-
results.push(this.set(key, value));
|
|
534
|
-
}
|
|
535
|
-
return results;
|
|
536
|
-
}
|
|
537
|
-
has(key) {
|
|
538
|
-
if (isWeakKey(key)) {
|
|
539
|
-
const hash = this._objHashFn(key);
|
|
540
|
-
return this.objMap.has(hash);
|
|
541
|
-
}
|
|
542
|
-
const hash = this._hashFn(key);
|
|
543
|
-
return hash in this.noObjMap;
|
|
544
|
-
}
|
|
545
|
-
get(key) {
|
|
546
|
-
if (isWeakKey(key)) {
|
|
547
|
-
const hash = this._objHashFn(key);
|
|
548
|
-
const node = this.objMap.get(hash);
|
|
549
|
-
return node ? node.value : undefined;
|
|
550
|
-
}
|
|
551
|
-
const hash = this._hashFn(key);
|
|
552
|
-
const node = this.noObjMap[hash];
|
|
553
|
-
return node ? node.value : undefined;
|
|
554
|
-
}
|
|
555
|
-
/**
|
|
556
|
-
* Get the value at a given index in insertion order.
|
|
557
|
-
* @remarks Time O(N), Space O(1)
|
|
558
|
-
* @param index - Zero-based index.
|
|
559
|
-
* @returns Value at the index.
|
|
560
|
-
*/
|
|
561
|
-
at(index) {
|
|
562
|
-
rangeCheck(index, 0, this._size - 1);
|
|
563
|
-
let node = this.head;
|
|
564
|
-
while (index--)
|
|
565
|
-
node = node.next;
|
|
566
|
-
return node.value;
|
|
567
|
-
}
|
|
568
|
-
delete(key) {
|
|
569
|
-
let node;
|
|
570
|
-
if (isWeakKey(key)) {
|
|
571
|
-
const hash = this._objHashFn(key);
|
|
572
|
-
node = this.objMap.get(hash);
|
|
573
|
-
if (!node)
|
|
574
|
-
return false;
|
|
575
|
-
this.objMap.delete(hash);
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
578
|
-
const hash = this._hashFn(key);
|
|
579
|
-
node = this.noObjMap[hash];
|
|
580
|
-
if (!node)
|
|
581
|
-
return false;
|
|
582
|
-
delete this.noObjMap[hash];
|
|
583
|
-
}
|
|
584
|
-
return this._deleteNode(node);
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* Delete the first entry that matches a predicate.
|
|
588
|
-
* @remarks Time O(N), Space O(1)
|
|
589
|
-
* @param predicate - Function (key, value, index, map) → boolean to decide deletion.
|
|
590
|
-
* @returns True if an entry was removed.
|
|
591
|
-
*/
|
|
592
|
-
deleteWhere(predicate) {
|
|
593
|
-
let node = this._head;
|
|
594
|
-
let i = 0;
|
|
595
|
-
while (node !== this._sentinel) {
|
|
596
|
-
const cur = node;
|
|
597
|
-
node = node.next;
|
|
598
|
-
if (predicate(cur.key, cur.value, i++, this)) {
|
|
599
|
-
if (isWeakKey(cur.key)) {
|
|
600
|
-
this._objMap.delete(cur.key);
|
|
601
|
-
}
|
|
602
|
-
else {
|
|
603
|
-
const hash = this._hashFn(cur.key);
|
|
604
|
-
delete this._noObjMap[hash];
|
|
605
|
-
}
|
|
606
|
-
return this._deleteNode(cur);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
return false;
|
|
610
|
-
}
|
|
611
|
-
/**
|
|
612
|
-
* Delete the entry at a given index.
|
|
613
|
-
* @remarks Time O(N), Space O(1)
|
|
614
|
-
* @param index - Zero-based index.
|
|
615
|
-
* @returns True if removed.
|
|
616
|
-
*/
|
|
617
|
-
deleteAt(index) {
|
|
618
|
-
rangeCheck(index, 0, this._size - 1);
|
|
619
|
-
let node = this.head;
|
|
620
|
-
while (index--)
|
|
621
|
-
node = node.next;
|
|
622
|
-
return this._deleteNode(node);
|
|
623
|
-
}
|
|
624
|
-
isEmpty() {
|
|
625
|
-
return this._size === 0;
|
|
626
|
-
}
|
|
627
|
-
isEntry(rawElement) {
|
|
628
|
-
return Array.isArray(rawElement) && rawElement.length === 2;
|
|
629
|
-
}
|
|
630
|
-
clear() {
|
|
631
|
-
this._noObjMap = {};
|
|
632
|
-
this._size = 0;
|
|
633
|
-
this._head = this._tail = this._sentinel.prev = this._sentinel.next = this._sentinel;
|
|
634
|
-
}
|
|
635
|
-
clone() {
|
|
636
|
-
const opts = { hashFn: this._hashFn, objHashFn: this._objHashFn };
|
|
637
|
-
return this._createLike(this, opts);
|
|
638
|
-
}
|
|
639
|
-
filter(predicate, thisArg) {
|
|
640
|
-
const out = this._createLike();
|
|
641
|
-
let index = 0;
|
|
642
|
-
for (const [key, value] of this) {
|
|
643
|
-
if (predicate.call(thisArg, key, value, index, this))
|
|
644
|
-
out.set(key, value);
|
|
645
|
-
index++;
|
|
646
|
-
}
|
|
647
|
-
return out;
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Map each entry to a new [key, value] pair and preserve order.
|
|
651
|
-
* @remarks Time O(N), Space O(N)
|
|
652
|
-
* @template MK
|
|
653
|
-
* @template MV
|
|
654
|
-
* @param callback - Mapping function (key, value, index, map) → [newKey, newValue].
|
|
655
|
-
* @param [thisArg] - Value for `this` inside the callback.
|
|
656
|
-
* @returns A new map of the same class with transformed entries.
|
|
657
|
-
*/
|
|
658
|
-
map(callback, thisArg) {
|
|
659
|
-
const out = this._createLike();
|
|
660
|
-
let index = 0;
|
|
661
|
-
for (const [key, value] of this) {
|
|
662
|
-
const [newKey, newValue] = callback.call(thisArg, key, value, index, this);
|
|
663
|
-
out.set(newKey, newValue);
|
|
664
|
-
index++;
|
|
665
|
-
}
|
|
666
|
-
return out;
|
|
667
|
-
}
|
|
668
|
-
*_getIterator() {
|
|
669
|
-
let node = this.head;
|
|
670
|
-
while (node !== this._sentinel) {
|
|
671
|
-
yield [node.key, node.value];
|
|
672
|
-
node = node.next;
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
_deleteNode(node) {
|
|
676
|
-
const { prev, next } = node;
|
|
677
|
-
prev.next = next;
|
|
678
|
-
next.prev = prev;
|
|
679
|
-
if (node === this.head)
|
|
680
|
-
this._head = next;
|
|
681
|
-
if (node === this.tail)
|
|
682
|
-
this._tail = prev;
|
|
683
|
-
this._size -= 1;
|
|
684
|
-
return true;
|
|
685
|
-
}
|
|
686
|
-
_createLike(entries = [], options) {
|
|
687
|
-
const Ctor = this.constructor;
|
|
688
|
-
return new Ctor(entries, options);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
//# sourceMappingURL=hash-map.js.map
|