data-structure-typed 2.0.5 → 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 +27 -0
- package/README.md +5 -34
- package/benchmark/report.html +13 -77
- package/benchmark/report.json +152 -184
- 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/types/data-structures/base/iterable-element-base.d.ts +219 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +144 -0
- package/dist/types/data-structures/base/linear-base.d.ts +335 -0
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +182 -0
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +135 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +291 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +754 -0
- package/dist/types/data-structures/binary-tree/bst.d.ts +413 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +208 -0
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +190 -0
- package/dist/{esm → types}/data-structures/binary-tree/tree-multi-map.d.ts +72 -69
- package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +207 -0
- package/dist/types/data-structures/graph/map-graph.d.ts +78 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +188 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +345 -0
- package/dist/types/data-structures/heap/heap.d.ts +503 -0
- package/dist/types/data-structures/heap/max-heap.d.ts +32 -0
- package/dist/types/data-structures/heap/min-heap.d.ts +33 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +769 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +451 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -0
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -0
- package/dist/types/data-structures/queue/deque.d.ts +431 -0
- package/dist/types/data-structures/queue/queue.d.ts +308 -0
- package/dist/{cjs → types}/data-structures/stack/stack.d.ts +124 -102
- package/dist/types/data-structures/trie/trie.d.ts +350 -0
- package/dist/types/interfaces/binary-tree.d.ts +59 -0
- package/dist/types/interfaces/graph.d.ts +21 -0
- package/dist/{cjs → types}/types/data-structures/base/base.d.ts +1 -1
- package/dist/{esm → types}/types/data-structures/graph/abstract-graph.d.ts +4 -0
- package/dist/{cjs → types}/types/utils/utils.d.ts +1 -0
- package/dist/{esm → types}/utils/utils.d.ts +1 -1
- package/dist/umd/data-structure-typed.js +4693 -6484
- package/dist/umd/data-structure-typed.js.map +1 -0
- package/dist/umd/data-structure-typed.min.js +8 -6
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/jest.integration.config.js +3 -0
- package/package.json +13 -12
- package/src/data-structures/base/iterable-element-base.ts +238 -115
- package/src/data-structures/base/iterable-entry-base.ts +96 -120
- package/src/data-structures/base/linear-base.ts +271 -277
- package/src/data-structures/binary-tree/avl-tree-counter.ts +196 -217
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +188 -102
- package/src/data-structures/binary-tree/avl-tree.ts +237 -206
- package/src/data-structures/binary-tree/binary-tree.ts +665 -896
- package/src/data-structures/binary-tree/bst.ts +565 -572
- package/src/data-structures/binary-tree/red-black-tree.ts +157 -223
- package/src/data-structures/binary-tree/tree-counter.ts +195 -219
- package/src/data-structures/binary-tree/tree-multi-map.ts +127 -98
- package/src/data-structures/graph/abstract-graph.ts +339 -264
- package/src/data-structures/graph/directed-graph.ts +146 -236
- package/src/data-structures/graph/map-graph.ts +63 -60
- package/src/data-structures/graph/undirected-graph.ts +129 -152
- package/src/data-structures/hash/hash-map.ts +274 -496
- package/src/data-structures/heap/heap.ts +389 -402
- package/src/data-structures/heap/max-heap.ts +12 -76
- package/src/data-structures/heap/min-heap.ts +13 -76
- package/src/data-structures/linked-list/doubly-linked-list.ts +426 -530
- package/src/data-structures/linked-list/singly-linked-list.ts +495 -517
- package/src/data-structures/linked-list/skip-linked-list.ts +1 -108
- package/src/data-structures/priority-queue/max-priority-queue.ts +12 -87
- package/src/data-structures/priority-queue/min-priority-queue.ts +11 -88
- package/src/data-structures/priority-queue/priority-queue.ts +3 -92
- package/src/data-structures/queue/deque.ts +381 -357
- package/src/data-structures/queue/queue.ts +310 -264
- package/src/data-structures/stack/stack.ts +217 -131
- package/src/data-structures/trie/trie.ts +240 -175
- package/src/interfaces/binary-tree.ts +240 -6
- package/src/interfaces/graph.ts +37 -0
- package/src/types/data-structures/base/base.ts +5 -5
- package/src/types/data-structures/graph/abstract-graph.ts +5 -0
- package/src/types/utils/utils.ts +2 -0
- package/src/utils/utils.ts +9 -14
- package/test/integration/all-in-one.test.ts +1 -1
- package/test/integration/index.html +1 -1
- package/test/performance/benchmark-runner.ts +528 -0
- package/test/performance/data-structures/comparison/comparison.test.ts +27 -57
- package/test/performance/reportor.mjs +43 -43
- package/test/performance/runner-config.json +39 -0
- package/test/performance/single-suite-runner.ts +69 -0
- package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +3 -3
- package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +5 -5
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +4 -4
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +350 -90
- package/test/unit/data-structures/binary-tree/bst.test.ts +12 -9
- package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +2 -2
- package/test/unit/data-structures/binary-tree/tree-counter.test.ts +25 -24
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +112 -4
- package/test/unit/data-structures/graph/abstract-graph.test.ts +0 -4
- package/test/unit/data-structures/graph/directed-graph.test.ts +1 -1
- package/test/unit/data-structures/heap/heap.test.ts +14 -21
- package/test/unit/data-structures/heap/max-heap.test.ts +5 -9
- package/test/unit/data-structures/heap/min-heap.test.ts +1 -4
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +14 -14
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +0 -7
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +8 -11
- package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -4
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +1 -4
- package/test/unit/data-structures/queue/queue.test.ts +4 -5
- package/test/unit/utils/utils.test.ts +0 -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.d.ts +0 -116
- package/dist/cjs/data-structures/base/iterable-element-base.js +0 -202
- package/dist/cjs/data-structures/base/iterable-element-base.js.map +0 -1
- package/dist/cjs/data-structures/base/iterable-entry-base.d.ts +0 -168
- package/dist/cjs/data-structures/base/iterable-entry-base.js +0 -241
- package/dist/cjs/data-structures/base/iterable-entry-base.js.map +0 -1
- package/dist/cjs/data-structures/base/linear-base.d.ts +0 -277
- package/dist/cjs/data-structures/base/linear-base.js +0 -553
- package/dist/cjs/data-structures/base/linear-base.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree-counter.d.ts +0 -214
- package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js +0 -409
- 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 -104
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +0 -203
- 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 -302
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -599
- 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 -910
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +0 -2197
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +0 -461
- package/dist/cjs/data-structures/binary-tree/bst.js +0 -880
- 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 -280
- package/dist/cjs/data-structures/binary-tree/red-black-tree.js +0 -642
- 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.d.ts +0 -212
- package/dist/cjs/data-structures/binary-tree/tree-counter.js +0 -445
- package/dist/cjs/data-structures/binary-tree/tree-counter.js.map +0 -1
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +0 -267
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +0 -365
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +0 -1
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +0 -335
- package/dist/cjs/data-structures/graph/abstract-graph.js +0 -867
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +0 -1
- package/dist/cjs/data-structures/graph/directed-graph.d.ts +0 -323
- package/dist/cjs/data-structures/graph/directed-graph.js +0 -613
- 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.d.ts +0 -84
- package/dist/cjs/data-structures/graph/map-graph.js +0 -111
- package/dist/cjs/data-structures/graph/map-graph.js.map +0 -1
- package/dist/cjs/data-structures/graph/undirected-graph.d.ts +0 -231
- package/dist/cjs/data-structures/graph/undirected-graph.js +0 -445
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +0 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +0 -519
- package/dist/cjs/data-structures/hash/hash-map.js +0 -880
- 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 -578
- package/dist/cjs/data-structures/heap/heap.js +0 -911
- 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.d.ts +0 -68
- package/dist/cjs/data-structures/heap/max-heap.js +0 -96
- package/dist/cjs/data-structures/heap/max-heap.js.map +0 -1
- package/dist/cjs/data-structures/heap/min-heap.d.ts +0 -68
- package/dist/cjs/data-structures/heap/min-heap.js +0 -87
- 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.d.ts +0 -885
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +0 -1238
- 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 -500
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +0 -870
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +0 -1
- package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +0 -134
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js +0 -245
- 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.d.ts +0 -71
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +0 -102
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +0 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +0 -72
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +0 -94
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +0 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +0 -74
- package/dist/cjs/data-structures/priority-queue/priority-queue.js +0 -96
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +0 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +0 -458
- package/dist/cjs/data-structures/queue/deque.js +0 -919
- 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.d.ts +0 -329
- package/dist/cjs/data-structures/queue/queue.js +0 -457
- 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 -346
- 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.d.ts +0 -351
- package/dist/cjs/data-structures/trie/trie.js +0 -594
- 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 -9
- 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.d.ts +0 -5
- 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.d.ts +0 -10
- 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.d.ts +0 -209
- package/dist/cjs/utils/utils.js +0 -353
- 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 -116
- package/dist/esm/data-structures/base/iterable-element-base.js +0 -199
- 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 -168
- package/dist/esm/data-structures/base/iterable-entry-base.js +0 -237
- package/dist/esm/data-structures/base/iterable-entry-base.js.map +0 -1
- package/dist/esm/data-structures/base/linear-base.d.ts +0 -277
- package/dist/esm/data-structures/base/linear-base.js +0 -549
- 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 -214
- package/dist/esm/data-structures/binary-tree/avl-tree-counter.js +0 -410
- 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.d.ts +0 -104
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +0 -205
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +0 -302
- package/dist/esm/data-structures/binary-tree/avl-tree.js +0 -601
- 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.d.ts +0 -910
- package/dist/esm/data-structures/binary-tree/binary-tree.js +0 -2198
- package/dist/esm/data-structures/binary-tree/binary-tree.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/bst.d.ts +0 -461
- package/dist/esm/data-structures/binary-tree/bst.js +0 -881
- 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.d.ts +0 -280
- package/dist/esm/data-structures/binary-tree/red-black-tree.js +0 -641
- 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 -212
- package/dist/esm/data-structures/binary-tree/tree-counter.js +0 -446
- package/dist/esm/data-structures/binary-tree/tree-counter.js.map +0 -1
- package/dist/esm/data-structures/binary-tree/tree-multi-map.js +0 -367
- 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 -335
- package/dist/esm/data-structures/graph/abstract-graph.js +0 -862
- package/dist/esm/data-structures/graph/abstract-graph.js.map +0 -1
- package/dist/esm/data-structures/graph/directed-graph.d.ts +0 -323
- package/dist/esm/data-structures/graph/directed-graph.js +0 -609
- 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 -84
- package/dist/esm/data-structures/graph/map-graph.js +0 -108
- package/dist/esm/data-structures/graph/map-graph.js.map +0 -1
- package/dist/esm/data-structures/graph/undirected-graph.d.ts +0 -231
- package/dist/esm/data-structures/graph/undirected-graph.js +0 -439
- package/dist/esm/data-structures/graph/undirected-graph.js.map +0 -1
- package/dist/esm/data-structures/hash/hash-map.d.ts +0 -519
- package/dist/esm/data-structures/hash/hash-map.js +0 -878
- 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 -578
- package/dist/esm/data-structures/heap/heap.js +0 -914
- 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 -68
- package/dist/esm/data-structures/heap/max-heap.js +0 -95
- package/dist/esm/data-structures/heap/max-heap.js.map +0 -1
- package/dist/esm/data-structures/heap/min-heap.d.ts +0 -68
- package/dist/esm/data-structures/heap/min-heap.js +0 -83
- 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 -885
- package/dist/esm/data-structures/linked-list/doubly-linked-list.js +0 -1236
- 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 -500
- package/dist/esm/data-structures/linked-list/singly-linked-list.js +0 -866
- 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 -134
- package/dist/esm/data-structures/linked-list/skip-linked-list.js +0 -243
- 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 -71
- package/dist/esm/data-structures/priority-queue/max-priority-queue.js +0 -101
- 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 -72
- package/dist/esm/data-structures/priority-queue/min-priority-queue.js +0 -90
- 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 -74
- package/dist/esm/data-structures/priority-queue/priority-queue.js +0 -92
- package/dist/esm/data-structures/priority-queue/priority-queue.js.map +0 -1
- package/dist/esm/data-structures/queue/deque.d.ts +0 -458
- package/dist/esm/data-structures/queue/deque.js +0 -915
- 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 -329
- package/dist/esm/data-structures/queue/queue.js +0 -452
- 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 -284
- package/dist/esm/data-structures/stack/stack.js +0 -342
- 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 -351
- package/dist/esm/data-structures/trie/trie.js +0 -592
- 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.d.ts +0 -9
- 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 -5
- 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.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 -21
- 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.js +0 -324
- package/dist/esm/utils/utils.js.map +0 -1
- package/test/performance/data-structures/binary-tree/avl-tree.test.mjs +0 -71
- package/test/performance/data-structures/binary-tree/red-black-tree.test.mjs +0 -81
- 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/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/index.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/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/linked-list/index.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/queue/index.d.ts +0 -0
- /package/dist/{cjs → types}/data-structures/stack/index.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}/index.d.ts +0 -0
- /package/dist/{cjs → types}/interfaces/doubly-linked-list.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/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/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/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
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BinaryIndexedTree = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* data-structure-typed
|
|
6
|
-
*
|
|
7
|
-
* @author Pablo Zeng
|
|
8
|
-
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
9
|
-
* @license MIT License
|
|
10
|
-
*/
|
|
11
|
-
const utils_1 = require("../../utils");
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
class BinaryIndexedTree {
|
|
16
|
-
/**
|
|
17
|
-
* The constructor initializes the properties of an object, including default frequency, maximum
|
|
18
|
-
* value, a freqMap data structure, the most significant bit, and the count of negative frequencies.
|
|
19
|
-
* @param - - `frequency`: The default frequency value. It is optional and has a default
|
|
20
|
-
* value of 0.
|
|
21
|
-
*/
|
|
22
|
-
constructor({ frequency = 0, max }) {
|
|
23
|
-
this._freq = frequency;
|
|
24
|
-
this._max = max;
|
|
25
|
-
this._freqMap = { 0: 0 };
|
|
26
|
-
this._msb = (0, utils_1.getMSB)(max);
|
|
27
|
-
this._negativeCount = frequency < 0 ? max : 0;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* The function returns the frequency map of numbers.
|
|
31
|
-
* @returns The `_freqMap` property, which is a record with number keys and number values, is being
|
|
32
|
-
* returned.
|
|
33
|
-
*/
|
|
34
|
-
get freqMap() {
|
|
35
|
-
return this._freqMap;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* The function returns the value of the _msb property.
|
|
39
|
-
* @returns The `_msb` property of the object.
|
|
40
|
-
*/
|
|
41
|
-
get msb() {
|
|
42
|
-
return this._msb;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* The function returns the value of the _negativeCount property.
|
|
46
|
-
* @returns The method is returning the value of the variable `_negativeCount`, which is of type
|
|
47
|
-
* `number`.
|
|
48
|
-
*/
|
|
49
|
-
get negativeCount() {
|
|
50
|
-
return this._negativeCount;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* The above function returns the value of the protected variable `_freq`.
|
|
54
|
-
* @returns The frequency value stored in the protected variable `_freq`.
|
|
55
|
-
*/
|
|
56
|
-
get freq() {
|
|
57
|
-
return this._freq;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* The above function returns the maximum value.
|
|
61
|
-
* @returns The maximum value stored in the variable `_max`.
|
|
62
|
-
*/
|
|
63
|
-
get max() {
|
|
64
|
-
return this._max;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* The function "readSingle" reads a single number from a specified index.
|
|
68
|
-
* @param {number} index - The `index` parameter is a number that represents the index of an element in a
|
|
69
|
-
* collection or array.
|
|
70
|
-
* @returns a number.
|
|
71
|
-
*/
|
|
72
|
-
readSingle(index) {
|
|
73
|
-
this._checkIndex(index);
|
|
74
|
-
return this._readSingle(index);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* The "update" function updates the value at a given index by adding a delta and triggers a callback
|
|
78
|
-
* to notify of the change.
|
|
79
|
-
* @param {number} position - The `index` parameter represents the index of the element that needs to be
|
|
80
|
-
* updated in the data structure.
|
|
81
|
-
* @param {number} change - The "delta" parameter represents the change in value that needs to be
|
|
82
|
-
* applied to the frequency at the specified index.
|
|
83
|
-
*/
|
|
84
|
-
update(position, change) {
|
|
85
|
-
this._checkIndex(position);
|
|
86
|
-
const freqCur = this._readSingle(position);
|
|
87
|
-
this._update(position, change);
|
|
88
|
-
this._updateNegativeCount(freqCur, freqCur + change);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* The function "writeSingle" checks the index and writes a single value with a given frequency.
|
|
92
|
-
* @param {number} index - The `index` parameter is a number that represents the index of an element. It
|
|
93
|
-
* is used to identify the specific element that needs to be written.
|
|
94
|
-
* @param {number} freq - The `freq` parameter represents the frequency value that needs to be
|
|
95
|
-
* written.
|
|
96
|
-
*/
|
|
97
|
-
writeSingle(index, freq) {
|
|
98
|
-
this._checkIndex(index);
|
|
99
|
-
this._writeSingle(index, freq);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* The read function takes a count parameter, checks if it is an integer, and returns the result of
|
|
103
|
-
* calling the _read function with the count parameter clamped between 0 and the maximum value.
|
|
104
|
-
* @param {number} count - The `count` parameter is a number that represents the number of items to
|
|
105
|
-
* read.
|
|
106
|
-
* @returns a number.
|
|
107
|
-
*/
|
|
108
|
-
read(count) {
|
|
109
|
-
if (!Number.isInteger(count)) {
|
|
110
|
-
throw new Error('Invalid count');
|
|
111
|
-
}
|
|
112
|
-
return this._read(Math.max(Math.min(count, this.max), 0));
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* The function returns the lower bound of a non-descending sequence that sums up to a given number.
|
|
116
|
-
* @param {number} sum - The `sum` parameter is a number that represents the target sum that we want
|
|
117
|
-
* to find in the sequence.
|
|
118
|
-
* @returns The lowerBound function is returning a number.
|
|
119
|
-
*/
|
|
120
|
-
lowerBound(sum) {
|
|
121
|
-
if (this.negativeCount > 0) {
|
|
122
|
-
throw new Error('Sequence is not non-descending');
|
|
123
|
-
}
|
|
124
|
-
return this._binarySearch(sum, (x, y) => x < y);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* The upperBound function returns the index of the first element in a sequence that is greater than
|
|
128
|
-
* or equal to a given sum.
|
|
129
|
-
* @param {number} sum - The "sum" parameter is a number that represents the target sum that we want
|
|
130
|
-
* to find in the sequence.
|
|
131
|
-
* @returns The upperBound function is returning a number.
|
|
132
|
-
*/
|
|
133
|
-
upperBound(sum) {
|
|
134
|
-
if (this.negativeCount > 0) {
|
|
135
|
-
throw new Error('Must not be descending');
|
|
136
|
-
}
|
|
137
|
-
return this._binarySearch(sum, (x, y) => x <= y);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* The function calculates the prefix sum of an array using a binary indexed tree.
|
|
141
|
-
* @param {number} i - The parameter "i" in the function "getPrefixSum" represents the index of the element in the
|
|
142
|
-
* array for which we want to calculate the prefix sum.
|
|
143
|
-
* @returns The function `getPrefixSum` returns the prefix sum of the elements in the binary indexed tree up to index
|
|
144
|
-
* `i`.
|
|
145
|
-
*/
|
|
146
|
-
getPrefixSum(i) {
|
|
147
|
-
this._checkIndex(i);
|
|
148
|
-
i++; // Convert to 1-based index
|
|
149
|
-
let sum = 0;
|
|
150
|
-
while (i > 0) {
|
|
151
|
-
sum += this._getFrequency(i);
|
|
152
|
-
i -= i & -i;
|
|
153
|
-
}
|
|
154
|
-
return sum;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* The function returns the value of a specific index in a freqMap data structure, or a default value if
|
|
158
|
-
* the index is not found.
|
|
159
|
-
* @param {number} index - The `index` parameter is a number that represents the index of a node in a
|
|
160
|
-
* freqMap data structure.
|
|
161
|
-
* @returns a number.
|
|
162
|
-
*/
|
|
163
|
-
_getFrequency(index) {
|
|
164
|
-
if (index in this.freqMap) {
|
|
165
|
-
return this.freqMap[index];
|
|
166
|
-
}
|
|
167
|
-
return this.freq * (index & -index);
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* The function _updateFrequency adds a delta value to the element at the specified index in the freqMap array.
|
|
171
|
-
* @param {number} index - The index parameter is a number that represents the index of the freqMap
|
|
172
|
-
* element that needs to be updated.
|
|
173
|
-
* @param {number} delta - The `delta` parameter represents the change in value that needs to be
|
|
174
|
-
* added to the freqMap at the specified `index`.
|
|
175
|
-
*/
|
|
176
|
-
_updateFrequency(index, delta) {
|
|
177
|
-
this.freqMap[index] = this._getFrequency(index) + delta;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* The function checks if the given index is valid and within the range.
|
|
181
|
-
* @param {number} index - The parameter "index" is of type number and represents the index value
|
|
182
|
-
* that needs to be checked.
|
|
183
|
-
*/
|
|
184
|
-
_checkIndex(index) {
|
|
185
|
-
if (!Number.isInteger(index)) {
|
|
186
|
-
throw new Error('Invalid index: Index must be an integer.');
|
|
187
|
-
}
|
|
188
|
-
if (index < 0 || index >= this.max) {
|
|
189
|
-
throw new Error('Index out of range: Index must be within the range [0, this.max).');
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* The function calculates the sum of elements in an array up to a given index using a binary indexed
|
|
194
|
-
* freqMap.
|
|
195
|
-
* @param {number} index - The `index` parameter is a number that represents the index of an element in a
|
|
196
|
-
* data structure.
|
|
197
|
-
* @returns a number.
|
|
198
|
-
*/
|
|
199
|
-
_readSingle(index) {
|
|
200
|
-
index = index + 1;
|
|
201
|
-
let sum = this._getFrequency(index);
|
|
202
|
-
const z = index - (index & -index);
|
|
203
|
-
index--;
|
|
204
|
-
while (index !== z) {
|
|
205
|
-
sum -= this._getFrequency(index);
|
|
206
|
-
index -= index & -index;
|
|
207
|
-
}
|
|
208
|
-
return sum;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* The function `_updateNegativeCount` updates a counter based on changes in frequency values.
|
|
212
|
-
* @param {number} freqCur - The current frequency value.
|
|
213
|
-
* @param {number} freqNew - The freqNew parameter represents the new frequency value.
|
|
214
|
-
*/
|
|
215
|
-
_updateNegativeCount(freqCur, freqNew) {
|
|
216
|
-
if (freqCur < 0 && freqNew >= 0) {
|
|
217
|
-
this._negativeCount--;
|
|
218
|
-
}
|
|
219
|
-
else if (freqCur >= 0 && freqNew < 0) {
|
|
220
|
-
this._negativeCount++;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* The `_update` function updates the values in a binary indexed freqMap starting from a given index and
|
|
225
|
-
* propagating the changes to its parent nodes.
|
|
226
|
-
* @param {number} index - The `index` parameter is a number that represents the index of the element in
|
|
227
|
-
* the data structure that needs to be updated.
|
|
228
|
-
* @param {number} delta - The `delta` parameter represents the change in value that needs to be
|
|
229
|
-
* applied to the elements in the data structure.
|
|
230
|
-
*/
|
|
231
|
-
_update(index, delta) {
|
|
232
|
-
index = index + 1;
|
|
233
|
-
while (index <= this.max) {
|
|
234
|
-
this._updateFrequency(index, delta);
|
|
235
|
-
index += index & -index;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* The `_writeSingle` function updates the frequency at a specific index and triggers a callback if
|
|
240
|
-
* the frequency has changed.
|
|
241
|
-
* @param {number} index - The `index` parameter is a number that represents the index of the element
|
|
242
|
-
* being modified or accessed.
|
|
243
|
-
* @param {number} freq - The `freq` parameter represents the new frequency value that needs to be
|
|
244
|
-
* written to the specified index `index`.
|
|
245
|
-
*/
|
|
246
|
-
_writeSingle(index, freq) {
|
|
247
|
-
const freqCur = this._readSingle(index);
|
|
248
|
-
this._update(index, freq - freqCur);
|
|
249
|
-
this._updateNegativeCount(freqCur, freq);
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* The `_read` function calculates the sum of values in a binary freqMap up to a given count.
|
|
253
|
-
* @param {number} count - The `count` parameter is a number that represents the number of elements
|
|
254
|
-
* to read from the freqMap.
|
|
255
|
-
* @returns the sum of the values obtained from calling the `_getFrequency` method for each index in the
|
|
256
|
-
* range from `count` to 1.
|
|
257
|
-
*/
|
|
258
|
-
_read(count) {
|
|
259
|
-
let index = count;
|
|
260
|
-
let sum = 0;
|
|
261
|
-
while (index) {
|
|
262
|
-
sum += this._getFrequency(index);
|
|
263
|
-
index -= index & -index;
|
|
264
|
-
}
|
|
265
|
-
return sum;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* The function `_binarySearch` performs a binary search to find the largest number that satisfies a given
|
|
269
|
-
* condition.
|
|
270
|
-
* @param {number} sum - The sum parameter is a number that represents the target sum value.
|
|
271
|
-
* @param before - The `before` parameter is a function that takes two numbers `x` and `y` as
|
|
272
|
-
* arguments and returns a boolean value. It is used to determine if `x` is less than or equal to
|
|
273
|
-
* `y`. The purpose of this function is to compare two numbers and determine their order.
|
|
274
|
-
* @returns the value of the variable "left".
|
|
275
|
-
*/
|
|
276
|
-
_binarySearch(sum, before) {
|
|
277
|
-
let left = 0;
|
|
278
|
-
let right = this.msb << 1;
|
|
279
|
-
let sumT = sum;
|
|
280
|
-
while (right > left + 1) {
|
|
281
|
-
const middle = (left + right) >> 1;
|
|
282
|
-
const sumM = this._getFrequency(middle);
|
|
283
|
-
if (middle <= this.max && before(sumM, sumT)) {
|
|
284
|
-
sumT -= sumM;
|
|
285
|
-
left = middle;
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
right = middle;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return left;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
exports.BinaryIndexedTree = BinaryIndexedTree;
|
|
295
|
-
//# sourceMappingURL=binary-indexed-tree.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"binary-indexed-tree.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/binary-indexed-tree.ts"],"names":[],"mappings":";;;AAAA;;;;;;GA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