data-structure-typed 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/COMMANDS.md +13 -3
- package/README.md +5 -34
- 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/index.cjs +13091 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +13013 -0
- package/dist/index.js.map +1 -0
- package/dist/{cjs → types}/data-structures/binary-tree/avl-tree-counter.d.ts +4 -4
- package/dist/{esm → types}/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -5
- package/dist/{esm → types}/data-structures/binary-tree/avl-tree.d.ts +4 -4
- package/dist/{esm → types}/data-structures/binary-tree/binary-tree.d.ts +5 -5
- package/dist/{esm → types}/data-structures/binary-tree/bst.d.ts +5 -5
- package/dist/{esm → types}/data-structures/binary-tree/red-black-tree.d.ts +5 -5
- package/dist/{cjs → types}/data-structures/binary-tree/tree-counter.d.ts +4 -4
- package/dist/{cjs → types}/data-structures/binary-tree/tree-multi-map.d.ts +5 -5
- package/dist/{esm → types}/interfaces/binary-tree.d.ts +2 -2
- package/dist/umd/data-structure-typed.js +12 -11
- 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 +3 -0
- package/package.json +13 -11
- package/src/data-structures/binary-tree/avl-tree-counter.ts +4 -7
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +5 -10
- package/src/data-structures/binary-tree/avl-tree.ts +4 -6
- package/src/data-structures/binary-tree/binary-tree.ts +14 -16
- package/src/data-structures/binary-tree/bst.ts +5 -10
- package/src/data-structures/binary-tree/red-black-tree.ts +5 -10
- package/src/data-structures/binary-tree/tree-counter.ts +4 -9
- package/src/data-structures/binary-tree/tree-multi-map.ts +5 -10
- package/src/interfaces/binary-tree.ts +2 -2
- package/test/integration/all-in-one.test.ts +1 -1
- package/test/performance/data-structures/comparison/comparison.test.ts +27 -57
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +109 -1
- package/tsconfig-base.json +20 -20
- package/tsconfig-types.json +17 -0
- package/tsconfig.test.json +8 -0
- package/tsup.config.js +11 -22
- package/tsup.node.config.ts +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.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.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.d.ts +0 -503
- 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.d.ts +0 -451
- 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/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/heap.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/singly-linked-list.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
package/dist/cjs/utils/utils.js
DELETED
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.isTrampolineThunk = exports.makeTrampolineThunk = exports.roundFixed = exports.calcMinUnitsRequired = exports.isWeakKey = exports.throwRangeError = exports.rangeCheck = exports.getMSB = exports.arrayRemove = exports.uuidV4 = void 0;
|
|
13
|
-
exports.isComparable = isComparable;
|
|
14
|
-
exports.trampoline = trampoline;
|
|
15
|
-
exports.makeTrampoline = makeTrampoline;
|
|
16
|
-
exports.asyncTrampoline = asyncTrampoline;
|
|
17
|
-
exports.makeAsyncTrampoline = makeAsyncTrampoline;
|
|
18
|
-
/**
|
|
19
|
-
* The function generates a random UUID (Universally Unique Identifier) in TypeScript.
|
|
20
|
-
* @returns A randomly generated UUID (Universally Unique Identifier) in the format
|
|
21
|
-
* 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' where each 'x' is replaced with a random hexadecimal
|
|
22
|
-
* character.
|
|
23
|
-
*/
|
|
24
|
-
const uuidV4 = function () {
|
|
25
|
-
return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) {
|
|
26
|
-
const r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
|
|
27
|
-
return v.toString(16);
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
exports.uuidV4 = uuidV4;
|
|
31
|
-
/**
|
|
32
|
-
* The `arrayRemove` function removes elements from an array based on a specified predicate function
|
|
33
|
-
* and returns the removed elements.
|
|
34
|
-
* @param {T[]} array - An array of elements that you want to filter based on the provided predicate
|
|
35
|
-
* function.
|
|
36
|
-
* @param predicate - The `predicate` parameter is a function that takes three arguments:
|
|
37
|
-
* @returns The `arrayRemove` function returns an array containing the elements that satisfy the given
|
|
38
|
-
* `predicate` function.
|
|
39
|
-
*/
|
|
40
|
-
const arrayRemove = function (array, predicate) {
|
|
41
|
-
let i = -1, len = array ? array.length : 0;
|
|
42
|
-
const result = [];
|
|
43
|
-
while (++i < len) {
|
|
44
|
-
const value = array[i];
|
|
45
|
-
if (predicate(value, i, array)) {
|
|
46
|
-
result.push(value);
|
|
47
|
-
Array.prototype.splice.call(array, i--, 1);
|
|
48
|
-
len--;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
};
|
|
53
|
-
exports.arrayRemove = arrayRemove;
|
|
54
|
-
/**
|
|
55
|
-
* The function `getMSB` returns the most significant bit of a given number.
|
|
56
|
-
* @param {number} value - The `value` parameter is a number for which we want to find the position of
|
|
57
|
-
* the Most Significant Bit (MSB). The function `getMSB` takes this number as input and calculates the
|
|
58
|
-
* position of the MSB in its binary representation.
|
|
59
|
-
* @returns The function `getMSB` returns the most significant bit (MSB) of the input `value`. If the
|
|
60
|
-
* input value is less than or equal to 0, it returns 0. Otherwise, it calculates the position of the
|
|
61
|
-
* MSB using the `Math.clz32` function and bitwise left shifts 1 to that position.
|
|
62
|
-
*/
|
|
63
|
-
const getMSB = (value) => {
|
|
64
|
-
if (value <= 0) {
|
|
65
|
-
return 0;
|
|
66
|
-
}
|
|
67
|
-
return 1 << (31 - Math.clz32(value));
|
|
68
|
-
};
|
|
69
|
-
exports.getMSB = getMSB;
|
|
70
|
-
/**
|
|
71
|
-
* The `rangeCheck` function in TypeScript is used to validate if an index is within a specified range
|
|
72
|
-
* and throws a `RangeError` with a custom message if it is out of bounds.
|
|
73
|
-
* @param {number} index - The `index` parameter represents the value that you want to check if it
|
|
74
|
-
* falls within a specified range.
|
|
75
|
-
* @param {number} min - The `min` parameter represents the minimum value that the `index` should be
|
|
76
|
-
* compared against in the `rangeCheck` function.
|
|
77
|
-
* @param {number} max - The `max` parameter in the `rangeCheck` function represents the maximum value
|
|
78
|
-
* that the `index` parameter is allowed to have. If the `index` is greater than this `max` value, a
|
|
79
|
-
* `RangeError` will be thrown.
|
|
80
|
-
* @param [message=Index out of bounds.] - The `message` parameter is a string that represents the
|
|
81
|
-
* error message to be thrown if the index is out of bounds. By default, if no message is provided when
|
|
82
|
-
* calling the `rangeCheck` function, the message "Index out of bounds." will be used.
|
|
83
|
-
*/
|
|
84
|
-
const rangeCheck = (index, min, max, message = 'Index out of bounds.') => {
|
|
85
|
-
if (index < min || index > max)
|
|
86
|
-
throw new RangeError(message);
|
|
87
|
-
};
|
|
88
|
-
exports.rangeCheck = rangeCheck;
|
|
89
|
-
/**
|
|
90
|
-
* The function `throwRangeError` throws a RangeError with a custom message if called.
|
|
91
|
-
* @param [message=The value is off-limits.] - The `message` parameter is a string that represents the
|
|
92
|
-
* error message to be displayed when a `RangeError` is thrown. If no message is provided, the default
|
|
93
|
-
* message is 'The value is off-limits.'.
|
|
94
|
-
*/
|
|
95
|
-
const throwRangeError = (message = 'The value is off-limits.') => {
|
|
96
|
-
throw new RangeError(message);
|
|
97
|
-
};
|
|
98
|
-
exports.throwRangeError = throwRangeError;
|
|
99
|
-
/**
|
|
100
|
-
* The function `isWeakKey` checks if the input is an object or a function in TypeScript.
|
|
101
|
-
* @param {unknown} input - The `input` parameter in the `isWeakKey` function is of type `unknown`,
|
|
102
|
-
* which means it can be any type. The function checks if the `input` is an object (excluding `null`)
|
|
103
|
-
* or a function, and returns a boolean indicating whether the `input` is a weak
|
|
104
|
-
* @returns The function `isWeakKey` returns a boolean value indicating whether the input is an object
|
|
105
|
-
* or a function.
|
|
106
|
-
*/
|
|
107
|
-
const isWeakKey = (input) => {
|
|
108
|
-
const inputType = typeof input;
|
|
109
|
-
return (inputType === 'object' && input !== null) || inputType === 'function';
|
|
110
|
-
};
|
|
111
|
-
exports.isWeakKey = isWeakKey;
|
|
112
|
-
/**
|
|
113
|
-
* The function `calcMinUnitsRequired` calculates the minimum number of units required to accommodate a
|
|
114
|
-
* given total quantity based on a specified unit size.
|
|
115
|
-
* @param {number} totalQuantity - The `totalQuantity` parameter represents the total quantity of items
|
|
116
|
-
* that need to be processed or handled.
|
|
117
|
-
* @param {number} unitSize - The `unitSize` parameter represents the size of each unit or package. It
|
|
118
|
-
* is used in the `calcMinUnitsRequired` function to calculate the minimum number of units required to
|
|
119
|
-
* accommodate a total quantity of items.
|
|
120
|
-
*/
|
|
121
|
-
const calcMinUnitsRequired = (totalQuantity, unitSize) => Math.floor((totalQuantity + unitSize - 1) / unitSize);
|
|
122
|
-
exports.calcMinUnitsRequired = calcMinUnitsRequired;
|
|
123
|
-
/**
|
|
124
|
-
* The `roundFixed` function in TypeScript rounds a number to a specified number of decimal places.
|
|
125
|
-
* @param {number} num - The `num` parameter is a number that you want to round to a certain number of
|
|
126
|
-
* decimal places.
|
|
127
|
-
* @param {number} [digit=10] - The `digit` parameter in the `roundFixed` function specifies the number
|
|
128
|
-
* of decimal places to round the number to. By default, it is set to 10 if not provided explicitly.
|
|
129
|
-
* @returns The function `roundFixed` returns a number that is rounded to the specified number of
|
|
130
|
-
* decimal places (default is 10 decimal places).
|
|
131
|
-
*/
|
|
132
|
-
const roundFixed = (num, digit = 10) => {
|
|
133
|
-
const multiplier = Math.pow(10, digit);
|
|
134
|
-
return Math.round(num * multiplier) / multiplier;
|
|
135
|
-
};
|
|
136
|
-
exports.roundFixed = roundFixed;
|
|
137
|
-
/**
|
|
138
|
-
* The function `isPrimitiveComparable` checks if a value is a primitive type that can be compared.
|
|
139
|
-
* @param {unknown} value - The `value` parameter in the `isPrimitiveComparable` function is of type
|
|
140
|
-
* `unknown`, which means it can be any type. The function checks if the `value` is a primitive type
|
|
141
|
-
* that can be compared, such as number, bigint, string, or boolean.
|
|
142
|
-
* @returns The function `isPrimitiveComparable` returns a boolean value indicating whether the input
|
|
143
|
-
* `value` is a primitive value that can be compared using standard comparison operators (<, >, <=,
|
|
144
|
-
* >=).
|
|
145
|
-
*/
|
|
146
|
-
function isPrimitiveComparable(value) {
|
|
147
|
-
const valueType = typeof value;
|
|
148
|
-
if (valueType === 'number')
|
|
149
|
-
return true;
|
|
150
|
-
// if (valueType === 'number') return !Number.isNaN(value);
|
|
151
|
-
return valueType === 'bigint' || valueType === 'string' || valueType === 'boolean';
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* The function `tryObjectToPrimitive` attempts to convert an object to a comparable primitive value by
|
|
155
|
-
* first checking the `valueOf` method and then the `toString` method.
|
|
156
|
-
* @param {object} obj - The `obj` parameter in the `tryObjectToPrimitive` function is an object that
|
|
157
|
-
* you want to convert to a primitive value. The function attempts to convert the object to a primitive
|
|
158
|
-
* value by first checking if the object has a `valueOf` method. If the `valueOf` method exists, it
|
|
159
|
-
* @returns The function `tryObjectToPrimitive` returns a value of type `ComparablePrimitive` if a
|
|
160
|
-
* primitive comparable value is found within the object, or a string value if the object has a custom
|
|
161
|
-
* `toString` method that does not return `'[object Object]'`. If neither condition is met, the
|
|
162
|
-
* function returns `null`.
|
|
163
|
-
*/
|
|
164
|
-
function tryObjectToPrimitive(obj) {
|
|
165
|
-
if (typeof obj.valueOf === 'function') {
|
|
166
|
-
const valueOfResult = obj.valueOf();
|
|
167
|
-
if (valueOfResult !== obj) {
|
|
168
|
-
if (isPrimitiveComparable(valueOfResult))
|
|
169
|
-
return valueOfResult;
|
|
170
|
-
if (typeof valueOfResult === 'object' && valueOfResult !== null)
|
|
171
|
-
return tryObjectToPrimitive(valueOfResult);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (typeof obj.toString === 'function') {
|
|
175
|
-
const stringResult = obj.toString();
|
|
176
|
-
if (stringResult !== '[object Object]')
|
|
177
|
-
return stringResult;
|
|
178
|
-
}
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* The function `isComparable` in TypeScript checks if a value is comparable, handling primitive values
|
|
183
|
-
* and objects with optional force comparison.
|
|
184
|
-
* @param {unknown} value - The `value` parameter in the `isComparable` function represents the value
|
|
185
|
-
* that you want to check if it is comparable. It can be of any type (`unknown`), and the function will
|
|
186
|
-
* determine if it is comparable based on certain conditions.
|
|
187
|
-
* @param [isForceObjectComparable=false] - The `isForceObjectComparable` parameter in the
|
|
188
|
-
* `isComparable` function is a boolean flag that determines whether to treat non-primitive values as
|
|
189
|
-
* comparable objects. When set to `true`, it forces the function to consider non-primitive values as
|
|
190
|
-
* comparable objects, regardless of their type.
|
|
191
|
-
* @returns The function `isComparable` returns a boolean value indicating whether the `value` is
|
|
192
|
-
* considered comparable or not.
|
|
193
|
-
*/
|
|
194
|
-
function isComparable(value, isForceObjectComparable = false) {
|
|
195
|
-
if (value === null || value === undefined)
|
|
196
|
-
return false;
|
|
197
|
-
if (isPrimitiveComparable(value))
|
|
198
|
-
return true;
|
|
199
|
-
if (typeof value !== 'object')
|
|
200
|
-
return false;
|
|
201
|
-
if (value instanceof Date)
|
|
202
|
-
return true;
|
|
203
|
-
// if (value instanceof Date) return !Number.isNaN(value.getTime());
|
|
204
|
-
if (isForceObjectComparable)
|
|
205
|
-
return true;
|
|
206
|
-
const comparableValue = tryObjectToPrimitive(value);
|
|
207
|
-
if (comparableValue === null || comparableValue === undefined)
|
|
208
|
-
return false;
|
|
209
|
-
return isPrimitiveComparable(comparableValue);
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Creates a trampoline thunk object.
|
|
213
|
-
*
|
|
214
|
-
* A "thunk" is a deferred computation — instead of performing a recursive call immediately,
|
|
215
|
-
* it wraps the next step of the computation in a function. This allows recursive processes
|
|
216
|
-
* to be executed iteratively, preventing stack overflows.
|
|
217
|
-
*
|
|
218
|
-
* @template T - The type of the final computation result.
|
|
219
|
-
* @param computation - A function that, when executed, returns the next trampoline step.
|
|
220
|
-
* @returns A TrampolineThunk object containing the deferred computation.
|
|
221
|
-
*/
|
|
222
|
-
const makeTrampolineThunk = (computation) => ({
|
|
223
|
-
isThunk: true, // Marker indicating this is a thunk
|
|
224
|
-
fn: computation // The deferred computation function
|
|
225
|
-
});
|
|
226
|
-
exports.makeTrampolineThunk = makeTrampolineThunk;
|
|
227
|
-
/**
|
|
228
|
-
* Type guard to check whether a given value is a TrampolineThunk.
|
|
229
|
-
*
|
|
230
|
-
* This function is used to distinguish between a final computation result (value)
|
|
231
|
-
* and a deferred computation (thunk).
|
|
232
|
-
*
|
|
233
|
-
* @template T - The type of the value being checked.
|
|
234
|
-
* @param value - The value to test.
|
|
235
|
-
* @returns True if the value is a valid TrampolineThunk, false otherwise.
|
|
236
|
-
*/
|
|
237
|
-
const isTrampolineThunk = (value) => typeof value === 'object' && // Must be an object
|
|
238
|
-
value !== null && // Must not be null
|
|
239
|
-
'isThunk' in value && // Must have the 'isThunk' property
|
|
240
|
-
value.isThunk; // The flag must be true
|
|
241
|
-
exports.isTrampolineThunk = isTrampolineThunk;
|
|
242
|
-
/**
|
|
243
|
-
* Executes a trampoline computation until a final (non-thunk) result is obtained.
|
|
244
|
-
*
|
|
245
|
-
* The trampoline function repeatedly invokes the deferred computations (thunks)
|
|
246
|
-
* in an iterative loop. This avoids deep recursive calls and prevents stack overflow,
|
|
247
|
-
* which is particularly useful for implementing recursion in a stack-safe manner.
|
|
248
|
-
*
|
|
249
|
-
* @template T - The type of the final result.
|
|
250
|
-
* @param initial - The initial Trampoline value or thunk to start execution from.
|
|
251
|
-
* @returns The final result of the computation (a non-thunk value).
|
|
252
|
-
*/
|
|
253
|
-
function trampoline(initial) {
|
|
254
|
-
let current = initial; // Start with the initial trampoline value
|
|
255
|
-
while ((0, exports.isTrampolineThunk)(current)) {
|
|
256
|
-
// Keep unwrapping while we have thunks
|
|
257
|
-
current = current.fn(); // Execute the deferred function to get the next step
|
|
258
|
-
}
|
|
259
|
-
return current; // Once no thunks remain, return the final result
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Wraps a recursive function inside a trampoline executor.
|
|
263
|
-
*
|
|
264
|
-
* This function transforms a potentially recursive function (that returns a Trampoline<Result>)
|
|
265
|
-
* into a *stack-safe* function that executes iteratively using the `trampoline` runner.
|
|
266
|
-
*
|
|
267
|
-
* In other words, it allows you to write functions that look recursive,
|
|
268
|
-
* but actually run in constant stack space.
|
|
269
|
-
*
|
|
270
|
-
* @template Args - The tuple type representing the argument list of the original function.
|
|
271
|
-
* @template Result - The final return type after all trampoline steps are resolved.
|
|
272
|
-
*
|
|
273
|
-
* @param fn - A function that performs a single step of computation
|
|
274
|
-
* and returns a Trampoline (either a final value or a deferred thunk).
|
|
275
|
-
*
|
|
276
|
-
* @returns A new function with the same arguments, but which automatically
|
|
277
|
-
* runs the trampoline process and returns the *final result* instead
|
|
278
|
-
* of a Trampoline.
|
|
279
|
-
*
|
|
280
|
-
* @example
|
|
281
|
-
* // Example: Computing factorial in a stack-safe way
|
|
282
|
-
* const factorial = makeTrampoline(function fact(n: number, acc: number = 1): Trampoline<number> {
|
|
283
|
-
* return n === 0
|
|
284
|
-
* ? acc
|
|
285
|
-
* : makeTrampolineThunk(() => fact(n - 1, acc * n));
|
|
286
|
-
* });
|
|
287
|
-
*
|
|
288
|
-
* console.log(factorial(100000)); // Works without stack overflow
|
|
289
|
-
*/
|
|
290
|
-
function makeTrampoline(fn // A function that returns a trampoline step
|
|
291
|
-
) {
|
|
292
|
-
// Return a wrapped function that automatically runs the trampoline execution loop
|
|
293
|
-
return (...args) => trampoline(fn(...args));
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Executes an asynchronous trampoline computation until a final (non-thunk) result is obtained.
|
|
297
|
-
*
|
|
298
|
-
* This function repeatedly invokes asynchronous deferred computations (thunks)
|
|
299
|
-
* in an iterative loop. Each thunk may return either a Trampoline<T> or a Promise<Trampoline<T>>.
|
|
300
|
-
*
|
|
301
|
-
* It ensures that asynchronous recursive functions can run without growing the call stack,
|
|
302
|
-
* making it suitable for stack-safe async recursion.
|
|
303
|
-
*
|
|
304
|
-
* @template T - The type of the final result.
|
|
305
|
-
* @param initial - The initial Trampoline or Promise of Trampoline to start execution from.
|
|
306
|
-
* @returns A Promise that resolves to the final result (a non-thunk value).
|
|
307
|
-
*/
|
|
308
|
-
function asyncTrampoline(initial) {
|
|
309
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
310
|
-
let current = yield initial; // Wait for the initial step to resolve if it's a Promise
|
|
311
|
-
// Keep executing thunks until we reach a non-thunk (final) value
|
|
312
|
-
while ((0, exports.isTrampolineThunk)(current)) {
|
|
313
|
-
current = yield current.fn(); // Execute the thunk function (may be async)
|
|
314
|
-
}
|
|
315
|
-
// Once the final value is reached, return it
|
|
316
|
-
return current;
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Wraps an asynchronous recursive function inside an async trampoline executor.
|
|
321
|
-
*
|
|
322
|
-
* This helper transforms a recursive async function that returns a Trampoline<Result>
|
|
323
|
-
* (or Promise<Trampoline<Result>>) into a *stack-safe* async function that executes
|
|
324
|
-
* iteratively via the `asyncTrampoline` runner.
|
|
325
|
-
*
|
|
326
|
-
* @template Args - The tuple type representing the argument list of the original function.
|
|
327
|
-
* @template Result - The final return type after all async trampoline steps are resolved.
|
|
328
|
-
*
|
|
329
|
-
* @param fn - An async or sync function that performs a single step of computation
|
|
330
|
-
* and returns a Trampoline (either a final value or a deferred thunk).
|
|
331
|
-
*
|
|
332
|
-
* @returns An async function with the same arguments, but which automatically
|
|
333
|
-
* runs the trampoline process and resolves to the *final result*.
|
|
334
|
-
*
|
|
335
|
-
* @example
|
|
336
|
-
* // Example: Async factorial using trampoline
|
|
337
|
-
* const asyncFactorial = makeAsyncTrampoline(async function fact(
|
|
338
|
-
* n: number,
|
|
339
|
-
* acc: number = 1
|
|
340
|
-
* ): Promise<Trampoline<number>> {
|
|
341
|
-
* return n === 0
|
|
342
|
-
* ? acc
|
|
343
|
-
* : makeTrampolineThunk(() => fact(n - 1, acc * n));
|
|
344
|
-
* });
|
|
345
|
-
*
|
|
346
|
-
* asyncFactorial(100000).then(console.log); // Works without stack overflow
|
|
347
|
-
*/
|
|
348
|
-
function makeAsyncTrampoline(fn) {
|
|
349
|
-
// Return a wrapped async function that runs through the async trampoline loop
|
|
350
|
-
return (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
351
|
-
return asyncTrampoline(fn(...args));
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/utils.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare enum DFSOperation {
|
|
2
|
-
VISIT = 0,
|
|
3
|
-
PROCESS = 1
|
|
4
|
-
}
|
|
5
|
-
export declare class Range<K> {
|
|
6
|
-
low: K;
|
|
7
|
-
high: K;
|
|
8
|
-
includeLow: boolean;
|
|
9
|
-
includeHigh: boolean;
|
|
10
|
-
constructor(low: K, high: K, includeLow?: boolean, includeHigh?: boolean);
|
|
11
|
-
isInRange(key: K, comparator: (a: K, b: K) => number): boolean;
|
|
12
|
-
}
|
package/dist/esm/common/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { isComparable } from '../utils';
|
|
2
|
-
export var DFSOperation;
|
|
3
|
-
(function (DFSOperation) {
|
|
4
|
-
DFSOperation[DFSOperation["VISIT"] = 0] = "VISIT";
|
|
5
|
-
DFSOperation[DFSOperation["PROCESS"] = 1] = "PROCESS";
|
|
6
|
-
})(DFSOperation || (DFSOperation = {}));
|
|
7
|
-
export class Range {
|
|
8
|
-
low;
|
|
9
|
-
high;
|
|
10
|
-
includeLow;
|
|
11
|
-
includeHigh;
|
|
12
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
13
|
-
this.low = low;
|
|
14
|
-
this.high = high;
|
|
15
|
-
this.includeLow = includeLow;
|
|
16
|
-
this.includeHigh = includeHigh;
|
|
17
|
-
if (!(isComparable(low) && isComparable(high)))
|
|
18
|
-
throw new RangeError('low or high is not comparable');
|
|
19
|
-
if (low > high)
|
|
20
|
-
throw new RangeError('low must be less than or equal to high');
|
|
21
|
-
}
|
|
22
|
-
// Determine whether a key is within the range
|
|
23
|
-
isInRange(key, comparator) {
|
|
24
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
25
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
26
|
-
return lowCheck && highCheck;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,iDAAS,CAAA;IACT,qDAAW,CAAA;AACb,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAED,MAAM,OAAO,KAAK;IAEP;IACA;IACA;IACA;IAJT,YACS,GAAM,EACN,IAAO,EACP,aAAsB,IAAI,EAC1B,cAAuB,IAAI;QAH3B,QAAG,GAAH,GAAG,CAAG;QACN,SAAI,GAAJ,IAAI,CAAG;QACP,eAAU,GAAV,UAAU,CAAgB;QAC1B,gBAAW,GAAX,WAAW,CAAgB;QAElC,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;YAAE,MAAM,IAAI,UAAU,CAAC,+BAA+B,CAAC,CAAC;QACtG,IAAI,GAAG,GAAG,IAAI;YAAE,MAAM,IAAI,UAAU,CAAC,wCAAwC,CAAC,CAAC;IACjF,CAAC;IAED,8CAA8C;IAC9C,SAAS,CAAC,GAAM,EAAE,UAAkC;QAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClG,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtG,OAAO,QAAQ,IAAI,SAAS,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data-structures/base/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC"}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import type { ElementCallback, IterableElementBaseOptions, ReduceElementCallback } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Base class that makes a data structure iterable and provides common
|
|
4
|
-
* element-wise utilities (e.g., map/filter/reduce/find).
|
|
5
|
-
*
|
|
6
|
-
* @template E The public element type yielded by the structure.
|
|
7
|
-
* @template R The underlying "raw" element type used internally or by converters.
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* This class implements the JavaScript iteration protocol (via `Symbol.iterator`)
|
|
11
|
-
* and offers array-like helpers with predictable time/space complexity.
|
|
12
|
-
*/
|
|
13
|
-
export declare abstract class IterableElementBase<E, R> implements Iterable<E> {
|
|
14
|
-
/**
|
|
15
|
-
* Create a new iterable base.
|
|
16
|
-
*
|
|
17
|
-
* @param options Optional behavior overrides. When provided, a `toElementFn`
|
|
18
|
-
* is used to convert a raw element (`R`) into a public element (`E`).
|
|
19
|
-
*
|
|
20
|
-
* @remarks
|
|
21
|
-
* Time O(1), Space O(1).
|
|
22
|
-
*/
|
|
23
|
-
protected constructor(options?: IterableElementBaseOptions<E, R>);
|
|
24
|
-
/**
|
|
25
|
-
* The converter used to transform a raw element (`R`) into a public element (`E`).
|
|
26
|
-
*
|
|
27
|
-
* @remarks
|
|
28
|
-
* Time O(1), Space O(1).
|
|
29
|
-
*/
|
|
30
|
-
protected _toElementFn?: (rawElement: R) => E;
|
|
31
|
-
/**
|
|
32
|
-
* Exposes the current `toElementFn`, if configured.
|
|
33
|
-
*
|
|
34
|
-
* @returns The converter function or `undefined` when not set.
|
|
35
|
-
* @remarks
|
|
36
|
-
* Time O(1), Space O(1).
|
|
37
|
-
*/
|
|
38
|
-
get toElementFn(): ((rawElement: R) => E) | undefined;
|
|
39
|
-
/**
|
|
40
|
-
* Returns an iterator over the structure's elements.
|
|
41
|
-
*
|
|
42
|
-
* @param args Optional iterator arguments forwarded to the internal iterator.
|
|
43
|
-
* @returns An `IterableIterator<E>` that yields the elements in traversal order.
|
|
44
|
-
*
|
|
45
|
-
* @remarks
|
|
46
|
-
* Producing the iterator is O(1); consuming the entire iterator is Time O(n) with O(1) extra space.
|
|
47
|
-
*/
|
|
48
|
-
[Symbol.iterator](...args: unknown[]): IterableIterator<E>;
|
|
49
|
-
/**
|
|
50
|
-
* Returns an iterator over the values (alias of the default iterator).
|
|
51
|
-
*
|
|
52
|
-
* @returns An `IterableIterator<E>` over all elements.
|
|
53
|
-
* @remarks
|
|
54
|
-
* Creating the iterator is O(1); full iteration is Time O(n), Space O(1).
|
|
55
|
-
*/
|
|
56
|
-
values(): IterableIterator<E>;
|
|
57
|
-
/**
|
|
58
|
-
* Tests whether all elements satisfy the predicate.
|
|
59
|
-
*
|
|
60
|
-
* @template TReturn
|
|
61
|
-
* @param predicate Function invoked for each element with signature `(value, index, self)`.
|
|
62
|
-
* @param thisArg Optional `this` binding for the predicate.
|
|
63
|
-
* @returns `true` if every element passes; otherwise `false`.
|
|
64
|
-
*
|
|
65
|
-
* @remarks
|
|
66
|
-
* Time O(n) in the worst case; may exit early when the first failure is found. Space O(1).
|
|
67
|
-
*/
|
|
68
|
-
every(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Tests whether at least one element satisfies the predicate.
|
|
71
|
-
*
|
|
72
|
-
* @param predicate Function invoked for each element with signature `(value, index, self)`.
|
|
73
|
-
* @param thisArg Optional `this` binding for the predicate.
|
|
74
|
-
* @returns `true` if any element passes; otherwise `false`.
|
|
75
|
-
*
|
|
76
|
-
* @remarks
|
|
77
|
-
* Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
78
|
-
*/
|
|
79
|
-
some(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Invokes a callback for each element in iteration order.
|
|
82
|
-
*
|
|
83
|
-
* @param callbackfn Function invoked per element with signature `(value, index, self)`.
|
|
84
|
-
* @param thisArg Optional `this` binding for the callback.
|
|
85
|
-
* @returns `void`.
|
|
86
|
-
*
|
|
87
|
-
* @remarks
|
|
88
|
-
* Time O(n), Space O(1).
|
|
89
|
-
*/
|
|
90
|
-
forEach(callbackfn: ElementCallback<E, R, void>, thisArg?: unknown): void;
|
|
91
|
-
/**
|
|
92
|
-
* Finds the first element that satisfies the predicate and returns it.
|
|
93
|
-
*
|
|
94
|
-
* @overload
|
|
95
|
-
* Finds the first element of type `S` (a subtype of `E`) that satisfies the predicate and returns it.
|
|
96
|
-
* @template S
|
|
97
|
-
* @param predicate Type-guard predicate: `(value, index, self) => value is S`.
|
|
98
|
-
* @param thisArg Optional `this` binding for the predicate.
|
|
99
|
-
* @returns The matched element typed as `S`, or `undefined` if not found.
|
|
100
|
-
*
|
|
101
|
-
* @overload
|
|
102
|
-
* @param predicate Boolean predicate: `(value, index, self) => boolean`.
|
|
103
|
-
* @param thisArg Optional `this` binding for the predicate.
|
|
104
|
-
* @returns The first matching element as `E`, or `undefined` if not found.
|
|
105
|
-
*
|
|
106
|
-
* @remarks
|
|
107
|
-
* Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
108
|
-
*/
|
|
109
|
-
find<S extends E>(predicate: ElementCallback<E, R, S>, thisArg?: unknown): S | undefined;
|
|
110
|
-
find(predicate: ElementCallback<E, R, unknown>, thisArg?: unknown): E | undefined;
|
|
111
|
-
/**
|
|
112
|
-
* Checks whether a strictly-equal element exists in the structure.
|
|
113
|
-
*
|
|
114
|
-
* @param element The element to test with `===` equality.
|
|
115
|
-
* @returns `true` if an equal element is found; otherwise `false`.
|
|
116
|
-
*
|
|
117
|
-
* @remarks
|
|
118
|
-
* Time O(n) in the worst case. Space O(1).
|
|
119
|
-
*/
|
|
120
|
-
has(element: E): boolean;
|
|
121
|
-
reduce(callbackfn: ReduceElementCallback<E, R>): E;
|
|
122
|
-
reduce(callbackfn: ReduceElementCallback<E, R>, initialValue: E): E;
|
|
123
|
-
reduce<U>(callbackfn: ReduceElementCallback<E, R, U>, initialValue: U): U;
|
|
124
|
-
/**
|
|
125
|
-
* Materializes the elements into a new array.
|
|
126
|
-
*
|
|
127
|
-
* @returns A shallow array copy of the iteration order.
|
|
128
|
-
* @remarks
|
|
129
|
-
* Time O(n), Space O(n).
|
|
130
|
-
*/
|
|
131
|
-
toArray(): E[];
|
|
132
|
-
/**
|
|
133
|
-
* Returns a representation of the structure suitable for quick visualization.
|
|
134
|
-
* Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
135
|
-
*
|
|
136
|
-
* @returns A visual representation (array by default).
|
|
137
|
-
* @remarks
|
|
138
|
-
* Time O(n), Space O(n).
|
|
139
|
-
*/
|
|
140
|
-
toVisual(): E[];
|
|
141
|
-
/**
|
|
142
|
-
* Prints `toVisual()` to the console. Intended for quick debugging.
|
|
143
|
-
*
|
|
144
|
-
* @returns `void`.
|
|
145
|
-
* @remarks
|
|
146
|
-
* Time O(n) due to materialization, Space O(n) for the intermediate representation.
|
|
147
|
-
*/
|
|
148
|
-
print(): void;
|
|
149
|
-
/**
|
|
150
|
-
* Indicates whether the structure currently contains no elements.
|
|
151
|
-
*
|
|
152
|
-
* @returns `true` if empty; otherwise `false`.
|
|
153
|
-
* @remarks
|
|
154
|
-
* Expected Time O(1), Space O(1) for most implementations.
|
|
155
|
-
*/
|
|
156
|
-
abstract isEmpty(): boolean;
|
|
157
|
-
/**
|
|
158
|
-
* Removes all elements from the structure.
|
|
159
|
-
*
|
|
160
|
-
* @returns `void`.
|
|
161
|
-
* @remarks
|
|
162
|
-
* Expected Time O(1) or O(n) depending on the implementation; Space O(1).
|
|
163
|
-
*/
|
|
164
|
-
abstract clear(): void;
|
|
165
|
-
/**
|
|
166
|
-
* Creates a structural copy with the same element values and configuration.
|
|
167
|
-
*
|
|
168
|
-
* @returns A clone of the current instance (same concrete type).
|
|
169
|
-
* @remarks
|
|
170
|
-
* Expected Time O(n) to copy elements; Space O(n).
|
|
171
|
-
*/
|
|
172
|
-
abstract clone(): this;
|
|
173
|
-
/**
|
|
174
|
-
* Maps each element to a new element and returns a new iterable structure.
|
|
175
|
-
*
|
|
176
|
-
* @template EM The mapped element type.
|
|
177
|
-
* @template RM The mapped raw element type used internally by the target structure.
|
|
178
|
-
* @param callback Function with signature `(value, index, self) => mapped`.
|
|
179
|
-
* @param options Optional options for the returned structure, including its `toElementFn`.
|
|
180
|
-
* @param thisArg Optional `this` binding for the callback.
|
|
181
|
-
* @returns A new `IterableElementBase<EM, RM>` containing mapped elements.
|
|
182
|
-
*
|
|
183
|
-
* @remarks
|
|
184
|
-
* Time O(n), Space O(n).
|
|
185
|
-
*/
|
|
186
|
-
abstract map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: IterableElementBaseOptions<EM, RM>, thisArg?: unknown): IterableElementBase<EM, RM>;
|
|
187
|
-
/**
|
|
188
|
-
* Maps each element to the same element type and returns the same concrete structure type.
|
|
189
|
-
*
|
|
190
|
-
* @param callback Function with signature `(value, index, self) => mappedValue`.
|
|
191
|
-
* @param thisArg Optional `this` binding for the callback.
|
|
192
|
-
* @returns A new instance of the same concrete type with mapped elements.
|
|
193
|
-
*
|
|
194
|
-
* @remarks
|
|
195
|
-
* Time O(n), Space O(n).
|
|
196
|
-
*/
|
|
197
|
-
abstract mapSame(callback: ElementCallback<E, R, E>, thisArg?: unknown): this;
|
|
198
|
-
/**
|
|
199
|
-
* Filters elements using the provided predicate and returns the same concrete structure type.
|
|
200
|
-
*
|
|
201
|
-
* @param predicate Function with signature `(value, index, self) => boolean`.
|
|
202
|
-
* @param thisArg Optional `this` binding for the predicate.
|
|
203
|
-
* @returns A new instance of the same concrete type containing only elements that pass the predicate.
|
|
204
|
-
*
|
|
205
|
-
* @remarks
|
|
206
|
-
* Time O(n), Space O(k) where `k` is the number of kept elements.
|
|
207
|
-
*/
|
|
208
|
-
abstract filter(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): this;
|
|
209
|
-
/**
|
|
210
|
-
* Internal iterator factory used by the default iterator.
|
|
211
|
-
*
|
|
212
|
-
* @param args Optional iterator arguments.
|
|
213
|
-
* @returns An iterator over elements.
|
|
214
|
-
*
|
|
215
|
-
* @remarks
|
|
216
|
-
* Implementations should yield in O(1) per element with O(1) extra space when possible.
|
|
217
|
-
*/
|
|
218
|
-
protected abstract _getIterator(...args: unknown[]): IterableIterator<E>;
|
|
219
|
-
}
|