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,880 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LinkedHashMap = exports.HashMap = void 0;
|
|
4
|
-
const base_1 = require("../base");
|
|
5
|
-
const utils_1 = require("../../utils");
|
|
6
|
-
/**
|
|
7
|
-
* 1. Key-Value Pair Storage: HashMap stores key-value pairs. Each key map to a value.
|
|
8
|
-
* 2. Fast Lookup: It's used when you need to quickly find, insert, or delete entries based on a key.
|
|
9
|
-
* 3. Unique Keys: Keys are unique.
|
|
10
|
-
* If you try to insert another entry with the same key, the new one will replace the old entry.
|
|
11
|
-
* 4. Unordered Collection: HashMap does not guarantee the order of entries, and the order may change over time.
|
|
12
|
-
* @example
|
|
13
|
-
* // should maintain insertion order
|
|
14
|
-
* const linkedHashMap = new LinkedHashMap<number, string>();
|
|
15
|
-
* linkedHashMap.set(1, 'A');
|
|
16
|
-
* linkedHashMap.set(2, 'B');
|
|
17
|
-
* linkedHashMap.set(3, 'C');
|
|
18
|
-
*
|
|
19
|
-
* const result = Array.from(linkedHashMap);
|
|
20
|
-
* console.log(result); // [
|
|
21
|
-
* // [1, 'A'],
|
|
22
|
-
* // [2, 'B'],
|
|
23
|
-
* // [3, 'C']
|
|
24
|
-
* // ]
|
|
25
|
-
* @example
|
|
26
|
-
* // fast lookup of values by key
|
|
27
|
-
* const hashMap = new HashMap<number, string>();
|
|
28
|
-
* hashMap.set(1, 'A');
|
|
29
|
-
* hashMap.set(2, 'B');
|
|
30
|
-
* hashMap.set(3, 'C');
|
|
31
|
-
*
|
|
32
|
-
* console.log(hashMap.get(1)); // 'A'
|
|
33
|
-
* console.log(hashMap.get(2)); // 'B'
|
|
34
|
-
* console.log(hashMap.get(3)); // 'C'
|
|
35
|
-
* console.log(hashMap.get(99)); // undefined
|
|
36
|
-
* @example
|
|
37
|
-
* // remove duplicates when adding multiple entries
|
|
38
|
-
* const hashMap = new HashMap<number, string>();
|
|
39
|
-
* hashMap.set(1, 'A');
|
|
40
|
-
* hashMap.set(2, 'B');
|
|
41
|
-
* hashMap.set(1, 'C'); // Update value for key 1
|
|
42
|
-
*
|
|
43
|
-
* console.log(hashMap.size); // 2
|
|
44
|
-
* console.log(hashMap.get(1)); // 'C'
|
|
45
|
-
* console.log(hashMap.get(2)); // 'B'
|
|
46
|
-
* @example
|
|
47
|
-
* // count occurrences of keys
|
|
48
|
-
* const data = [1, 2, 1, 3, 2, 1];
|
|
49
|
-
*
|
|
50
|
-
* const countMap = new HashMap<number, number>();
|
|
51
|
-
* for (const key of data) {
|
|
52
|
-
* countMap.set(key, (countMap.get(key) || 0) + 1);
|
|
53
|
-
* }
|
|
54
|
-
*
|
|
55
|
-
* console.log(countMap.get(1)); // 3
|
|
56
|
-
* console.log(countMap.get(2)); // 2
|
|
57
|
-
* console.log(countMap.get(3)); // 1
|
|
58
|
-
*/
|
|
59
|
-
class HashMap extends base_1.IterableEntryBase {
|
|
60
|
-
/**
|
|
61
|
-
* The constructor function initializes a HashMap object with an optional initial collection and
|
|
62
|
-
* options.
|
|
63
|
-
* @param entryOrRawElements - The `entryOrRawElements` parameter is an iterable collection of elements of a type
|
|
64
|
-
* `T`. It is an optional parameter and its default value is an empty array `[]`.
|
|
65
|
-
* @param [options] - The `options` parameter is an optional object that can contain two properties:
|
|
66
|
-
*/
|
|
67
|
-
constructor(entryOrRawElements = [], options) {
|
|
68
|
-
super();
|
|
69
|
-
this._store = {};
|
|
70
|
-
this._objMap = new Map();
|
|
71
|
-
this._size = 0;
|
|
72
|
-
this._hashFn = (key) => String(key);
|
|
73
|
-
if (options) {
|
|
74
|
-
const { hashFn, toEntryFn } = options;
|
|
75
|
-
if (hashFn)
|
|
76
|
-
this._hashFn = hashFn;
|
|
77
|
-
if (toEntryFn)
|
|
78
|
-
this._toEntryFn = toEntryFn;
|
|
79
|
-
}
|
|
80
|
-
if (entryOrRawElements) {
|
|
81
|
-
this.setMany(entryOrRawElements);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* The function returns the store object, which is a dictionary of HashMapStoreItem objects.
|
|
86
|
-
* @returns The store property is being returned. It is a dictionary-like object with string keys and
|
|
87
|
-
* values of type HashMapStoreItem<K, V>.
|
|
88
|
-
*/
|
|
89
|
-
get store() {
|
|
90
|
-
return this._store;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* The function returns the object map.
|
|
94
|
-
* @returns The `objMap` property is being returned, which is a `Map` object with keys of type
|
|
95
|
-
* `object` and values of type `V`.
|
|
96
|
-
*/
|
|
97
|
-
get objMap() {
|
|
98
|
-
return this._objMap;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* The function returns the value of the _toEntryFn property.
|
|
102
|
-
* @returns The function being returned is `this._toEntryFn`.
|
|
103
|
-
*/
|
|
104
|
-
get toEntryFn() {
|
|
105
|
-
return this._toEntryFn;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* The function returns the size of an object.
|
|
109
|
-
* @returns The size of the object, which is a number.
|
|
110
|
-
*/
|
|
111
|
-
get size() {
|
|
112
|
-
return this._size;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* The hasFn function is a function that takes in an item and returns a boolean
|
|
116
|
-
* indicating whether the item is contained within the hash table.
|
|
117
|
-
*
|
|
118
|
-
* @return The hash function
|
|
119
|
-
*/
|
|
120
|
-
get hashFn() {
|
|
121
|
-
return this._hashFn;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Time Complexity: O(1)
|
|
125
|
-
* Space Complexity: O(1)
|
|
126
|
-
*
|
|
127
|
-
* The function checks if a given element is an array with exactly two elements.
|
|
128
|
-
* @param {any} rawElement - The `rawElement` parameter is of type `any`, which means it can be any
|
|
129
|
-
* data type.
|
|
130
|
-
* @returns a boolean value.
|
|
131
|
-
*/
|
|
132
|
-
isEntry(rawElement) {
|
|
133
|
-
return Array.isArray(rawElement) && rawElement.length === 2;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Time Complexity: O(1)
|
|
137
|
-
* Space Complexity: O(1)
|
|
138
|
-
*
|
|
139
|
-
* The function checks if the size of an object is equal to zero and returns a boolean value.
|
|
140
|
-
* @returns A boolean value indicating whether the size of the object is 0 or not.
|
|
141
|
-
*/
|
|
142
|
-
isEmpty() {
|
|
143
|
-
return this._size === 0;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Time Complexity: O(1)
|
|
147
|
-
* Space Complexity: O(1)
|
|
148
|
-
*
|
|
149
|
-
* The clear() function resets the state of an object by clearing its internal store, object map, and
|
|
150
|
-
* size.
|
|
151
|
-
*/
|
|
152
|
-
clear() {
|
|
153
|
-
this._store = {};
|
|
154
|
-
this._objMap.clear();
|
|
155
|
-
this._size = 0;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Time Complexity: O(1)
|
|
159
|
-
* Space Complexity: O(1)
|
|
160
|
-
*
|
|
161
|
-
* The `set` function adds a key-value pair to a map-like data structure, incrementing the size if
|
|
162
|
-
* the key is not already present.
|
|
163
|
-
* @param {K} key - The key parameter is the key used to identify the value in the data structure. It
|
|
164
|
-
* can be of any type, but if it is an object, it will be stored in a Map, otherwise it will be
|
|
165
|
-
* stored in a regular JavaScript object.
|
|
166
|
-
* @param {V} value - The value parameter represents the value that you want to associate with the
|
|
167
|
-
* key in the data structure.
|
|
168
|
-
*/
|
|
169
|
-
set(key, value) {
|
|
170
|
-
if (this._isObjKey(key)) {
|
|
171
|
-
if (!this.objMap.has(key)) {
|
|
172
|
-
this._size++;
|
|
173
|
-
}
|
|
174
|
-
this.objMap.set(key, value);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
const strKey = this._getNoObjKey(key);
|
|
178
|
-
if (this.store[strKey] === undefined) {
|
|
179
|
-
this._size++;
|
|
180
|
-
}
|
|
181
|
-
this._store[strKey] = { key, value };
|
|
182
|
-
}
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Time Complexity: O(k)
|
|
187
|
-
* Space Complexity: O(k)
|
|
188
|
-
*
|
|
189
|
-
* The function `setMany` takes an iterable collection of objects, maps each object to a key-value
|
|
190
|
-
* pair using a mapping function, and sets each key-value pair in the current object.
|
|
191
|
-
* @param entryOrRawElements - The `entryOrRawElements` parameter is an iterable collection of elements of a type
|
|
192
|
-
* `T`.
|
|
193
|
-
* @returns The `setMany` function is returning an array of booleans.
|
|
194
|
-
*/
|
|
195
|
-
setMany(entryOrRawElements) {
|
|
196
|
-
const results = [];
|
|
197
|
-
for (const rawEle of entryOrRawElements) {
|
|
198
|
-
let key, value;
|
|
199
|
-
if (this.isEntry(rawEle)) {
|
|
200
|
-
key = rawEle[0];
|
|
201
|
-
value = rawEle[1];
|
|
202
|
-
}
|
|
203
|
-
else if (this._toEntryFn) {
|
|
204
|
-
const item = this._toEntryFn(rawEle);
|
|
205
|
-
key = item[0];
|
|
206
|
-
value = item[1];
|
|
207
|
-
}
|
|
208
|
-
if (key !== undefined && value !== undefined)
|
|
209
|
-
results.push(this.set(key, value));
|
|
210
|
-
}
|
|
211
|
-
return results;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Time Complexity: O(1)
|
|
215
|
-
* Space Complexity: O(1)
|
|
216
|
-
*
|
|
217
|
-
* The `get` function retrieves a value from a map based on a given key, either from an object map or
|
|
218
|
-
* a string map.
|
|
219
|
-
* @param {K} key - The `key` parameter is the key used to retrieve a value from the map. It can be
|
|
220
|
-
* of any type, but it should be compatible with the key type used when the map was created.
|
|
221
|
-
* @returns The method `get(key: K)` returns a value of type `V` if the key exists in the `_objMap`
|
|
222
|
-
* or `_store`, otherwise it returns `undefined`.
|
|
223
|
-
*/
|
|
224
|
-
get(key) {
|
|
225
|
-
var _a;
|
|
226
|
-
if (this._isObjKey(key)) {
|
|
227
|
-
return this.objMap.get(key);
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
const strKey = this._getNoObjKey(key);
|
|
231
|
-
return (_a = this._store[strKey]) === null || _a === void 0 ? void 0 : _a.value;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Time Complexity: O(1)
|
|
236
|
-
* Space Complexity: O(1)
|
|
237
|
-
*
|
|
238
|
-
* The `has` function checks if a given key exists in the `_objMap` or `_store` based on whether it
|
|
239
|
-
* is an object key or not.
|
|
240
|
-
* @param {K} key - The parameter "key" is of type K, which means it can be any type.
|
|
241
|
-
* @returns The `has` method is returning a boolean value.
|
|
242
|
-
*/
|
|
243
|
-
has(key) {
|
|
244
|
-
if (this._isObjKey(key)) {
|
|
245
|
-
return this.objMap.has(key);
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
const strKey = this._getNoObjKey(key);
|
|
249
|
-
return strKey in this.store;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Time Complexity: O(1)
|
|
254
|
-
* Space Complexity: O(1)
|
|
255
|
-
*
|
|
256
|
-
* The `delete` function removes an element from a map-like data structure based on the provided key.
|
|
257
|
-
* @param {K} key - The `key` parameter is the key of the element that you want to delete from the
|
|
258
|
-
* data structure.
|
|
259
|
-
* @returns The `delete` method returns a boolean value. It returns `true` if the key was
|
|
260
|
-
* successfully deleted from the map, and `false` if the key was not found in the map.
|
|
261
|
-
*/
|
|
262
|
-
delete(key) {
|
|
263
|
-
if (this._isObjKey(key)) {
|
|
264
|
-
if (this.objMap.has(key)) {
|
|
265
|
-
this._size--;
|
|
266
|
-
}
|
|
267
|
-
return this.objMap.delete(key);
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
const strKey = this._getNoObjKey(key);
|
|
271
|
-
if (strKey in this.store) {
|
|
272
|
-
delete this.store[strKey];
|
|
273
|
-
this._size--;
|
|
274
|
-
return true;
|
|
275
|
-
}
|
|
276
|
-
return false;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Time Complexity: O(n)
|
|
281
|
-
* Space Complexity: O(n)
|
|
282
|
-
*
|
|
283
|
-
* The clone function creates a new HashMap with the same key-value pairs as
|
|
284
|
-
* this one. The clone function is useful for creating a copy of an existing
|
|
285
|
-
* HashMap, and then modifying that copy without affecting the original.
|
|
286
|
-
*
|
|
287
|
-
* @return A new hashmap with the same values as this one
|
|
288
|
-
*/
|
|
289
|
-
clone() {
|
|
290
|
-
return new HashMap(this, { hashFn: this._hashFn, toEntryFn: this._toEntryFn });
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Time Complexity: O(n)
|
|
294
|
-
* Space Complexity: O(n)
|
|
295
|
-
*
|
|
296
|
-
* The `map` function in TypeScript creates a new HashMap by applying a callback function to each
|
|
297
|
-
* key-value pair in the original HashMap.
|
|
298
|
-
* @param callbackfn - The callback function that will be called for each key-value pair in the
|
|
299
|
-
* HashMap. It takes four parameters:
|
|
300
|
-
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
301
|
-
* to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
|
|
302
|
-
* be passed as the `this` value to the `callbackfn` function. If `thisArg
|
|
303
|
-
* @returns The `map` method is returning a new `HashMap` object with the transformed values based on
|
|
304
|
-
* the provided callback function.
|
|
305
|
-
*/
|
|
306
|
-
map(callbackfn, thisArg) {
|
|
307
|
-
const resultMap = new HashMap();
|
|
308
|
-
let index = 0;
|
|
309
|
-
for (const [key, value] of this) {
|
|
310
|
-
resultMap.set(key, callbackfn.call(thisArg, key, value, index++, this));
|
|
311
|
-
}
|
|
312
|
-
return resultMap;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Time Complexity: O(n)
|
|
316
|
-
* Space Complexity: O(n)
|
|
317
|
-
*
|
|
318
|
-
* The `filter` function creates a new HashMap containing key-value pairs from the original HashMap
|
|
319
|
-
* that satisfy a given predicate function.
|
|
320
|
-
* @param predicate - The predicate parameter is a function that takes four arguments: value, key,
|
|
321
|
-
* index, and map. It is used to determine whether an element should be included in the filtered map
|
|
322
|
-
* or not. The function should return a boolean value - true if the element should be included, and
|
|
323
|
-
* false otherwise.
|
|
324
|
-
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
325
|
-
* to be used as `this` when executing the `predicate` function. If `thisArg` is provided, it will be
|
|
326
|
-
* passed as the `this` value to the `predicate` function. If `thisArg` is
|
|
327
|
-
* @returns The `filter` method is returning a new `HashMap` object that contains the key-value pairs
|
|
328
|
-
* from the original `HashMap` that pass the provided `predicate` function.
|
|
329
|
-
*/
|
|
330
|
-
filter(predicate, thisArg) {
|
|
331
|
-
const filteredMap = new HashMap();
|
|
332
|
-
let index = 0;
|
|
333
|
-
for (const [key, value] of this) {
|
|
334
|
-
if (predicate.call(thisArg, key, value, index++, this)) {
|
|
335
|
-
filteredMap.set(key, value);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
return filteredMap;
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* The function returns an iterator that yields key-value pairs from both an object store and an
|
|
342
|
-
* object map.
|
|
343
|
-
*/
|
|
344
|
-
*_getIterator() {
|
|
345
|
-
for (const node of Object.values(this.store)) {
|
|
346
|
-
yield [node.key, node.value];
|
|
347
|
-
}
|
|
348
|
-
for (const node of this.objMap) {
|
|
349
|
-
yield node;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* The function checks if a given key is an object or a function.
|
|
354
|
-
* @param {any} key - The parameter "key" can be of any type.
|
|
355
|
-
* @returns a boolean value.
|
|
356
|
-
*/
|
|
357
|
-
_isObjKey(key) {
|
|
358
|
-
const keyType = typeof key;
|
|
359
|
-
return (keyType === 'object' || keyType === 'function') && key !== null;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* The function `_getNoObjKey` takes a key and returns a string representation of the key, handling
|
|
363
|
-
* different types of keys.
|
|
364
|
-
* @param {K} key - The `key` parameter is of type `K`, which represents the type of the key being
|
|
365
|
-
* passed to the `_getNoObjKey` function.
|
|
366
|
-
* @returns a string value.
|
|
367
|
-
*/
|
|
368
|
-
_getNoObjKey(key) {
|
|
369
|
-
const keyType = typeof key;
|
|
370
|
-
let strKey;
|
|
371
|
-
if (keyType !== 'string' && keyType !== 'number' && keyType !== 'symbol') {
|
|
372
|
-
strKey = this._hashFn(key);
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
if (keyType === 'number') {
|
|
376
|
-
// TODO numeric key should has its own hash
|
|
377
|
-
strKey = key;
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
strKey = key;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
return strKey;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
exports.HashMap = HashMap;
|
|
387
|
-
/**
|
|
388
|
-
* 1. Maintaining the Order of Element Insertion: Unlike HashMap, LinkedHashMap maintains the order in which entries are inserted. Therefore, when you traverse it, entries will be returned in the order they were inserted into the map.
|
|
389
|
-
* 2. Based on Hash Table and Linked List: It combines the structures of a hash table and a linked list, using the hash table to ensure fast access, while maintaining the order of entries through the linked list.
|
|
390
|
-
* 3. Time Complexity: Similar to HashMap, LinkedHashMap offers constant-time performance for get and put operations in most cases.
|
|
391
|
-
*/
|
|
392
|
-
class LinkedHashMap extends base_1.IterableEntryBase {
|
|
393
|
-
/**
|
|
394
|
-
* The constructor initializes a LinkedHashMap object with an optional raw collection and options.
|
|
395
|
-
* @param entryOrRawElements - The `entryOrRawElements` parameter is an iterable collection of elements. It is
|
|
396
|
-
* used to initialize the HashMapLinked instance with key-value pairs. Each element in the
|
|
397
|
-
* `entryOrRawElements` is converted to a key-value pair using the `toEntryFn` function (if provided) and
|
|
398
|
-
* then added to the HashMap
|
|
399
|
-
* @param [options] - The `options` parameter is an optional object that can contain the following
|
|
400
|
-
* properties:
|
|
401
|
-
*/
|
|
402
|
-
constructor(entryOrRawElements = [], options) {
|
|
403
|
-
super();
|
|
404
|
-
this._hashFn = (key) => String(key);
|
|
405
|
-
this._objHashFn = (key) => key;
|
|
406
|
-
this._noObjMap = {};
|
|
407
|
-
this._objMap = new WeakMap();
|
|
408
|
-
this._toEntryFn = (rawElement) => {
|
|
409
|
-
if (this.isEntry(rawElement)) {
|
|
410
|
-
// TODO, For performance optimization, it may be necessary to only inspect the first element traversed.
|
|
411
|
-
return rawElement;
|
|
412
|
-
}
|
|
413
|
-
else {
|
|
414
|
-
throw new Error("If the provided entryOrRawElements does not adhere to the [key, value] type format, the toEntryFn in the constructor's options parameter needs to specified.");
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
this._size = 0;
|
|
418
|
-
this._sentinel = {};
|
|
419
|
-
this._sentinel.prev = this._sentinel.next = this._head = this._tail = this._sentinel;
|
|
420
|
-
if (options) {
|
|
421
|
-
const { hashFn, objHashFn, toEntryFn } = options;
|
|
422
|
-
if (hashFn)
|
|
423
|
-
this._hashFn = hashFn;
|
|
424
|
-
if (objHashFn)
|
|
425
|
-
this._objHashFn = objHashFn;
|
|
426
|
-
if (toEntryFn) {
|
|
427
|
-
this._toEntryFn = toEntryFn;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
if (entryOrRawElements) {
|
|
431
|
-
this.setMany(entryOrRawElements);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* The function returns the hash function used for generating a hash value for a given key.
|
|
436
|
-
* @returns The hash function that takes a key of type K and returns a string.
|
|
437
|
-
*/
|
|
438
|
-
get hashFn() {
|
|
439
|
-
return this._hashFn;
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* The function returns the object hash function.
|
|
443
|
-
* @returns The function `objHashFn` is being returned.
|
|
444
|
-
*/
|
|
445
|
-
get objHashFn() {
|
|
446
|
-
return this._objHashFn;
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* The function returns a record of HashMapLinkedNode objects with string keys.
|
|
450
|
-
* @returns The method is returning a Record object, which is a TypeScript type that represents an
|
|
451
|
-
* object with string keys and values that are HashMapLinkedNode objects with keys of type K and
|
|
452
|
-
* values of type V or undefined.
|
|
453
|
-
*/
|
|
454
|
-
get noObjMap() {
|
|
455
|
-
return this._noObjMap;
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* The function returns the WeakMap object used to map objects to HashMapLinkedNode instances.
|
|
459
|
-
* @returns The `objMap` property is being returned.
|
|
460
|
-
*/
|
|
461
|
-
get objMap() {
|
|
462
|
-
return this._objMap;
|
|
463
|
-
}
|
|
464
|
-
/**
|
|
465
|
-
* The function returns the head node of a HashMapLinkedNode.
|
|
466
|
-
* @returns The method `getHead()` is returning a `HashMapLinkedNode` object with key type `K` and
|
|
467
|
-
* a value type `V | undefined`.
|
|
468
|
-
*/
|
|
469
|
-
get head() {
|
|
470
|
-
return this._head;
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* The function returns the tail node of a HashMapLinkedNode.
|
|
474
|
-
* @returns The `_tail` property of type `HashMapLinkedNode<K, V | undefined>` is being returned.
|
|
475
|
-
*/
|
|
476
|
-
get tail() {
|
|
477
|
-
return this._tail;
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* The function returns the value of the _toEntryFn property.
|
|
481
|
-
* @returns The function being returned is `this._toEntryFn`.
|
|
482
|
-
*/
|
|
483
|
-
get toEntryFn() {
|
|
484
|
-
return this._toEntryFn;
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* The function returns the size of an object.
|
|
488
|
-
* @returns The size of the object.
|
|
489
|
-
*/
|
|
490
|
-
get size() {
|
|
491
|
-
return this._size;
|
|
492
|
-
}
|
|
493
|
-
/**
|
|
494
|
-
* Time Complexity: O(1)
|
|
495
|
-
* Space Complexity: O(1)
|
|
496
|
-
*
|
|
497
|
-
* The function returns the key-value pair at the front of a data structure.
|
|
498
|
-
* @returns The front element of the data structure, represented as a tuple with a key (K) and a
|
|
499
|
-
* value (V).
|
|
500
|
-
*/
|
|
501
|
-
get first() {
|
|
502
|
-
if (this._size === 0)
|
|
503
|
-
return;
|
|
504
|
-
return [this.head.key, this.head.value];
|
|
505
|
-
}
|
|
506
|
-
/**
|
|
507
|
-
* Time Complexity: O(1)
|
|
508
|
-
* Space Complexity: O(1)
|
|
509
|
-
*
|
|
510
|
-
* The function returns the key-value pair at the end of a data structure.
|
|
511
|
-
* @returns The method is returning an array containing the key-value pair of the tail element in the
|
|
512
|
-
* data structure.
|
|
513
|
-
*/
|
|
514
|
-
get last() {
|
|
515
|
-
if (this._size === 0)
|
|
516
|
-
return;
|
|
517
|
-
return [this.tail.key, this.tail.value];
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
* The `begin()` function in TypeScript iterates over a linked list and yields key-value pairs.
|
|
521
|
-
*/
|
|
522
|
-
*begin() {
|
|
523
|
-
let node = this.head;
|
|
524
|
-
while (node !== this._sentinel) {
|
|
525
|
-
yield [node.key, node.value];
|
|
526
|
-
node = node.next;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* The function `reverseBegin()` iterates over a linked list in reverse order, yielding each node's
|
|
531
|
-
* key and value.
|
|
532
|
-
*/
|
|
533
|
-
*reverseBegin() {
|
|
534
|
-
let node = this.tail;
|
|
535
|
-
while (node !== this._sentinel) {
|
|
536
|
-
yield [node.key, node.value];
|
|
537
|
-
node = node.prev;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Time Complexity: O(1)
|
|
542
|
-
* Space Complexity: O(1)
|
|
543
|
-
*
|
|
544
|
-
* The `set` function adds a new key-value pair to a data structure, either using an object key or a
|
|
545
|
-
* string key.
|
|
546
|
-
* @param {K} key - The `key` parameter is the key to be set in the data structure. It can be of any
|
|
547
|
-
* type, but typically it is a string or symbol.
|
|
548
|
-
* @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the
|
|
549
|
-
* value associated with the key being set in the data structure.
|
|
550
|
-
* @returns the size of the data structure after the key-value pair has been set.
|
|
551
|
-
*/
|
|
552
|
-
set(key, value) {
|
|
553
|
-
let node;
|
|
554
|
-
const isNewKey = !this.has(key); // Check if the key is new
|
|
555
|
-
if ((0, utils_1.isWeakKey)(key)) {
|
|
556
|
-
const hash = this._objHashFn(key);
|
|
557
|
-
node = this.objMap.get(hash);
|
|
558
|
-
if (!node && isNewKey) {
|
|
559
|
-
// Create a new node
|
|
560
|
-
node = { key: hash, value, prev: this.tail, next: this._sentinel };
|
|
561
|
-
this.objMap.set(hash, node);
|
|
562
|
-
}
|
|
563
|
-
else if (node) {
|
|
564
|
-
// Update the value of an existing node
|
|
565
|
-
node.value = value;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
const hash = this._hashFn(key);
|
|
570
|
-
node = this.noObjMap[hash];
|
|
571
|
-
if (!node && isNewKey) {
|
|
572
|
-
this.noObjMap[hash] = node = { key, value, prev: this.tail, next: this._sentinel };
|
|
573
|
-
}
|
|
574
|
-
else if (node) {
|
|
575
|
-
// Update the value of an existing node
|
|
576
|
-
node.value = value;
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
if (node && isNewKey) {
|
|
580
|
-
// Update the head and tail of the linked list
|
|
581
|
-
if (this._size === 0) {
|
|
582
|
-
this._head = node;
|
|
583
|
-
this._sentinel.next = node;
|
|
584
|
-
}
|
|
585
|
-
else {
|
|
586
|
-
this.tail.next = node;
|
|
587
|
-
node.prev = this.tail; // Make sure that the prev of the new node points to the current tail node
|
|
588
|
-
}
|
|
589
|
-
this._tail = node;
|
|
590
|
-
this._sentinel.prev = node;
|
|
591
|
-
this._size++;
|
|
592
|
-
}
|
|
593
|
-
return true;
|
|
594
|
-
}
|
|
595
|
-
/**
|
|
596
|
-
* Time Complexity: O(k)
|
|
597
|
-
* Space Complexity: O(k)
|
|
598
|
-
*
|
|
599
|
-
* The function `setMany` takes an iterable collection, converts each element into a key-value pair
|
|
600
|
-
* using a provided function, and sets each key-value pair in the current object, returning an array
|
|
601
|
-
* of booleans indicating the success of each set operation.
|
|
602
|
-
* @param entryOrRawElements - The entryOrRawElements parameter is an iterable collection of elements of type
|
|
603
|
-
* R.
|
|
604
|
-
* @returns The `setMany` function returns an array of booleans.
|
|
605
|
-
*/
|
|
606
|
-
setMany(entryOrRawElements) {
|
|
607
|
-
const results = [];
|
|
608
|
-
for (const rawEle of entryOrRawElements) {
|
|
609
|
-
let key, value;
|
|
610
|
-
if (this.isEntry(rawEle)) {
|
|
611
|
-
key = rawEle[0];
|
|
612
|
-
value = rawEle[1];
|
|
613
|
-
}
|
|
614
|
-
else if (this._toEntryFn) {
|
|
615
|
-
const item = this._toEntryFn(rawEle);
|
|
616
|
-
key = item[0];
|
|
617
|
-
value = item[1];
|
|
618
|
-
}
|
|
619
|
-
if (key !== undefined && value !== undefined)
|
|
620
|
-
results.push(this.set(key, value));
|
|
621
|
-
}
|
|
622
|
-
return results;
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
* Time Complexity: O(1)
|
|
626
|
-
* Space Complexity: O(1)
|
|
627
|
-
*
|
|
628
|
-
* The function checks if a given key exists in a map, using different logic depending on whether the
|
|
629
|
-
* key is a weak key or not.
|
|
630
|
-
* @param {K} key - The `key` parameter is the key that is being checked for existence in the map.
|
|
631
|
-
* @returns The method `has` is returning a boolean value.
|
|
632
|
-
*/
|
|
633
|
-
has(key) {
|
|
634
|
-
if ((0, utils_1.isWeakKey)(key)) {
|
|
635
|
-
const hash = this._objHashFn(key);
|
|
636
|
-
return this.objMap.has(hash);
|
|
637
|
-
}
|
|
638
|
-
else {
|
|
639
|
-
const hash = this._hashFn(key);
|
|
640
|
-
return hash in this.noObjMap;
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
/**
|
|
644
|
-
* Time Complexity: O(1)
|
|
645
|
-
* Space Complexity: O(1)
|
|
646
|
-
*
|
|
647
|
-
* The function `get` retrieves the value associated with a given key from a map, either by using the
|
|
648
|
-
* key directly or by using an index stored in the key object.
|
|
649
|
-
* @param {K} key - The `key` parameter is the key used to retrieve a value from the map. It can be
|
|
650
|
-
* of any type, but typically it is a string or symbol.
|
|
651
|
-
* @returns The value associated with the given key is being returned. If the key is an object key,
|
|
652
|
-
* the value is retrieved from the `_nodes` array using the index stored in the `OBJ_KEY_INDEX`
|
|
653
|
-
* property of the key. If the key is a string key, the value is retrieved from the `_noObjMap` object
|
|
654
|
-
* using the key itself. If the key is not found, `undefined` is
|
|
655
|
-
*/
|
|
656
|
-
get(key) {
|
|
657
|
-
if ((0, utils_1.isWeakKey)(key)) {
|
|
658
|
-
const hash = this._objHashFn(key);
|
|
659
|
-
const node = this.objMap.get(hash);
|
|
660
|
-
return node ? node.value : undefined;
|
|
661
|
-
}
|
|
662
|
-
else {
|
|
663
|
-
const hash = this._hashFn(key);
|
|
664
|
-
const node = this.noObjMap[hash];
|
|
665
|
-
return node ? node.value : undefined;
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
/**
|
|
669
|
-
* Time Complexity: O(n)
|
|
670
|
-
* Space Complexity: O(1)
|
|
671
|
-
*
|
|
672
|
-
* The function `at` retrieves the key-value pair at a specified index in a linked list.
|
|
673
|
-
* @param {number} index - The index parameter is a number that represents the position of the
|
|
674
|
-
* element we want to retrieve from the data structure.
|
|
675
|
-
* @returns The method `at(index: number)` is returning an array containing the key-value pair at
|
|
676
|
-
* the specified index in the data structure. The key-value pair is represented as a tuple `[K, V]`,
|
|
677
|
-
* where `K` is the key and `V` is the value.
|
|
678
|
-
*/
|
|
679
|
-
at(index) {
|
|
680
|
-
(0, utils_1.rangeCheck)(index, 0, this._size - 1);
|
|
681
|
-
let node = this.head;
|
|
682
|
-
while (index--) {
|
|
683
|
-
node = node.next;
|
|
684
|
-
}
|
|
685
|
-
return node.value;
|
|
686
|
-
}
|
|
687
|
-
/**
|
|
688
|
-
* Time Complexity: O(1)
|
|
689
|
-
* Space Complexity: O(1)
|
|
690
|
-
*
|
|
691
|
-
* The `delete` function removes a key-value pair from a map-like data structure.
|
|
692
|
-
* @param {K} key - The `key` parameter is the key that you want to delete from the data structure.
|
|
693
|
-
* It can be of any type, but typically it is a string or an object.
|
|
694
|
-
* @returns a boolean value. It returns `true` if the deletion was successful, and `false` if the key
|
|
695
|
-
* was not found.
|
|
696
|
-
*/
|
|
697
|
-
delete(key) {
|
|
698
|
-
let node;
|
|
699
|
-
if ((0, utils_1.isWeakKey)(key)) {
|
|
700
|
-
const hash = this._objHashFn(key);
|
|
701
|
-
// Get nodes from WeakMap
|
|
702
|
-
node = this.objMap.get(hash);
|
|
703
|
-
if (!node) {
|
|
704
|
-
return false; // If the node does not exist, return false
|
|
705
|
-
}
|
|
706
|
-
// Remove nodes from WeakMap
|
|
707
|
-
this.objMap.delete(hash);
|
|
708
|
-
}
|
|
709
|
-
else {
|
|
710
|
-
const hash = this._hashFn(key);
|
|
711
|
-
// Get nodes from noObjMap
|
|
712
|
-
node = this.noObjMap[hash];
|
|
713
|
-
if (!node) {
|
|
714
|
-
return false; // If the node does not exist, return false
|
|
715
|
-
}
|
|
716
|
-
// Remove nodes from orgMap
|
|
717
|
-
delete this.noObjMap[hash];
|
|
718
|
-
}
|
|
719
|
-
// Remove node from doubly linked list
|
|
720
|
-
this._deleteNode(node);
|
|
721
|
-
return true;
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* Time Complexity: O(n)
|
|
725
|
-
* Space Complexity: O(1)
|
|
726
|
-
*
|
|
727
|
-
* The `deleteAt` function deletes a node at a specified index in a linked list.
|
|
728
|
-
* @param {number} index - The index parameter represents the position at which the node should be
|
|
729
|
-
* deleted in the linked list.
|
|
730
|
-
* @returns The size of the list after deleting the element at the specified index.
|
|
731
|
-
*/
|
|
732
|
-
deleteAt(index) {
|
|
733
|
-
(0, utils_1.rangeCheck)(index, 0, this._size - 1);
|
|
734
|
-
let node = this.head;
|
|
735
|
-
while (index--) {
|
|
736
|
-
node = node.next;
|
|
737
|
-
}
|
|
738
|
-
return this._deleteNode(node);
|
|
739
|
-
}
|
|
740
|
-
/**
|
|
741
|
-
* Time Complexity: O(1)
|
|
742
|
-
* Space Complexity: O(1)
|
|
743
|
-
*
|
|
744
|
-
* The function checks if a data structure is empty by comparing its size to zero.
|
|
745
|
-
* @returns The method is returning a boolean value indicating whether the size of the object is 0 or
|
|
746
|
-
* not.
|
|
747
|
-
*/
|
|
748
|
-
isEmpty() {
|
|
749
|
-
return this._size === 0;
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
* The function checks if a given element is an array with exactly two elements.
|
|
753
|
-
* @param {any} rawElement - The `rawElement` parameter is of type `any`, which means it can be any
|
|
754
|
-
* data type.
|
|
755
|
-
* @returns a boolean value.
|
|
756
|
-
*/
|
|
757
|
-
isEntry(rawElement) {
|
|
758
|
-
return Array.isArray(rawElement) && rawElement.length === 2;
|
|
759
|
-
}
|
|
760
|
-
/**
|
|
761
|
-
* Time Complexity: O(1)
|
|
762
|
-
* Space Complexity: O(1)
|
|
763
|
-
*
|
|
764
|
-
* The `clear` function clears all the entries in a data structure and resets its properties.
|
|
765
|
-
*/
|
|
766
|
-
clear() {
|
|
767
|
-
this._noObjMap = {};
|
|
768
|
-
this._size = 0;
|
|
769
|
-
this._head = this._tail = this._sentinel.prev = this._sentinel.next = this._sentinel;
|
|
770
|
-
}
|
|
771
|
-
/**
|
|
772
|
-
* Time Complexity: O(n)
|
|
773
|
-
* Space Complexity: O(n)
|
|
774
|
-
*
|
|
775
|
-
* The `clone` function creates a new instance of a `LinkedHashMap` with the same key-value pairs as
|
|
776
|
-
* the original.
|
|
777
|
-
* @returns The `clone()` method is returning a new instance of `LinkedHashMap<K, V>` that is a clone
|
|
778
|
-
* of the original `LinkedHashMap` object.
|
|
779
|
-
*/
|
|
780
|
-
clone() {
|
|
781
|
-
const cloned = new LinkedHashMap([], { hashFn: this._hashFn, objHashFn: this._objHashFn });
|
|
782
|
-
for (const entry of this) {
|
|
783
|
-
const [key, value] = entry;
|
|
784
|
-
cloned.set(key, value);
|
|
785
|
-
}
|
|
786
|
-
return cloned;
|
|
787
|
-
}
|
|
788
|
-
/**
|
|
789
|
-
* Time Complexity: O(n)
|
|
790
|
-
* Space Complexity: O(n)
|
|
791
|
-
*
|
|
792
|
-
* The `filter` function creates a new `LinkedHashMap` containing key-value pairs from the original
|
|
793
|
-
* map that satisfy a given predicate function.
|
|
794
|
-
* @param predicate - The `predicate` parameter is a callback function that takes four arguments:
|
|
795
|
-
* `value`, `key`, `index`, and `this`. It should return a boolean value indicating whether the
|
|
796
|
-
* current element should be included in the filtered map or not.
|
|
797
|
-
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
|
|
798
|
-
* specify the value of `this` within the `predicate` function. It is used when you want to bind a
|
|
799
|
-
* specific object as the context for the `predicate` function. If `thisArg` is not provided, `this
|
|
800
|
-
* @returns a new `LinkedHashMap` object that contains the key-value pairs from the original
|
|
801
|
-
* `LinkedHashMap` object that satisfy the given predicate function.
|
|
802
|
-
*/
|
|
803
|
-
filter(predicate, thisArg) {
|
|
804
|
-
const filteredMap = new LinkedHashMap();
|
|
805
|
-
let index = 0;
|
|
806
|
-
for (const [key, value] of this) {
|
|
807
|
-
if (predicate.call(thisArg, key, value, index, this)) {
|
|
808
|
-
filteredMap.set(key, value);
|
|
809
|
-
}
|
|
810
|
-
index++;
|
|
811
|
-
}
|
|
812
|
-
return filteredMap;
|
|
813
|
-
}
|
|
814
|
-
/**
|
|
815
|
-
* Time Complexity: O(n)
|
|
816
|
-
* Space Complexity: O(n)
|
|
817
|
-
*
|
|
818
|
-
* The `map` function in TypeScript creates a new `LinkedHashMap` by applying a callback function to
|
|
819
|
-
* each key-value pair in the original map.
|
|
820
|
-
* @param callback - The callback parameter is a function that will be called for each key-value pair
|
|
821
|
-
* in the map. It takes four arguments: the value of the current key-value pair, the key of the
|
|
822
|
-
* current key-value pair, the index of the current key-value pair, and the map itself. The callback
|
|
823
|
-
* function should
|
|
824
|
-
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
|
|
825
|
-
* specify the value of `this` within the callback function. If provided, the callback function will
|
|
826
|
-
* be called with `thisArg` as its `this` value. If not provided, `this` will refer to the current
|
|
827
|
-
* map
|
|
828
|
-
* @returns a new `LinkedHashMap` object with the values mapped according to the provided callback
|
|
829
|
-
* function.
|
|
830
|
-
*/
|
|
831
|
-
map(callback, thisArg) {
|
|
832
|
-
const mappedMap = new LinkedHashMap();
|
|
833
|
-
let index = 0;
|
|
834
|
-
for (const [key, value] of this) {
|
|
835
|
-
const [newKey, newValue] = callback.call(thisArg, key, value, index, this);
|
|
836
|
-
mappedMap.set(newKey, newValue);
|
|
837
|
-
index++;
|
|
838
|
-
}
|
|
839
|
-
return mappedMap;
|
|
840
|
-
}
|
|
841
|
-
/**
|
|
842
|
-
* Time Complexity: O(n)
|
|
843
|
-
* Space Complexity: O(1)
|
|
844
|
-
* where n is the number of entries in the LinkedHashMap.
|
|
845
|
-
*
|
|
846
|
-
* The above function is an iterator that yields key-value pairs from a linked list.
|
|
847
|
-
*/
|
|
848
|
-
*_getIterator() {
|
|
849
|
-
let node = this.head;
|
|
850
|
-
while (node !== this._sentinel) {
|
|
851
|
-
yield [node.key, node.value];
|
|
852
|
-
node = node.next;
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
/**
|
|
856
|
-
* Time Complexity: O(1)
|
|
857
|
-
* Space Complexity: O(1)
|
|
858
|
-
*
|
|
859
|
-
* The `_deleteNode` function removes a node from a doubly linked list and updates the head and tail
|
|
860
|
-
* pointers if necessary.
|
|
861
|
-
* @param node - The `node` parameter is an instance of the `HashMapLinkedNode` class, which
|
|
862
|
-
* represents a node in a linked list. It contains a key-value pair and references to the previous
|
|
863
|
-
* and next nodes in the list.
|
|
864
|
-
*/
|
|
865
|
-
_deleteNode(node) {
|
|
866
|
-
const { prev, next } = node;
|
|
867
|
-
prev.next = next;
|
|
868
|
-
next.prev = prev;
|
|
869
|
-
if (node === this.head) {
|
|
870
|
-
this._head = next;
|
|
871
|
-
}
|
|
872
|
-
if (node === this.tail) {
|
|
873
|
-
this._tail = prev;
|
|
874
|
-
}
|
|
875
|
-
this._size -= 1;
|
|
876
|
-
return true;
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
exports.LinkedHashMap = LinkedHashMap;
|
|
880
|
-
//# sourceMappingURL=hash-map.js.map
|