data-structure-typed 1.53.9 → 1.54.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 +1 -1
- package/README.md +1 -0
- package/benchmark/report.html +1 -28
- package/benchmark/report.json +17 -326
- package/dist/{mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts → cjs/data-structures/binary-tree/avl-tree-counter.d.ts} +54 -59
- package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js +408 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +71 -189
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +133 -357
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +108 -78
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +126 -79
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +3 -0
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +243 -190
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +273 -229
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +141 -122
- package/dist/cjs/data-structures/binary-tree/bst.js +170 -134
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/index.d.ts +2 -0
- package/dist/cjs/data-structures/binary-tree/index.js +2 -0
- package/dist/cjs/data-structures/binary-tree/index.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +84 -80
- package/dist/cjs/data-structures/binary-tree/red-black-tree.js +101 -79
- package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
- package/dist/{mjs/data-structures/binary-tree/tree-multi-map.d.ts → cjs/data-structures/binary-tree/tree-counter.d.ts} +54 -56
- package/dist/cjs/data-structures/binary-tree/tree-counter.js +445 -0
- package/dist/cjs/data-structures/binary-tree/tree-counter.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +78 -186
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +140 -388
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.d.ts +3 -0
- package/dist/cjs/data-structures/graph/directed-graph.js +3 -0
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/map-graph.d.ts +3 -0
- package/dist/cjs/data-structures/graph/map-graph.js +3 -0
- package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.d.ts +3 -0
- package/dist/cjs/data-structures/graph/undirected-graph.js +3 -0
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +3 -0
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +3 -0
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +3 -0
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js +3 -0
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/matrix/matrix.d.ts +3 -0
- package/dist/cjs/data-structures/matrix/matrix.js +3 -0
- package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
- package/dist/cjs/data-structures/matrix/navigator.d.ts +3 -0
- package/dist/cjs/data-structures/matrix/navigator.js +3 -0
- package/dist/cjs/data-structures/matrix/navigator.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +3 -0
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +3 -0
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.d.ts +0 -4
- package/dist/cjs/data-structures/trie/trie.js +0 -4
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/interfaces/binary-tree.d.ts +7 -6
- package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
- package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js +3 -0
- package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
- package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -3
- package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +0 -2
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +0 -2
- package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +3 -2
- package/dist/cjs/types/data-structures/binary-tree/index.d.ts +2 -0
- package/dist/cjs/types/data-structures/binary-tree/index.js +2 -0
- package/dist/cjs/types/data-structures/binary-tree/index.js.map +1 -1
- package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +1 -3
- package/dist/cjs/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
- package/dist/cjs/types/data-structures/binary-tree/tree-counter.js +3 -0
- package/dist/cjs/types/data-structures/binary-tree/tree-counter.js.map +1 -0
- package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -3
- package/dist/esm/data-structures/binary-tree/avl-tree-counter.d.ts +213 -0
- package/dist/{mjs/data-structures/binary-tree/avl-tree-multi-map.js → esm/data-structures/binary-tree/avl-tree-counter.js} +72 -78
- package/dist/esm/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.d.ts +100 -0
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +191 -0
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -0
- package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +234 -0
- package/dist/{mjs → esm}/data-structures/binary-tree/avl-tree.js +126 -80
- package/dist/esm/data-structures/binary-tree/avl-tree.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
- package/dist/{mjs → esm}/data-structures/binary-tree/binary-indexed-tree.js +3 -0
- package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/binary-tree/binary-tree.d.ts +243 -190
- package/dist/{mjs → esm}/data-structures/binary-tree/binary-tree.js +276 -234
- package/dist/esm/data-structures/binary-tree/binary-tree.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/binary-tree/bst.d.ts +141 -122
- package/dist/{mjs → esm}/data-structures/binary-tree/bst.js +171 -140
- package/dist/esm/data-structures/binary-tree/bst.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/binary-tree/index.d.ts +2 -0
- package/dist/{mjs → esm}/data-structures/binary-tree/index.js +2 -0
- package/dist/{mjs → esm}/data-structures/binary-tree/index.js.map +1 -1
- package/dist/{mjs → esm}/data-structures/binary-tree/red-black-tree.d.ts +84 -80
- package/dist/{mjs → esm}/data-structures/binary-tree/red-black-tree.js +100 -79
- package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +1 -0
- package/dist/esm/data-structures/binary-tree/tree-counter.d.ts +212 -0
- package/dist/{mjs/data-structures/binary-tree/tree-multi-map.js → esm/data-structures/binary-tree/tree-counter.js} +88 -86
- package/dist/esm/data-structures/binary-tree/tree-counter.js.map +1 -0
- package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +106 -0
- package/dist/esm/data-structures/binary-tree/tree-multi-map.js +196 -0
- package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/graph/directed-graph.d.ts +3 -0
- package/dist/{mjs → esm}/data-structures/graph/directed-graph.js +3 -0
- package/dist/esm/data-structures/graph/directed-graph.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/graph/map-graph.d.ts +3 -0
- package/dist/{mjs → esm}/data-structures/graph/map-graph.js +3 -0
- package/dist/esm/data-structures/graph/map-graph.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/graph/undirected-graph.d.ts +3 -0
- package/dist/{mjs → esm}/data-structures/graph/undirected-graph.js +3 -0
- package/dist/esm/data-structures/graph/undirected-graph.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/linked-list/singly-linked-list.d.ts +3 -0
- package/dist/{mjs → esm}/data-structures/linked-list/singly-linked-list.js +3 -0
- package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/linked-list/skip-linked-list.d.ts +3 -0
- package/dist/{mjs → esm}/data-structures/linked-list/skip-linked-list.js +3 -0
- package/dist/esm/data-structures/linked-list/skip-linked-list.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/matrix/matrix.d.ts +3 -0
- package/dist/{mjs → esm}/data-structures/matrix/matrix.js +3 -0
- package/dist/esm/data-structures/matrix/matrix.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/matrix/navigator.d.ts +3 -0
- package/dist/{mjs → esm}/data-structures/matrix/navigator.js +3 -0
- package/dist/esm/data-structures/matrix/navigator.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
- package/dist/{mjs → esm}/data-structures/priority-queue/max-priority-queue.js +3 -0
- package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
- package/dist/{mjs → esm}/data-structures/priority-queue/min-priority-queue.js +3 -0
- package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +1 -0
- package/dist/{mjs → esm}/data-structures/trie/trie.d.ts +0 -4
- package/dist/{mjs → esm}/data-structures/trie/trie.js +0 -4
- package/dist/esm/data-structures/trie/trie.js.map +1 -0
- package/dist/esm/interfaces/binary-tree.d.ts +9 -0
- package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
- package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js +2 -0
- package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
- package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
- package/dist/esm/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
- package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-tree.d.ts +0 -2
- package/dist/{mjs → esm}/types/data-structures/binary-tree/bst.d.ts +3 -2
- package/dist/{mjs → esm}/types/data-structures/binary-tree/index.d.ts +2 -0
- package/dist/{mjs → esm}/types/data-structures/binary-tree/index.js +2 -0
- package/dist/{mjs → esm}/types/data-structures/binary-tree/index.js.map +1 -1
- package/dist/esm/types/data-structures/binary-tree/rb-tree.d.ts +3 -0
- package/dist/esm/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
- package/dist/esm/types/data-structures/binary-tree/tree-counter.js +2 -0
- package/dist/esm/types/data-structures/binary-tree/tree-counter.js.map +1 -0
- package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
- package/dist/umd/data-structure-typed.js +1407 -913
- package/dist/umd/data-structure-typed.min.js +5 -5
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +14 -14
- package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +148 -394
- package/src/data-structures/binary-tree/avl-tree.ts +152 -112
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
- package/src/data-structures/binary-tree/binary-tree.ts +446 -379
- package/src/data-structures/binary-tree/bst.ts +224 -201
- package/src/data-structures/binary-tree/index.ts +2 -0
- package/src/data-structures/binary-tree/red-black-tree.ts +138 -114
- package/src/data-structures/binary-tree/tree-counter.ts +504 -0
- package/src/data-structures/binary-tree/tree-multi-map.ts +156 -428
- package/src/data-structures/graph/directed-graph.ts +3 -0
- package/src/data-structures/graph/map-graph.ts +3 -0
- package/src/data-structures/graph/undirected-graph.ts +3 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +3 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
- package/src/data-structures/matrix/matrix.ts +3 -0
- package/src/data-structures/matrix/navigator.ts +3 -0
- package/src/data-structures/priority-queue/max-priority-queue.ts +3 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +3 -0
- package/src/data-structures/trie/trie.ts +0 -4
- package/src/interfaces/binary-tree.ts +10 -11
- package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -4
- package/src/types/data-structures/binary-tree/avl-tree.ts +0 -3
- package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
- package/src/types/data-structures/binary-tree/bst.ts +5 -3
- package/src/types/data-structures/binary-tree/index.ts +2 -0
- package/src/types/data-structures/binary-tree/rb-tree.ts +1 -4
- package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +1 -4
- package/test/integration/all-in-one.test.ts +1 -1
- package/test/integration/avl-tree.test.ts +1 -1
- package/test/integration/bst.test.ts +2 -2
- package/test/integration/compile.js +144 -0
- package/test/integration/compile.ts +171 -0
- package/test/integration/index.html +48 -48
- package/test/performance/data-structures/binary-tree/avl-tree.test.ts +4 -4
- package/test/performance/data-structures/binary-tree/rb-tree.test.ts +5 -4
- package/test/performance/data-structures/comparison/comparison.test.ts +2 -2
- package/test/performance/reportor.ts +5 -3
- package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +877 -0
- package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +459 -761
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +223 -223
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +474 -492
- package/test/unit/data-structures/binary-tree/bst.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/overall.test.ts +0 -3
- package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +87 -90
- package/test/unit/data-structures/binary-tree/tree-counter.test.ts +975 -0
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +729 -857
- package/test/unit/data-structures/hash/hash-map.test.ts +1 -1
- package/{tsconfig-mjs.json → tsconfig-esm.json} +1 -1
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +0 -204
- package/dist/mjs/data-structures/binary-tree/avl-tree.js.map +0 -1
- package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
- package/dist/mjs/data-structures/binary-tree/binary-tree.js.map +0 -1
- package/dist/mjs/data-structures/binary-tree/bst.js.map +0 -1
- package/dist/mjs/data-structures/binary-tree/red-black-tree.js.map +0 -1
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.js.map +0 -1
- package/dist/mjs/data-structures/graph/directed-graph.js.map +0 -1
- package/dist/mjs/data-structures/graph/map-graph.js.map +0 -1
- package/dist/mjs/data-structures/graph/undirected-graph.js.map +0 -1
- package/dist/mjs/data-structures/linked-list/singly-linked-list.js.map +0 -1
- package/dist/mjs/data-structures/linked-list/skip-linked-list.js.map +0 -1
- package/dist/mjs/data-structures/matrix/matrix.js.map +0 -1
- package/dist/mjs/data-structures/matrix/navigator.js.map +0 -1
- package/dist/mjs/data-structures/priority-queue/max-priority-queue.js.map +0 -1
- package/dist/mjs/data-structures/priority-queue/min-priority-queue.js.map +0 -1
- package/dist/mjs/data-structures/trie/trie.js.map +0 -1
- package/dist/mjs/interfaces/binary-tree.d.ts +0 -8
- package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -4
- package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +0 -4
- package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +0 -5
- package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -4
- /package/dist/{mjs → esm}/common/index.d.ts +0 -0
- /package/dist/{mjs → esm}/common/index.js +0 -0
- /package/dist/{mjs → esm}/common/index.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/base/index.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/base/index.js +0 -0
- /package/dist/{mjs → esm}/data-structures/base/index.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/base/iterable-element-base.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/base/iterable-element-base.js +0 -0
- /package/dist/{mjs → esm}/data-structures/base/iterable-element-base.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/base/iterable-entry-base.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/base/iterable-entry-base.js +0 -0
- /package/dist/{mjs → esm}/data-structures/base/iterable-entry-base.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/binary-tree/segment-tree.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/binary-tree/segment-tree.js +0 -0
- /package/dist/{mjs → esm}/data-structures/binary-tree/segment-tree.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/graph/abstract-graph.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/graph/abstract-graph.js +0 -0
- /package/dist/{mjs → esm}/data-structures/graph/abstract-graph.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/graph/index.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/graph/index.js +0 -0
- /package/dist/{mjs → esm}/data-structures/graph/index.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/hash/hash-map.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/hash/hash-map.js +0 -0
- /package/dist/{mjs → esm}/data-structures/hash/hash-map.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/hash/index.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/hash/index.js +0 -0
- /package/dist/{mjs → esm}/data-structures/hash/index.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/heap/heap.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/heap/heap.js +0 -0
- /package/dist/{mjs → esm}/data-structures/heap/heap.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/heap/index.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/heap/index.js +0 -0
- /package/dist/{mjs → esm}/data-structures/heap/index.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/heap/max-heap.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/heap/max-heap.js +0 -0
- /package/dist/{mjs → esm}/data-structures/heap/max-heap.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/heap/min-heap.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/heap/min-heap.js +0 -0
- /package/dist/{mjs → esm}/data-structures/heap/min-heap.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/index.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/index.js +0 -0
- /package/dist/{mjs → esm}/data-structures/index.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/linked-list/doubly-linked-list.js +0 -0
- /package/dist/{mjs → esm}/data-structures/linked-list/doubly-linked-list.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/linked-list/index.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/linked-list/index.js +0 -0
- /package/dist/{mjs → esm}/data-structures/linked-list/index.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/matrix/index.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/matrix/index.js +0 -0
- /package/dist/{mjs → esm}/data-structures/matrix/index.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/priority-queue/index.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/priority-queue/index.js +0 -0
- /package/dist/{mjs → esm}/data-structures/priority-queue/index.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/priority-queue/priority-queue.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/priority-queue/priority-queue.js +0 -0
- /package/dist/{mjs → esm}/data-structures/priority-queue/priority-queue.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/queue/deque.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/queue/deque.js +0 -0
- /package/dist/{mjs → esm}/data-structures/queue/deque.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/queue/index.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/queue/index.js +0 -0
- /package/dist/{mjs → esm}/data-structures/queue/index.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/queue/queue.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/queue/queue.js +0 -0
- /package/dist/{mjs → esm}/data-structures/queue/queue.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/stack/index.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/stack/index.js +0 -0
- /package/dist/{mjs → esm}/data-structures/stack/index.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/stack/stack.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/stack/stack.js +0 -0
- /package/dist/{mjs → esm}/data-structures/stack/stack.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/tree/index.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/tree/index.js +0 -0
- /package/dist/{mjs → esm}/data-structures/tree/index.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/tree/tree.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/tree/tree.js +0 -0
- /package/dist/{mjs → esm}/data-structures/tree/tree.js.map +0 -0
- /package/dist/{mjs → esm}/data-structures/trie/index.d.ts +0 -0
- /package/dist/{mjs → esm}/data-structures/trie/index.js +0 -0
- /package/dist/{mjs → esm}/data-structures/trie/index.js.map +0 -0
- /package/dist/{mjs → esm}/index.d.ts +0 -0
- /package/dist/{mjs → esm}/index.js +0 -0
- /package/dist/{mjs → esm}/index.js.map +0 -0
- /package/dist/{mjs → esm}/interfaces/binary-tree.js +0 -0
- /package/dist/{mjs → esm}/interfaces/binary-tree.js.map +0 -0
- /package/dist/{mjs → esm}/interfaces/doubly-linked-list.d.ts +0 -0
- /package/dist/{mjs → esm}/interfaces/doubly-linked-list.js +0 -0
- /package/dist/{mjs → esm}/interfaces/doubly-linked-list.js.map +0 -0
- /package/dist/{mjs → esm}/interfaces/graph.d.ts +0 -0
- /package/dist/{mjs → esm}/interfaces/graph.js +0 -0
- /package/dist/{mjs → esm}/interfaces/graph.js.map +0 -0
- /package/dist/{mjs → esm}/interfaces/heap.d.ts +0 -0
- /package/dist/{mjs → esm}/interfaces/heap.js +0 -0
- /package/dist/{mjs → esm}/interfaces/heap.js.map +0 -0
- /package/dist/{mjs → esm}/interfaces/index.d.ts +0 -0
- /package/dist/{mjs → esm}/interfaces/index.js +0 -0
- /package/dist/{mjs → esm}/interfaces/index.js.map +0 -0
- /package/dist/{mjs → esm}/interfaces/navigator.d.ts +0 -0
- /package/dist/{mjs → esm}/interfaces/navigator.js +0 -0
- /package/dist/{mjs → esm}/interfaces/navigator.js.map +0 -0
- /package/dist/{mjs → esm}/interfaces/priority-queue.d.ts +0 -0
- /package/dist/{mjs → esm}/interfaces/priority-queue.js +0 -0
- /package/dist/{mjs → esm}/interfaces/priority-queue.js.map +0 -0
- /package/dist/{mjs → esm}/interfaces/segment-tree.d.ts +0 -0
- /package/dist/{mjs → esm}/interfaces/segment-tree.js +0 -0
- /package/dist/{mjs → esm}/interfaces/segment-tree.js.map +0 -0
- /package/dist/{mjs → esm}/interfaces/singly-linked-list.d.ts +0 -0
- /package/dist/{mjs → esm}/interfaces/singly-linked-list.js +0 -0
- /package/dist/{mjs → esm}/interfaces/singly-linked-list.js.map +0 -0
- /package/dist/{mjs → esm}/types/common.d.ts +0 -0
- /package/dist/{mjs → esm}/types/common.js +0 -0
- /package/dist/{mjs → esm}/types/common.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/base/base.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/base/base.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/base/base.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/base/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/base/index.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/base/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-indexed-tree.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-tree.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-tree.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/bst.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/bst.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/rb-tree.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/rb-tree.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/segment-tree.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/segment-tree.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/segment-tree.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/tree-multi-map.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/binary-tree/tree-multi-map.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/abstract-graph.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/abstract-graph.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/abstract-graph.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/directed-graph.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/directed-graph.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/directed-graph.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/index.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/map-graph.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/map-graph.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/map-graph.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/undirected-graph.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/undirected-graph.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/graph/undirected-graph.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/hash/hash-map.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/hash/hash-map.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/hash/hash-map.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/hash/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/hash/index.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/hash/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/heap/heap.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/heap/heap.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/heap/heap.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/heap/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/heap/index.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/heap/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/heap/max-heap.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/heap/max-heap.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/heap/max-heap.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/heap/min-heap.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/heap/min-heap.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/heap/min-heap.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/index.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/linked-list/doubly-linked-list.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/linked-list/doubly-linked-list.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/linked-list/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/linked-list/index.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/linked-list/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/linked-list/singly-linked-list.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/linked-list/singly-linked-list.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/linked-list/singly-linked-list.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/linked-list/skip-linked-list.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/linked-list/skip-linked-list.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/linked-list/skip-linked-list.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/matrix/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/matrix/index.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/matrix/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/matrix/matrix.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/matrix/matrix.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/matrix/matrix.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/matrix/navigator.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/matrix/navigator.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/matrix/navigator.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/priority-queue/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/priority-queue/index.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/priority-queue/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/priority-queue/max-priority-queue.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/priority-queue/max-priority-queue.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/priority-queue/min-priority-queue.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/priority-queue/min-priority-queue.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/priority-queue/priority-queue.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/priority-queue/priority-queue.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/priority-queue/priority-queue.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/queue/deque.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/queue/deque.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/queue/deque.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/queue/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/queue/index.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/queue/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/queue/queue.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/queue/queue.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/queue/queue.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/stack/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/stack/index.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/stack/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/stack/stack.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/stack/stack.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/stack/stack.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/tree/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/tree/index.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/tree/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/tree/tree.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/tree/tree.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/tree/tree.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/trie/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/trie/index.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/trie/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/data-structures/trie/trie.d.ts +0 -0
- /package/dist/{mjs → esm}/types/data-structures/trie/trie.js +0 -0
- /package/dist/{mjs → esm}/types/data-structures/trie/trie.js.map +0 -0
- /package/dist/{mjs → esm}/types/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/index.js +0 -0
- /package/dist/{mjs → esm}/types/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/utils/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types/utils/index.js +0 -0
- /package/dist/{mjs → esm}/types/utils/index.js.map +0 -0
- /package/dist/{mjs → esm}/types/utils/utils.d.ts +0 -0
- /package/dist/{mjs → esm}/types/utils/utils.js +0 -0
- /package/dist/{mjs → esm}/types/utils/utils.js.map +0 -0
- /package/dist/{mjs → esm}/types/utils/validate-type.d.ts +0 -0
- /package/dist/{mjs → esm}/types/utils/validate-type.js +0 -0
- /package/dist/{mjs → esm}/types/utils/validate-type.js.map +0 -0
- /package/dist/{mjs → esm}/utils/index.d.ts +0 -0
- /package/dist/{mjs → esm}/utils/index.js +0 -0
- /package/dist/{mjs → esm}/utils/index.js.map +0 -0
- /package/dist/{mjs → esm}/utils/number.d.ts +0 -0
- /package/dist/{mjs → esm}/utils/number.js +0 -0
- /package/dist/{mjs → esm}/utils/number.js.map +0 -0
- /package/dist/{mjs → esm}/utils/utils.d.ts +0 -0
- /package/dist/{mjs → esm}/utils/utils.js +0 -0
- /package/dist/{mjs → esm}/utils/utils.js.map +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';
|
|
2
|
-
export class
|
|
2
|
+
export class TreeCounterNode extends RedBlackTreeNode {
|
|
3
3
|
/**
|
|
4
4
|
* The constructor function initializes a Red-Black Tree node with a key, value, count, and color.
|
|
5
5
|
* @param {K} key - The key parameter represents the key of the node in the Red-Black Tree. It is
|
|
@@ -16,31 +16,39 @@ export class TreeMultiMapNode extends RedBlackTreeNode {
|
|
|
16
16
|
super(key, value, color);
|
|
17
17
|
this.count = count;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
get count() {
|
|
25
|
-
return this._count;
|
|
19
|
+
parent = undefined;
|
|
20
|
+
_left = undefined;
|
|
21
|
+
get left() {
|
|
22
|
+
return this._left;
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
set left(v) {
|
|
25
|
+
if (v) {
|
|
26
|
+
v.parent = this;
|
|
27
|
+
}
|
|
28
|
+
this._left = v;
|
|
29
|
+
}
|
|
30
|
+
_right = undefined;
|
|
31
|
+
get right() {
|
|
32
|
+
return this._right;
|
|
33
|
+
}
|
|
34
|
+
set right(v) {
|
|
35
|
+
if (v) {
|
|
36
|
+
v.parent = this;
|
|
37
|
+
}
|
|
38
|
+
this._right = v;
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
|
-
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
export class TreeCounter extends RedBlackTree {
|
|
37
45
|
/**
|
|
38
|
-
* The constructor function initializes a
|
|
46
|
+
* The constructor function initializes a TreeCounter object with optional initial data.
|
|
39
47
|
* @param keysNodesEntriesOrRaws - The parameter `keysNodesEntriesOrRaws` is an
|
|
40
48
|
* iterable that can contain keys, nodes, entries, or raw elements. It is used to initialize the
|
|
41
|
-
*
|
|
49
|
+
* TreeCounter with initial data.
|
|
42
50
|
* @param [options] - The `options` parameter is an optional object that can be used to customize the
|
|
43
|
-
* behavior of the `
|
|
51
|
+
* behavior of the `TreeCounter` constructor. It can include properties such as `compareKeys` and
|
|
44
52
|
* `compareValues`, which are functions used to compare keys and values respectively.
|
|
45
53
|
*/
|
|
46
54
|
constructor(keysNodesEntriesOrRaws = [], options) {
|
|
@@ -71,7 +79,7 @@ export class TreeMultiMap extends RedBlackTree {
|
|
|
71
79
|
return sum;
|
|
72
80
|
}
|
|
73
81
|
/**
|
|
74
|
-
* The function creates a new
|
|
82
|
+
* The function creates a new TreeCounterNode with the specified key, value, color, and count.
|
|
75
83
|
* @param {K} key - The key parameter represents the key of the node being created. It is of type K,
|
|
76
84
|
* which is a generic type representing the type of keys in the tree.
|
|
77
85
|
* @param {V} [value] - The `value` parameter is an optional parameter that represents the value
|
|
@@ -81,38 +89,37 @@ export class TreeMultiMap extends RedBlackTree {
|
|
|
81
89
|
* @param {number} [count] - The `count` parameter represents the number of occurrences of a key in
|
|
82
90
|
* the tree. It is an optional parameter and is used to keep track of the number of values associated
|
|
83
91
|
* with a key in the tree.
|
|
84
|
-
* @returns A new instance of the
|
|
92
|
+
* @returns A new instance of the TreeCounterNode class, casted as TreeCounterNode<K, V>.
|
|
85
93
|
*/
|
|
86
94
|
createNode(key, value, color = 'BLACK', count) {
|
|
87
|
-
return new
|
|
95
|
+
return new TreeCounterNode(key, this._isMapMode ? undefined : value, count, color);
|
|
88
96
|
}
|
|
89
97
|
/**
|
|
90
|
-
* The function creates a new instance of a
|
|
98
|
+
* The function creates a new instance of a TreeCounter with the specified options and returns it.
|
|
91
99
|
* @param [options] - The `options` parameter is an optional object that contains additional
|
|
92
|
-
* configuration options for creating the `
|
|
100
|
+
* configuration options for creating the `TreeCounter`. It is of type `TreeCounterOptions<K, V,
|
|
93
101
|
* R>`.
|
|
94
|
-
* @returns a new instance of the `
|
|
102
|
+
* @returns a new instance of the `TreeCounter` class, with the provided options merged with the
|
|
95
103
|
* existing `iterationType` property. The returned value is casted as `TREE`.
|
|
96
104
|
*/
|
|
97
|
-
// @ts-ignore
|
|
98
105
|
createTree(options) {
|
|
99
|
-
return new
|
|
106
|
+
return new TreeCounter([], {
|
|
100
107
|
iterationType: this.iterationType,
|
|
101
|
-
isMapMode: this._isMapMode,
|
|
102
108
|
specifyComparable: this._specifyComparable,
|
|
109
|
+
isMapMode: this._isMapMode,
|
|
103
110
|
toEntryFn: this._toEntryFn,
|
|
104
111
|
...options
|
|
105
112
|
});
|
|
106
113
|
}
|
|
107
114
|
/**
|
|
108
|
-
* The function checks if the input is an instance of the
|
|
109
|
-
* @param {BTNRep<K, V,
|
|
110
|
-
* `
|
|
111
|
-
* @returns a boolean value indicating whether the input parameter `
|
|
112
|
-
* an instance of the `
|
|
115
|
+
* The function checks if the input is an instance of the TreeCounterNode class.
|
|
116
|
+
* @param {BTNRep<K, V, TreeCounterNode<K, V>>} keyNodeOrEntry - The parameter
|
|
117
|
+
* `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, TreeCounterNode<K, V>>`.
|
|
118
|
+
* @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
|
|
119
|
+
* an instance of the `TreeCounterNode` class.
|
|
113
120
|
*/
|
|
114
|
-
isNode(
|
|
115
|
-
return
|
|
121
|
+
isNode(keyNodeOrEntry) {
|
|
122
|
+
return keyNodeOrEntry instanceof TreeCounterNode;
|
|
116
123
|
}
|
|
117
124
|
/**
|
|
118
125
|
* Time Complexity: O(log n)
|
|
@@ -120,8 +127,8 @@ export class TreeMultiMap extends RedBlackTree {
|
|
|
120
127
|
*
|
|
121
128
|
* The function overrides the add method of a class and adds a new node to a data structure, updating
|
|
122
129
|
* the count and returning a boolean indicating success.
|
|
123
|
-
* @param {BTNRep<K, V,
|
|
124
|
-
* `
|
|
130
|
+
* @param {BTNRep<K, V, TreeCounterNode<K, V>>} keyNodeOrEntry - The
|
|
131
|
+
* `keyNodeOrEntry` parameter can accept one of the following types:
|
|
125
132
|
* @param {V} [value] - The `value` parameter represents the value associated with the key in the
|
|
126
133
|
* data structure. It is an optional parameter, so it can be omitted if not needed.
|
|
127
134
|
* @param [count=1] - The `count` parameter represents the number of times the key-value pair should
|
|
@@ -130,8 +137,8 @@ export class TreeMultiMap extends RedBlackTree {
|
|
|
130
137
|
* @returns The method is returning a boolean value. It returns true if the addition of the new node
|
|
131
138
|
* was successful, and false otherwise.
|
|
132
139
|
*/
|
|
133
|
-
add(
|
|
134
|
-
const [newNode, newValue] = this.
|
|
140
|
+
add(keyNodeOrEntry, value, count = 1) {
|
|
141
|
+
const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count);
|
|
135
142
|
const orgCount = newNode?.count || 0;
|
|
136
143
|
const isSuccessAdded = super.add(newNode, newValue);
|
|
137
144
|
if (isSuccessAdded) {
|
|
@@ -148,34 +155,37 @@ export class TreeMultiMap extends RedBlackTree {
|
|
|
148
155
|
*
|
|
149
156
|
* The function `delete` in TypeScript overrides the deletion operation in a binary tree data
|
|
150
157
|
* structure, handling cases where nodes have children and maintaining balance in the tree.
|
|
151
|
-
* @param {BTNRep<K, V,
|
|
158
|
+
* @param {BTNRep<K, V, TreeCounterNode<K, V>>} keyNodeOrEntry - The `predicate`
|
|
152
159
|
* parameter in the `delete` method is used to specify the condition or key based on which a node
|
|
153
160
|
* should be deleted from the binary tree. It can be a key, a node, or an entry.
|
|
154
161
|
* @param [ignoreCount=false] - The `ignoreCount` parameter in the `override delete` method is a
|
|
155
162
|
* boolean flag that determines whether to ignore the count of nodes when performing deletion. If
|
|
156
163
|
* `ignoreCount` is set to `true`, the method will delete the node regardless of its count. If
|
|
157
164
|
* `ignoreCount` is `false
|
|
158
|
-
* @returns The `override delete` method returns an array of `BinaryTreeDeleteResult<
|
|
165
|
+
* @returns The `override delete` method returns an array of `BinaryTreeDeleteResult<TreeCounterNode<K, V>>` objects.
|
|
159
166
|
*/
|
|
160
|
-
delete(
|
|
161
|
-
if (
|
|
167
|
+
delete(keyNodeOrEntry, ignoreCount = false) {
|
|
168
|
+
if (keyNodeOrEntry === null)
|
|
162
169
|
return [];
|
|
163
170
|
const results = [];
|
|
164
171
|
let nodeToDelete;
|
|
165
|
-
if (this._isPredicate(
|
|
166
|
-
nodeToDelete = this.getNode(
|
|
172
|
+
if (this._isPredicate(keyNodeOrEntry))
|
|
173
|
+
nodeToDelete = this.getNode(keyNodeOrEntry);
|
|
167
174
|
else
|
|
168
|
-
nodeToDelete = this.isRealNode(
|
|
175
|
+
nodeToDelete = this.isRealNode(keyNodeOrEntry) ? keyNodeOrEntry : this.getNode(keyNodeOrEntry);
|
|
169
176
|
if (!nodeToDelete) {
|
|
170
177
|
return results;
|
|
171
178
|
}
|
|
172
179
|
let originalColor = nodeToDelete.color;
|
|
173
180
|
let replacementNode;
|
|
174
181
|
if (!this.isRealNode(nodeToDelete.left)) {
|
|
175
|
-
|
|
182
|
+
if (nodeToDelete.right !== null)
|
|
183
|
+
replacementNode = nodeToDelete.right;
|
|
176
184
|
if (ignoreCount || nodeToDelete.count <= 1) {
|
|
177
|
-
|
|
178
|
-
|
|
185
|
+
if (nodeToDelete.right !== null) {
|
|
186
|
+
this._transplant(nodeToDelete, nodeToDelete.right);
|
|
187
|
+
this._count -= nodeToDelete.count;
|
|
188
|
+
}
|
|
179
189
|
}
|
|
180
190
|
else {
|
|
181
191
|
nodeToDelete.count--;
|
|
@@ -201,7 +211,8 @@ export class TreeMultiMap extends RedBlackTree {
|
|
|
201
211
|
const successor = this.getLeftMost(node => node, nodeToDelete.right);
|
|
202
212
|
if (successor) {
|
|
203
213
|
originalColor = successor.color;
|
|
204
|
-
|
|
214
|
+
if (successor.right !== null)
|
|
215
|
+
replacementNode = successor.right;
|
|
205
216
|
if (successor.parent === nodeToDelete) {
|
|
206
217
|
if (this.isRealNode(replacementNode)) {
|
|
207
218
|
replacementNode.parent = successor;
|
|
@@ -209,8 +220,10 @@ export class TreeMultiMap extends RedBlackTree {
|
|
|
209
220
|
}
|
|
210
221
|
else {
|
|
211
222
|
if (ignoreCount || nodeToDelete.count <= 1) {
|
|
212
|
-
|
|
213
|
-
|
|
223
|
+
if (successor.right !== null) {
|
|
224
|
+
this._transplant(successor, successor.right);
|
|
225
|
+
this._count -= nodeToDelete.count;
|
|
226
|
+
}
|
|
214
227
|
}
|
|
215
228
|
else {
|
|
216
229
|
nodeToDelete.count--;
|
|
@@ -321,7 +334,6 @@ export class TreeMultiMap extends RedBlackTree {
|
|
|
321
334
|
* The function overrides the clone method to create a deep copy of a tree object.
|
|
322
335
|
* @returns The `clone()` method is returning a cloned instance of the `TREE` object.
|
|
323
336
|
*/
|
|
324
|
-
// @ts-ignore
|
|
325
337
|
clone() {
|
|
326
338
|
const cloned = this.createTree();
|
|
327
339
|
this.bfs(node => cloned.add(node.key, undefined, node.count));
|
|
@@ -330,23 +342,22 @@ export class TreeMultiMap extends RedBlackTree {
|
|
|
330
342
|
return cloned;
|
|
331
343
|
}
|
|
332
344
|
/**
|
|
333
|
-
* The `map` function in TypeScript overrides the default behavior to create a new
|
|
345
|
+
* The `map` function in TypeScript overrides the default behavior to create a new TreeCounter with
|
|
334
346
|
* modified entries based on a provided callback.
|
|
335
347
|
* @param callback - The `callback` parameter is a function that will be called for each entry in the
|
|
336
348
|
* map. It takes four arguments:
|
|
337
349
|
* @param [options] - The `options` parameter in the `override map` function is of type
|
|
338
|
-
* `
|
|
339
|
-
* options when creating a new `
|
|
350
|
+
* `TreeCounterOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
|
|
351
|
+
* options when creating a new `TreeCounter` instance within the `map` function. These options could
|
|
340
352
|
* include things like
|
|
341
353
|
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
|
|
342
354
|
* the value of `this` when executing the `callback` function. It allows you to set the context
|
|
343
355
|
* (value of `this`) for the callback function when it is called within the `map` function. This
|
|
344
|
-
* @returns A new
|
|
356
|
+
* @returns A new TreeCounter instance is being returned, which is populated with entries generated
|
|
345
357
|
* by the provided callback function.
|
|
346
358
|
*/
|
|
347
|
-
// @ts-ignore
|
|
348
359
|
map(callback, options, thisArg) {
|
|
349
|
-
const newTree = new
|
|
360
|
+
const newTree = new TreeCounter([], options);
|
|
350
361
|
let index = 0;
|
|
351
362
|
for (const [key, value] of this) {
|
|
352
363
|
newTree.add(callback.call(thisArg, key, value, index++, this));
|
|
@@ -356,37 +367,28 @@ export class TreeMultiMap extends RedBlackTree {
|
|
|
356
367
|
/**
|
|
357
368
|
* The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
|
|
358
369
|
* node based on the input.
|
|
359
|
-
* @param {BTNRep<K, V,
|
|
360
|
-
* `
|
|
370
|
+
* @param {BTNRep<K, V, TreeCounterNode<K, V>>} keyNodeOrEntry - The parameter
|
|
371
|
+
* `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, TreeCounterNode<K, V>>`.
|
|
361
372
|
* @param {V} [value] - The `value` parameter is an optional value that represents the value
|
|
362
373
|
* associated with the key in the node. It is used when creating a new node or updating the value of
|
|
363
374
|
* an existing node.
|
|
364
375
|
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
|
|
365
376
|
* times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
|
|
366
|
-
* @returns either a
|
|
377
|
+
* @returns either a TreeCounterNode<K, V> object or undefined.
|
|
367
378
|
*/
|
|
368
|
-
|
|
369
|
-
if (
|
|
379
|
+
_keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count = 1) {
|
|
380
|
+
if (keyNodeOrEntry === undefined || keyNodeOrEntry === null)
|
|
370
381
|
return [undefined, undefined];
|
|
371
|
-
if (this.isNode(
|
|
372
|
-
return [
|
|
373
|
-
if (this.isEntry(
|
|
374
|
-
const [key, entryValue] =
|
|
382
|
+
if (this.isNode(keyNodeOrEntry))
|
|
383
|
+
return [keyNodeOrEntry, value];
|
|
384
|
+
if (this.isEntry(keyNodeOrEntry)) {
|
|
385
|
+
const [key, entryValue] = keyNodeOrEntry;
|
|
375
386
|
if (key === undefined || key === null)
|
|
376
387
|
return [undefined, undefined];
|
|
377
388
|
const finalValue = value ?? entryValue;
|
|
378
|
-
|
|
379
|
-
return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
|
|
380
|
-
}
|
|
381
|
-
if (this.isRaw(keyNodeEntryOrRaw)) {
|
|
382
|
-
const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
|
|
383
|
-
const finalValue = value ?? entryValue;
|
|
384
|
-
if (this.isKey(key))
|
|
385
|
-
return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
|
|
389
|
+
return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
|
|
386
390
|
}
|
|
387
|
-
|
|
388
|
-
return [this.createNode(keyNodeEntryOrRaw, value, 'BLACK', count), value];
|
|
389
|
-
return [undefined, undefined];
|
|
391
|
+
return [this.createNode(keyNodeOrEntry, value, 'BLACK', count), value];
|
|
390
392
|
}
|
|
391
393
|
/**
|
|
392
394
|
* Time Complexity: O(1)
|
|
@@ -394,10 +396,10 @@ export class TreeMultiMap extends RedBlackTree {
|
|
|
394
396
|
*
|
|
395
397
|
* The `_swapProperties` function swaps the properties (key, value, count, color) between two nodes
|
|
396
398
|
* in a binary search tree.
|
|
397
|
-
* @param {R | BSTNOptKeyOrNode<K,
|
|
399
|
+
* @param {R | BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>} srcNode - The `srcNode` parameter represents the source node
|
|
398
400
|
* that will be swapped with the `destNode`. It can be either an instance of the `R` class or an
|
|
399
|
-
* instance of the `BSTNOptKeyOrNode<K,
|
|
400
|
-
* @param {R | BSTNOptKeyOrNode<K,
|
|
401
|
+
* instance of the `BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>` class.
|
|
402
|
+
* @param {R | BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>} destNode - The `destNode` parameter represents the destination
|
|
401
403
|
* node where the properties will be swapped with the source node.
|
|
402
404
|
* @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
|
|
403
405
|
* If either `srcNode` or `destNode` is undefined, it returns undefined.
|
|
@@ -430,15 +432,15 @@ export class TreeMultiMap extends RedBlackTree {
|
|
|
430
432
|
* Space Complexity: O(1)
|
|
431
433
|
*
|
|
432
434
|
* The function replaces an old node with a new node and updates the count property of the new node.
|
|
433
|
-
* @param {
|
|
435
|
+
* @param {TreeCounterNode<K, V>} oldNode - The `oldNode` parameter is the node that you want to replace in the data
|
|
434
436
|
* structure.
|
|
435
|
-
* @param {
|
|
437
|
+
* @param {TreeCounterNode<K, V>} newNode - The `newNode` parameter is an instance of the `TreeCounterNode<K, V>` class.
|
|
436
438
|
* @returns The method is returning the result of calling the `_replaceNode` method from the
|
|
437
|
-
* superclass, which is of type `
|
|
439
|
+
* superclass, which is of type `TreeCounterNode<K, V>`.
|
|
438
440
|
*/
|
|
439
441
|
_replaceNode(oldNode, newNode) {
|
|
440
442
|
newNode.count = oldNode.count + newNode.count;
|
|
441
443
|
return super._replaceNode(oldNode, newNode);
|
|
442
444
|
}
|
|
443
445
|
}
|
|
444
|
-
//# sourceMappingURL=tree-
|
|
446
|
+
//# sourceMappingURL=tree-counter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-counter.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/tree-counter.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAElE,MAAM,OAAO,eAAkC,SAAQ,gBAAsB;IAC3E;;;;;;;;;;;OAWG;IACH,YAAY,GAAM,EAAE,KAAS,EAAE,KAAK,GAAG,CAAC,EAAE,QAAmB,OAAO;QAClE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAEQ,MAAM,GAA2B,SAAS,CAAC;IAE3C,KAAK,GAA0C,SAAS,CAAC;IAElE,IAAa,IAAI;QACf,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAa,IAAI,CAAC,CAAuC;QACvD,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IAEQ,MAAM,GAA0C,SAAS,CAAC;IAEnE,IAAa,KAAK;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAa,KAAK,CAAC,CAAuC;QACxD,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,WACX,SAAQ,YAAiC;IAGzC;;;;;;;;OAQG;IACH,YACE,yBAA4E,EAAE,EAC9E,OAAqC;QAErC,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnB,IAAI,sBAAsB;YAAE,IAAI,CAAC,OAAO,CAAC,sBA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C,GAAG,CAAC;gBAC3B,IAAI,CAAC,IAAI,CAAC,UAAU;oBAAE,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;gBACrD,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;gBAC/B,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;gBAE/B,OAAO,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;gBAC3B,IAAI,CAAC,IAAI,CAAC,UAAU;oBAAE,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;gBACrD,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;gBAC/B,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;YACjC,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;;;;;OAUG;IACgB,YAAY,CAC7B,OAA8B,EAC9B,OAA8B;QAE9B,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC9C,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data-structure-typed
|
|
3
|
+
*
|
|
4
|
+
* @author Pablo Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
|
+
* @license MIT License
|
|
7
|
+
*/
|
|
8
|
+
import type { BTNRep, OptNodeOrNull, TreeMultiMapOptions } from '../../types';
|
|
9
|
+
import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';
|
|
10
|
+
import { IBinaryTree } from '../../interfaces';
|
|
11
|
+
export declare class TreeMultiMapNode<K = any, V = any> extends RedBlackTreeNode<K, V[]> {
|
|
12
|
+
/**
|
|
13
|
+
* This TypeScript constructor initializes an object with a key of type K and an array of values of
|
|
14
|
+
* type V.
|
|
15
|
+
* @param {K} key - The `key` parameter is typically used to store a unique identifier or key for the
|
|
16
|
+
* data being stored in the data structure. It helps in quickly accessing or retrieving the
|
|
17
|
+
* associated value in the data structure.
|
|
18
|
+
* @param {V[]} value - The `value` parameter in the constructor represents an array of values of
|
|
19
|
+
* type `V`.
|
|
20
|
+
*/
|
|
21
|
+
constructor(key: K, value: V[]);
|
|
22
|
+
parent?: TreeMultiMapNode<K, V>;
|
|
23
|
+
_left?: OptNodeOrNull<TreeMultiMapNode<K, V>>;
|
|
24
|
+
get left(): OptNodeOrNull<TreeMultiMapNode<K, V>>;
|
|
25
|
+
set left(v: OptNodeOrNull<TreeMultiMapNode<K, V>>);
|
|
26
|
+
_right?: OptNodeOrNull<TreeMultiMapNode<K, V>>;
|
|
27
|
+
get right(): OptNodeOrNull<TreeMultiMapNode<K, V>>;
|
|
28
|
+
set right(v: OptNodeOrNull<TreeMultiMapNode<K, V>>);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Find elements in a range
|
|
34
|
+
* const tmm = new TreeMultiMap<number>([10, 5, 15, 3, 7, 12, 18]);
|
|
35
|
+
* console.log(tmm.search(new Range(5, 10))); // [5, 10, 7]
|
|
36
|
+
* console.log(tmm.search(new Range(4, 12))); // [5, 10, 12, 7]
|
|
37
|
+
* console.log(tmm.search(new Range(15, 20))); // [15, 18]
|
|
38
|
+
*/
|
|
39
|
+
export declare class TreeMultiMap<K = any, V = any, R = object, MK = any, MV = any, MR = object> extends RedBlackTree<K, V[], R, MK, MV[], MR> implements IBinaryTree<K, V[], R, MK, MV, MR> {
|
|
40
|
+
/**
|
|
41
|
+
* The constructor initializes an TreeMultiMap with the provided keys, nodes, entries, or raw data
|
|
42
|
+
* and options.
|
|
43
|
+
* @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
|
|
44
|
+
* iterable that can contain either key-value pairs represented as `BTNRep<K, V[],
|
|
45
|
+
* TreeMultiMapNode<K, V>>` or raw data represented as `R`. This parameter is used to initialize
|
|
46
|
+
* the RedBlackTreeMulti
|
|
47
|
+
* @param [options] - The `options` parameter in the constructor is of type
|
|
48
|
+
* `TreeMultiMapOptions<K, V[], R>`. It is an optional parameter that allows you to specify
|
|
49
|
+
* additional options for configuring the TreeMultiMap instance.
|
|
50
|
+
*/
|
|
51
|
+
constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V[], TreeMultiMapNode<K, V>> | R>, options?: TreeMultiMapOptions<K, V[], R>);
|
|
52
|
+
/**
|
|
53
|
+
* Time Complexity: O(1)
|
|
54
|
+
* Space Complexity: O(1)
|
|
55
|
+
*
|
|
56
|
+
* The `createTree` function in TypeScript overrides the default implementation to create a new
|
|
57
|
+
* TreeMultiMap with specified options.
|
|
58
|
+
* @param [options] - The `options` parameter in the `createTree` method is of type
|
|
59
|
+
* `TreeMultiMapOptions<K, V[], R>`. This parameter allows you to pass additional configuration
|
|
60
|
+
* options when creating a new `TreeMultiMap` instance. It includes properties such as
|
|
61
|
+
* `iterationType`, `specifyComparable
|
|
62
|
+
* @returns A new instance of `TreeMultiMap` is being returned, with an empty array as the initial
|
|
63
|
+
* data and the provided options merged with the existing properties of the current object.
|
|
64
|
+
*/
|
|
65
|
+
createTree(options?: TreeMultiMapOptions<K, V[], R>): TreeMultiMap<K, V, R, MK, MV, MR>;
|
|
66
|
+
/**
|
|
67
|
+
* Time Complexity: O(1)
|
|
68
|
+
* Space Complexity: O(1)
|
|
69
|
+
*
|
|
70
|
+
* The function `createNode` overrides the method to create a new `TreeMultiMapNode` with a specified
|
|
71
|
+
* key and an empty array of values.
|
|
72
|
+
* @param {K} key - The `key` parameter in the `createNode` method represents the key of the node
|
|
73
|
+
* that will be created in the TreeMultiMap data structure.
|
|
74
|
+
* @returns A new instance of `TreeMultiMapNode<K, V>` is being returned, with the specified key and
|
|
75
|
+
* an empty array as its value.
|
|
76
|
+
*/
|
|
77
|
+
createNode(key: K): TreeMultiMapNode<K, V>;
|
|
78
|
+
add(node: BTNRep<K, V[], TreeMultiMapNode<K, V>>): boolean;
|
|
79
|
+
add(key: K, value: V): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Time Complexity: O(log n)
|
|
82
|
+
* Space Complexity: O(log n)
|
|
83
|
+
*
|
|
84
|
+
* The function `deleteValue` removes a specific value from a key in a TreeMultiMap data structure
|
|
85
|
+
* and deletes the entire node if no values are left for that key.
|
|
86
|
+
* @param {BTNRep<K, V[], TreeMultiMapNode<K, V>> | K} keyNodeOrEntry - The `keyNodeOrEntry`
|
|
87
|
+
* parameter in the `deleteValue` function can be either a `BTNRep` object containing a key and an
|
|
88
|
+
* array of values, or just a key itself.
|
|
89
|
+
* @param {V} value - The `value` parameter in the `deleteValue` function represents the specific
|
|
90
|
+
* value that you want to remove from the multi-map data structure associated with a particular key.
|
|
91
|
+
* The function checks if the value exists in the array of values associated with the key, and if
|
|
92
|
+
* found, removes it from the array.
|
|
93
|
+
* @returns The `deleteValue` function returns a boolean value - `true` if the specified `value` was
|
|
94
|
+
* successfully deleted from the values associated with the `keyNodeOrEntry`, and `false` otherwise.
|
|
95
|
+
*/
|
|
96
|
+
deleteValue(keyNodeOrEntry: BTNRep<K, V[], TreeMultiMapNode<K, V>> | K, value: V): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Time Complexity: O(n)
|
|
99
|
+
* Space Complexity: O(n)
|
|
100
|
+
*
|
|
101
|
+
* The function `clone` overrides the default cloning behavior to create a deep copy of a tree
|
|
102
|
+
* structure.
|
|
103
|
+
* @returns The `cloned` object is being returned.
|
|
104
|
+
*/
|
|
105
|
+
clone(): TreeMultiMap<K, V, R, MK, MV, MR>;
|
|
106
|
+
}
|