data-structure-typed 1.37.3 → 1.37.5
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/dist/data-structures/binary-tree/avl-tree.d.ts +42 -34
- package/dist/data-structures/binary-tree/avl-tree.js +42 -34
- package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +141 -43
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +230 -42
- package/dist/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/binary-tree.d.ts +265 -168
- package/dist/data-structures/binary-tree/binary-tree.js +257 -170
- package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/bst.d.ts +104 -59
- package/dist/data-structures/binary-tree/bst.js +105 -60
- package/dist/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +47 -39
- package/dist/data-structures/binary-tree/tree-multiset.js +47 -39
- package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -1
- package/{lib/types/data-structures → dist/types/data-structures/binary-tree}/avl-tree.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.js.map +1 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +3 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
- package/dist/types/data-structures/{binary-tree.d.ts → binary-tree/binary-tree.d.ts} +1 -5
- package/dist/types/data-structures/binary-tree/binary-tree.js.map +1 -0
- package/dist/types/data-structures/{bst.d.ts → binary-tree/bst.d.ts} +1 -1
- package/dist/types/data-structures/binary-tree/bst.js.map +1 -0
- package/dist/types/data-structures/binary-tree/index.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/index.js +23 -0
- package/dist/types/data-structures/binary-tree/index.js.map +1 -0
- package/dist/types/data-structures/{rb-tree.d.ts → binary-tree/rb-tree.d.ts} +1 -1
- package/dist/types/data-structures/binary-tree/rb-tree.js.map +1 -0
- package/dist/types/data-structures/binary-tree/segment-tree.js.map +1 -0
- package/dist/types/data-structures/{tree-multiset.d.ts → binary-tree/tree-multiset.d.ts} +1 -1
- package/dist/types/data-structures/binary-tree/tree-multiset.js.map +1 -0
- package/dist/types/data-structures/graph/abstract-graph.js.map +1 -0
- package/dist/types/data-structures/graph/directed-graph.js.map +1 -0
- package/dist/types/data-structures/graph/index.d.ts +3 -0
- package/dist/types/data-structures/graph/index.js +20 -0
- package/dist/types/data-structures/graph/index.js.map +1 -0
- package/dist/types/data-structures/graph/map-graph.js.map +1 -0
- package/dist/types/data-structures/graph/undirected-graph.js +3 -0
- package/dist/types/data-structures/graph/undirected-graph.js.map +1 -0
- package/dist/types/data-structures/hash/coordinate-map.js +3 -0
- package/dist/types/data-structures/hash/coordinate-map.js.map +1 -0
- package/dist/types/data-structures/hash/coordinate-set.js +3 -0
- package/dist/types/data-structures/hash/coordinate-set.js.map +1 -0
- package/dist/types/data-structures/hash/hash-map.js +3 -0
- package/dist/types/data-structures/hash/hash-map.js.map +1 -0
- package/dist/types/data-structures/hash/hash-table.js +3 -0
- package/dist/types/data-structures/hash/hash-table.js.map +1 -0
- package/dist/types/data-structures/hash/index.js +3 -0
- package/dist/types/data-structures/hash/index.js.map +1 -0
- package/dist/types/data-structures/hash/tree-map.js +3 -0
- package/dist/types/data-structures/hash/tree-map.js.map +1 -0
- package/dist/types/data-structures/hash/tree-set.js +3 -0
- package/dist/types/data-structures/hash/tree-set.js.map +1 -0
- package/dist/types/data-structures/heap/heap.js.map +1 -0
- package/dist/types/data-structures/heap/index.d.ts +1 -0
- package/dist/types/data-structures/heap/index.js +18 -0
- package/dist/types/data-structures/heap/index.js.map +1 -0
- package/dist/types/data-structures/heap/max-heap.js +3 -0
- package/dist/types/data-structures/heap/max-heap.js.map +1 -0
- package/dist/types/data-structures/heap/min-heap.js +3 -0
- package/dist/types/data-structures/heap/min-heap.js.map +1 -0
- package/dist/types/data-structures/index.d.ts +8 -13
- package/dist/types/data-structures/index.js +8 -11
- package/dist/types/data-structures/index.js.map +1 -1
- package/dist/types/data-structures/linked-list/doubly-linked-list.js.map +1 -0
- package/dist/types/data-structures/linked-list/index.d.ts +2 -0
- package/dist/types/data-structures/linked-list/index.js +19 -0
- package/dist/types/data-structures/linked-list/index.js.map +1 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.js.map +1 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.js +3 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.js.map +1 -0
- package/dist/types/data-structures/matrix/index.d.ts +1 -0
- package/dist/types/data-structures/matrix/index.js +18 -0
- package/dist/types/data-structures/matrix/index.js.map +1 -0
- package/dist/types/data-structures/matrix/matrix.js +3 -0
- package/dist/types/data-structures/matrix/matrix.js.map +1 -0
- package/dist/types/data-structures/matrix/matrix2d.js +3 -0
- package/dist/types/data-structures/matrix/matrix2d.js.map +1 -0
- package/dist/types/data-structures/matrix/navigator.js.map +1 -0
- package/dist/types/data-structures/matrix/vector2d.js +3 -0
- package/dist/types/data-structures/matrix/vector2d.js.map +1 -0
- package/dist/types/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/types/data-structures/priority-queue/index.js +20 -0
- package/dist/types/data-structures/priority-queue/index.js.map +1 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.js +3 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.js.map +1 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.js +3 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.js.map +1 -0
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/data-structures/priority-queue/priority-queue.js +3 -0
- package/dist/types/data-structures/priority-queue/priority-queue.js.map +1 -0
- package/dist/types/data-structures/queue/deque.d.ts +1 -0
- package/dist/types/data-structures/queue/deque.js +3 -0
- package/dist/types/data-structures/queue/deque.js.map +1 -0
- package/dist/types/data-structures/queue/index.d.ts +2 -0
- package/dist/types/data-structures/queue/index.js +19 -0
- package/dist/types/data-structures/queue/index.js.map +1 -0
- package/dist/types/data-structures/queue/queue.d.ts +1 -0
- package/dist/types/data-structures/queue/queue.js +3 -0
- package/dist/types/data-structures/queue/queue.js.map +1 -0
- package/dist/types/data-structures/stack/index.d.ts +1 -0
- package/dist/types/data-structures/stack/index.js +18 -0
- package/dist/types/data-structures/stack/index.js.map +1 -0
- package/dist/types/data-structures/stack/stack.d.ts +1 -0
- package/dist/types/data-structures/stack/stack.js +3 -0
- package/dist/types/data-structures/stack/stack.js.map +1 -0
- package/dist/types/data-structures/tree/index.d.ts +1 -0
- package/dist/types/data-structures/tree/index.js +18 -0
- package/dist/types/data-structures/tree/index.js.map +1 -0
- package/dist/types/data-structures/tree/tree.d.ts +1 -0
- package/dist/types/data-structures/{hash.js → tree/tree.js} +1 -1
- package/dist/types/data-structures/tree/tree.js.map +1 -0
- package/dist/types/data-structures/trie/index.d.ts +1 -0
- package/dist/types/data-structures/trie/index.js +18 -0
- package/dist/types/data-structures/trie/index.js.map +1 -0
- package/dist/types/data-structures/trie/trie.d.ts +1 -0
- package/dist/types/data-structures/trie/trie.js +3 -0
- package/dist/types/data-structures/trie/trie.js.map +1 -0
- package/dist/types/helpers.d.ts +2 -0
- package/dist/utils/utils.d.ts +1 -0
- package/dist/utils/utils.js +8 -1
- package/dist/utils/utils.js.map +1 -1
- package/lib/data-structures/binary-tree/avl-tree.d.ts +42 -34
- package/lib/data-structures/binary-tree/avl-tree.js +42 -34
- package/lib/data-structures/binary-tree/binary-indexed-tree.d.ts +141 -43
- package/lib/data-structures/binary-tree/binary-indexed-tree.js +230 -42
- package/lib/data-structures/binary-tree/binary-tree.d.ts +265 -168
- package/lib/data-structures/binary-tree/binary-tree.js +257 -170
- package/lib/data-structures/binary-tree/bst.d.ts +104 -59
- package/lib/data-structures/binary-tree/bst.js +105 -60
- package/lib/data-structures/binary-tree/tree-multiset.d.ts +47 -39
- package/lib/data-structures/binary-tree/tree-multiset.js +47 -39
- package/{dist/types/data-structures → lib/types/data-structures/binary-tree}/avl-tree.d.ts +1 -1
- package/lib/types/data-structures/binary-tree/avl-tree.js +1 -0
- package/lib/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
- package/lib/types/data-structures/binary-tree/binary-indexed-tree.js +1 -0
- package/lib/types/data-structures/{binary-tree.d.ts → binary-tree/binary-tree.d.ts} +1 -5
- package/lib/types/data-structures/{bst.d.ts → binary-tree/bst.d.ts} +1 -1
- package/lib/types/data-structures/binary-tree/index.d.ts +6 -0
- package/lib/types/data-structures/binary-tree/index.js +6 -0
- package/lib/types/data-structures/{rb-tree.d.ts → binary-tree/rb-tree.d.ts} +1 -1
- package/lib/types/data-structures/binary-tree/segment-tree.js +1 -0
- package/lib/types/data-structures/{tree-multiset.d.ts → binary-tree/tree-multiset.d.ts} +1 -1
- package/lib/types/data-structures/binary-tree/tree-multiset.js +1 -0
- package/lib/types/data-structures/graph/abstract-graph.js +1 -0
- package/lib/types/data-structures/graph/index.d.ts +3 -0
- package/lib/types/data-structures/graph/index.js +3 -0
- package/lib/types/data-structures/graph/map-graph.js +1 -0
- package/lib/types/data-structures/graph/undirected-graph.d.ts +1 -0
- package/lib/types/data-structures/graph/undirected-graph.js +1 -0
- package/lib/types/data-structures/hash/coordinate-map.d.ts +1 -0
- package/lib/types/data-structures/hash/coordinate-map.js +1 -0
- package/lib/types/data-structures/hash/coordinate-set.d.ts +1 -0
- package/lib/types/data-structures/hash/coordinate-set.js +1 -0
- package/lib/types/data-structures/hash/hash-map.d.ts +1 -0
- package/lib/types/data-structures/hash/hash-map.js +1 -0
- package/lib/types/data-structures/hash/hash-table.d.ts +1 -0
- package/lib/types/data-structures/hash/hash-table.js +1 -0
- package/lib/types/data-structures/hash/index.js +1 -0
- package/lib/types/data-structures/hash/tree-map.d.ts +1 -0
- package/lib/types/data-structures/hash/tree-map.js +1 -0
- package/lib/types/data-structures/hash/tree-set.d.ts +1 -0
- package/lib/types/data-structures/hash/tree-set.js +1 -0
- package/lib/types/data-structures/heap/heap.d.ts +1 -0
- package/lib/types/data-structures/heap/heap.js +1 -0
- package/lib/types/data-structures/heap/index.d.ts +1 -0
- package/lib/types/data-structures/heap/index.js +1 -0
- package/lib/types/data-structures/heap/max-heap.d.ts +1 -0
- package/lib/types/data-structures/heap/max-heap.js +1 -0
- package/lib/types/data-structures/heap/min-heap.d.ts +1 -0
- package/lib/types/data-structures/heap/min-heap.js +1 -0
- package/lib/types/data-structures/index.d.ts +8 -13
- package/lib/types/data-structures/index.js +8 -11
- package/lib/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -0
- package/lib/types/data-structures/linked-list/doubly-linked-list.js +1 -0
- package/lib/types/data-structures/linked-list/index.d.ts +2 -0
- package/lib/types/data-structures/linked-list/index.js +2 -0
- package/lib/types/data-structures/linked-list/singly-linked-list.d.ts +1 -0
- package/lib/types/data-structures/linked-list/singly-linked-list.js +1 -0
- package/lib/types/data-structures/linked-list/skip-linked-list.d.ts +1 -0
- package/lib/types/data-structures/linked-list/skip-linked-list.js +1 -0
- package/lib/types/data-structures/matrix/index.d.ts +1 -0
- package/lib/types/data-structures/matrix/index.js +1 -0
- package/lib/types/data-structures/matrix/matrix.d.ts +1 -0
- package/lib/types/data-structures/matrix/matrix.js +1 -0
- package/lib/types/data-structures/matrix/matrix2d.d.ts +1 -0
- package/lib/types/data-structures/matrix/matrix2d.js +1 -0
- package/lib/types/data-structures/matrix/navigator.js +1 -0
- package/lib/types/data-structures/matrix/vector2d.d.ts +1 -0
- package/lib/types/data-structures/matrix/vector2d.js +1 -0
- package/lib/types/data-structures/priority-queue/index.d.ts +3 -0
- package/lib/types/data-structures/priority-queue/index.js +3 -0
- package/lib/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
- package/lib/types/data-structures/priority-queue/max-priority-queue.js +1 -0
- package/lib/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
- package/lib/types/data-structures/priority-queue/min-priority-queue.js +1 -0
- package/lib/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/lib/types/data-structures/priority-queue/priority-queue.js +1 -0
- package/lib/types/data-structures/queue/deque.d.ts +1 -0
- package/lib/types/data-structures/queue/deque.js +1 -0
- package/lib/types/data-structures/queue/index.d.ts +2 -0
- package/lib/types/data-structures/queue/index.js +2 -0
- package/lib/types/data-structures/queue/queue.d.ts +1 -0
- package/lib/types/data-structures/queue/queue.js +1 -0
- package/lib/types/data-structures/stack/index.d.ts +1 -0
- package/lib/types/data-structures/stack/index.js +1 -0
- package/lib/types/data-structures/stack/stack.d.ts +1 -0
- package/lib/types/data-structures/stack/stack.js +1 -0
- package/lib/types/data-structures/tree/index.d.ts +1 -0
- package/lib/types/data-structures/tree/index.js +1 -0
- package/lib/types/data-structures/tree/tree.d.ts +1 -0
- package/lib/types/data-structures/tree/tree.js +1 -0
- package/lib/types/data-structures/trie/index.d.ts +1 -0
- package/lib/types/data-structures/trie/index.js +1 -0
- package/lib/types/data-structures/trie/trie.d.ts +1 -0
- package/lib/types/data-structures/trie/trie.js +1 -0
- package/lib/types/helpers.d.ts +2 -0
- package/lib/utils/utils.d.ts +1 -0
- package/lib/utils/utils.js +6 -0
- package/package.json +6 -6
- package/src/data-structures/binary-tree/avl-tree.ts +42 -34
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +264 -42
- package/src/data-structures/binary-tree/binary-tree.ts +267 -172
- package/src/data-structures/binary-tree/bst.ts +111 -60
- package/src/data-structures/binary-tree/tree-multiset.ts +47 -39
- package/src/types/data-structures/{avl-tree.ts → binary-tree/avl-tree.ts} +1 -1
- package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
- package/src/types/data-structures/{binary-tree.ts → binary-tree/binary-tree.ts} +1 -13
- package/src/types/data-structures/{bst.ts → binary-tree/bst.ts} +1 -1
- package/src/types/data-structures/binary-tree/index.ts +6 -0
- package/src/types/data-structures/{rb-tree.ts → binary-tree/rb-tree.ts} +2 -2
- package/src/types/data-structures/{tree-multiset.ts → binary-tree/tree-multiset.ts} +1 -1
- package/src/types/data-structures/graph/index.ts +3 -0
- package/src/types/data-structures/graph/undirected-graph.ts +1 -0
- package/src/types/data-structures/hash/coordinate-map.ts +1 -0
- package/src/types/data-structures/hash/coordinate-set.ts +1 -0
- package/src/types/data-structures/hash/hash-map.ts +1 -0
- package/src/types/data-structures/hash/hash-table.ts +1 -0
- package/src/types/data-structures/hash/tree-map.ts +1 -0
- package/src/types/data-structures/hash/tree-set.ts +1 -0
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/heap/index.ts +1 -0
- package/src/types/data-structures/heap/max-heap.ts +1 -0
- package/src/types/data-structures/heap/min-heap.ts +1 -0
- package/src/types/data-structures/index.ts +8 -14
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -0
- package/src/types/data-structures/linked-list/index.ts +2 -0
- package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -0
- package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
- package/src/types/data-structures/matrix/index.ts +1 -0
- package/src/types/data-structures/matrix/matrix.ts +1 -0
- package/src/types/data-structures/matrix/matrix2d.ts +1 -0
- package/src/types/data-structures/matrix/vector2d.ts +1 -0
- package/src/types/data-structures/priority-queue/index.ts +3 -0
- package/src/types/data-structures/priority-queue/max-priority-queue.ts +1 -0
- package/src/types/data-structures/priority-queue/min-priority-queue.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/data-structures/queue/deque.ts +1 -0
- package/src/types/data-structures/queue/index.ts +2 -0
- package/src/types/data-structures/queue/queue.ts +1 -0
- package/src/types/data-structures/stack/index.ts +1 -0
- package/src/types/data-structures/stack/stack.ts +1 -0
- package/src/types/data-structures/tree/index.ts +1 -0
- package/src/types/data-structures/tree/tree.ts +1 -0
- package/src/types/data-structures/trie/index.ts +1 -0
- package/src/types/data-structures/trie/trie.ts +1 -0
- package/src/types/helpers.ts +4 -1
- package/src/utils/utils.ts +7 -0
- package/test/config.js +4 -0
- package/test/types/index.js +29 -0
- package/test/types/utils/big-o.js +2 -0
- package/test/types/utils/index.js +29 -0
- package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +284 -0
- package/test/utils/big-o.js +212 -0
- package/test/utils/index.js +30 -0
- package/test/utils/number.js +14 -0
- package/umd/bundle.min.js +1 -1
- package/umd/bundle.min.js.map +1 -1
- package/dist/types/data-structures/abstract-graph.js.map +0 -1
- package/dist/types/data-structures/avl-tree.js.map +0 -1
- package/dist/types/data-structures/binary-tree.js.map +0 -1
- package/dist/types/data-structures/bst.js.map +0 -1
- package/dist/types/data-structures/directed-graph.js.map +0 -1
- package/dist/types/data-structures/doubly-linked-list.js.map +0 -1
- package/dist/types/data-structures/hash.js.map +0 -1
- package/dist/types/data-structures/heap.js.map +0 -1
- package/dist/types/data-structures/map-graph.js.map +0 -1
- package/dist/types/data-structures/navigator.js.map +0 -1
- package/dist/types/data-structures/rb-tree.js.map +0 -1
- package/dist/types/data-structures/segment-tree.js.map +0 -1
- package/dist/types/data-structures/singly-linked-list.js.map +0 -1
- package/dist/types/data-structures/tree-multiset.js.map +0 -1
- /package/dist/types/data-structures/{avl-tree.js → binary-tree/avl-tree.js} +0 -0
- /package/dist/types/data-structures/{doubly-linked-list.d.ts → binary-tree/binary-indexed-tree.d.ts} +0 -0
- /package/dist/types/data-structures/{binary-tree.js → binary-tree/binary-tree.js} +0 -0
- /package/dist/types/data-structures/{bst.js → binary-tree/bst.js} +0 -0
- /package/dist/types/data-structures/{rb-tree.js → binary-tree/rb-tree.js} +0 -0
- /package/dist/types/data-structures/{segment-tree.d.ts → binary-tree/segment-tree.d.ts} +0 -0
- /package/dist/types/data-structures/{segment-tree.js → binary-tree/segment-tree.js} +0 -0
- /package/dist/types/data-structures/{tree-multiset.js → binary-tree/tree-multiset.js} +0 -0
- /package/dist/types/data-structures/{abstract-graph.d.ts → graph/abstract-graph.d.ts} +0 -0
- /package/dist/types/data-structures/{abstract-graph.js → graph/abstract-graph.js} +0 -0
- /package/dist/types/data-structures/{directed-graph.d.ts → graph/directed-graph.d.ts} +0 -0
- /package/dist/types/data-structures/{directed-graph.js → graph/directed-graph.js} +0 -0
- /package/dist/types/data-structures/{map-graph.d.ts → graph/map-graph.d.ts} +0 -0
- /package/dist/types/data-structures/{map-graph.js → graph/map-graph.js} +0 -0
- /package/dist/types/data-structures/{heap.d.ts → graph/undirected-graph.d.ts} +0 -0
- /package/dist/types/data-structures/{singly-linked-list.d.ts → hash/coordinate-map.d.ts} +0 -0
- /package/{lib/types/data-structures/abstract-graph.js → dist/types/data-structures/hash/coordinate-set.d.ts} +0 -0
- /package/{lib/types/data-structures/avl-tree.js → dist/types/data-structures/hash/hash-map.d.ts} +0 -0
- /package/{lib/types/data-structures/doubly-linked-list.d.ts → dist/types/data-structures/hash/hash-table.d.ts} +0 -0
- /package/dist/types/data-structures/{hash.d.ts → hash/index.d.ts} +0 -0
- /package/{lib/types/data-structures/doubly-linked-list.js → dist/types/data-structures/hash/tree-map.d.ts} +0 -0
- /package/{lib/types/data-structures/hash.js → dist/types/data-structures/hash/tree-set.d.ts} +0 -0
- /package/{lib/types/data-structures → dist/types/data-structures/heap}/heap.d.ts +0 -0
- /package/dist/types/data-structures/{heap.js → heap/heap.js} +0 -0
- /package/{lib/types/data-structures/heap.js → dist/types/data-structures/heap/max-heap.d.ts} +0 -0
- /package/{lib/types/data-structures/map-graph.js → dist/types/data-structures/heap/min-heap.d.ts} +0 -0
- /package/{lib/types/data-structures/navigator.js → dist/types/data-structures/linked-list/doubly-linked-list.d.ts} +0 -0
- /package/dist/types/data-structures/{doubly-linked-list.js → linked-list/doubly-linked-list.js} +0 -0
- /package/{lib/types/data-structures → dist/types/data-structures/linked-list}/singly-linked-list.d.ts +0 -0
- /package/dist/types/data-structures/{singly-linked-list.js → linked-list/singly-linked-list.js} +0 -0
- /package/{lib/types/data-structures/segment-tree.js → dist/types/data-structures/linked-list/skip-linked-list.d.ts} +0 -0
- /package/{lib/types/data-structures/singly-linked-list.js → dist/types/data-structures/matrix/matrix.d.ts} +0 -0
- /package/{lib/types/data-structures/tree-multiset.js → dist/types/data-structures/matrix/matrix2d.d.ts} +0 -0
- /package/dist/types/data-structures/{navigator.d.ts → matrix/navigator.d.ts} +0 -0
- /package/dist/types/data-structures/{navigator.js → matrix/navigator.js} +0 -0
- /package/{src/types/data-structures/doubly-linked-list.ts → dist/types/data-structures/matrix/vector2d.d.ts} +0 -0
- /package/{src/types/data-structures/heap.ts → dist/types/data-structures/priority-queue/max-priority-queue.d.ts} +0 -0
- /package/{src/types/data-structures/singly-linked-list.ts → dist/types/data-structures/priority-queue/min-priority-queue.d.ts} +0 -0
- /package/lib/types/data-structures/{binary-tree.js → binary-tree/binary-tree.js} +0 -0
- /package/lib/types/data-structures/{bst.js → binary-tree/bst.js} +0 -0
- /package/lib/types/data-structures/{rb-tree.js → binary-tree/rb-tree.js} +0 -0
- /package/lib/types/data-structures/{segment-tree.d.ts → binary-tree/segment-tree.d.ts} +0 -0
- /package/lib/types/data-structures/{abstract-graph.d.ts → graph/abstract-graph.d.ts} +0 -0
- /package/lib/types/data-structures/{directed-graph.d.ts → graph/directed-graph.d.ts} +0 -0
- /package/lib/types/data-structures/{directed-graph.js → graph/directed-graph.js} +0 -0
- /package/lib/types/data-structures/{map-graph.d.ts → graph/map-graph.d.ts} +0 -0
- /package/lib/types/data-structures/{hash.d.ts → hash/index.d.ts} +0 -0
- /package/lib/types/data-structures/{navigator.d.ts → matrix/navigator.d.ts} +0 -0
- /package/src/types/data-structures/{segment-tree.ts → binary-tree/segment-tree.ts} +0 -0
- /package/src/types/data-structures/{abstract-graph.ts → graph/abstract-graph.ts} +0 -0
- /package/src/types/data-structures/{directed-graph.ts → graph/directed-graph.ts} +0 -0
- /package/src/types/data-structures/{map-graph.ts → graph/map-graph.ts} +0 -0
- /package/src/types/data-structures/{hash.ts → hash/index.ts} +0 -0
- /package/src/types/data-structures/{navigator.ts → matrix/navigator.ts} +0 -0
|
@@ -21,72 +21,80 @@ export declare class AVLTree<N extends AVLTreeNode<N['val'], N> = AVLTreeNode> e
|
|
|
21
21
|
*/
|
|
22
22
|
constructor(options?: AVLTreeOptions);
|
|
23
23
|
/**
|
|
24
|
-
* The
|
|
25
|
-
* @param {N} srcNode - The source node that
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* The function swaps the key, value, and height properties between two nodes in a binary tree.
|
|
25
|
+
* @param {N} srcNode - The `srcNode` parameter represents the source node that needs to be swapped
|
|
26
|
+
* with the `destNode`.
|
|
27
|
+
* @param {N} destNode - The `destNode` parameter represents the destination node where the values
|
|
28
|
+
* from the source node (`srcNode`) will be swapped to.
|
|
29
|
+
* @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
|
|
29
30
|
*/
|
|
30
31
|
protected _swap(srcNode: N, destNode: N): N;
|
|
31
32
|
/**
|
|
32
|
-
* The function creates a new AVL tree node with the
|
|
33
|
-
* @param {BinaryTreeNodeKey} key - The
|
|
34
|
-
*
|
|
35
|
-
* @param [val] - The `val`
|
|
36
|
-
*
|
|
33
|
+
* The function creates a new AVL tree node with the specified key and value.
|
|
34
|
+
* @param {BinaryTreeNodeKey} key - The key parameter is the key value that will be associated with
|
|
35
|
+
* the new node. It is used to determine the position of the node in the binary search tree.
|
|
36
|
+
* @param [val] - The parameter `val` is an optional value that can be assigned to the node. It is of
|
|
37
|
+
* type `N['val']`, which means it can be any value that is assignable to the `val` property of the
|
|
38
|
+
* node type `N`.
|
|
37
39
|
* @returns a new AVLTreeNode object with the specified key and value.
|
|
38
40
|
*/
|
|
39
41
|
createNode(key: BinaryTreeNodeKey, val?: N['val']): N;
|
|
40
42
|
/**
|
|
41
|
-
* The function overrides the add method of a binary tree node and balances the tree after inserting
|
|
42
|
-
*
|
|
43
|
-
* @param
|
|
44
|
-
* `
|
|
45
|
-
* @
|
|
43
|
+
* The function overrides the add method of a binary tree node and balances the tree after inserting
|
|
44
|
+
* a new node.
|
|
45
|
+
* @param {BinaryTreeNodeKey | N | null} keyOrNode - The `keyOrNode` parameter can accept either a
|
|
46
|
+
* `BinaryTreeNodeKey` or a `N` (which represents a node in the binary tree) or `null`.
|
|
47
|
+
* @param [val] - The `val` parameter is the value that you want to assign to the new node that you
|
|
48
|
+
* are adding to the binary search tree.
|
|
49
|
+
* @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
|
|
46
50
|
*/
|
|
47
51
|
add(keyOrNode: BinaryTreeNodeKey | N | null, val?: N['val']): N | null | undefined;
|
|
48
52
|
/**
|
|
49
|
-
* The function overrides the delete method of a binary tree and
|
|
53
|
+
* The function overrides the delete method of a binary tree and balances the tree after deleting a
|
|
54
|
+
* node if necessary.
|
|
55
|
+
* @param {N | BinaryTreeNodeKey} nodeOrKey - The `nodeOrKey` parameter can be either a node object
|
|
56
|
+
* (`N`) or a key value (`BinaryTreeNodeKey`).
|
|
50
57
|
* @returns The method is returning an array of `BinaryTreeDeletedResult<N>` objects.
|
|
51
|
-
* @param nodeOrKey - The `nodeOrKey` parameter is either a node or a key that needs to be deleted from the binary tree.
|
|
52
58
|
*/
|
|
53
59
|
delete(nodeOrKey: N | BinaryTreeNodeKey): BinaryTreeDeletedResult<N>[];
|
|
54
60
|
/**
|
|
55
|
-
* The balance factor of a
|
|
56
|
-
*
|
|
57
|
-
* @
|
|
58
|
-
*
|
|
61
|
+
* The function calculates the balance factor of a node in a binary tree.
|
|
62
|
+
* @param {N} node - The parameter "node" represents a node in a binary tree data structure.
|
|
63
|
+
* @returns the balance factor of a given node. The balance factor is calculated by subtracting the
|
|
64
|
+
* height of the left subtree from the height of the right subtree.
|
|
59
65
|
*/
|
|
60
66
|
protected _balanceFactor(node: N): number;
|
|
61
67
|
/**
|
|
62
|
-
* The function updates the height of a node in
|
|
63
|
-
*
|
|
68
|
+
* The function updates the height of a node in a binary tree based on the heights of its left and
|
|
69
|
+
* right children.
|
|
70
|
+
* @param {N} node - The parameter "node" represents a node in a binary tree data structure.
|
|
64
71
|
*/
|
|
65
72
|
protected _updateHeight(node: N): void;
|
|
66
73
|
/**
|
|
67
|
-
* The `_balancePath` function
|
|
68
|
-
*
|
|
69
|
-
* @param node - The `node` parameter
|
|
74
|
+
* The `_balancePath` function is used to update the heights of nodes and perform rotation operations
|
|
75
|
+
* to restore balance in an AVL tree after inserting a node.
|
|
76
|
+
* @param {N} node - The `node` parameter in the `_balancePath` function represents the node in the
|
|
77
|
+
* AVL tree that needs to be balanced.
|
|
70
78
|
*/
|
|
71
79
|
protected _balancePath(node: N): void;
|
|
72
80
|
/**
|
|
73
|
-
* The `_balanceLL`
|
|
74
|
-
* @param A -
|
|
81
|
+
* The function `_balanceLL` performs a left-left rotation to balance a binary tree.
|
|
82
|
+
* @param {N} A - A is a node in a binary tree.
|
|
75
83
|
*/
|
|
76
84
|
protected _balanceLL(A: N): void;
|
|
77
85
|
/**
|
|
78
|
-
* The `_balanceLR` function performs a left-right rotation to balance
|
|
79
|
-
* @param A - A is
|
|
86
|
+
* The `_balanceLR` function performs a left-right rotation to balance a binary tree.
|
|
87
|
+
* @param {N} A - A is a node in a binary tree.
|
|
80
88
|
*/
|
|
81
89
|
protected _balanceLR(A: N): void;
|
|
82
90
|
/**
|
|
83
|
-
* The `_balanceRR`
|
|
84
|
-
* @param A -
|
|
91
|
+
* The function `_balanceRR` performs a right-right rotation to balance a binary tree.
|
|
92
|
+
* @param {N} A - A is a node in a binary tree.
|
|
85
93
|
*/
|
|
86
94
|
protected _balanceRR(A: N): void;
|
|
87
95
|
/**
|
|
88
|
-
* The `_balanceRL`
|
|
89
|
-
* @param A - A is
|
|
96
|
+
* The function `_balanceRL` performs a right-left rotation to balance a binary tree.
|
|
97
|
+
* @param {N} A - A is a node in a binary tree.
|
|
90
98
|
*/
|
|
91
99
|
protected _balanceRL(A: N): void;
|
|
92
100
|
}
|
|
@@ -27,11 +27,12 @@ class AVLTree extends bst_1.BST {
|
|
|
27
27
|
super(options);
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* The
|
|
31
|
-
* @param {N} srcNode - The source node that
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
30
|
+
* The function swaps the key, value, and height properties between two nodes in a binary tree.
|
|
31
|
+
* @param {N} srcNode - The `srcNode` parameter represents the source node that needs to be swapped
|
|
32
|
+
* with the `destNode`.
|
|
33
|
+
* @param {N} destNode - The `destNode` parameter represents the destination node where the values
|
|
34
|
+
* from the source node (`srcNode`) will be swapped to.
|
|
35
|
+
* @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
|
|
35
36
|
*/
|
|
36
37
|
_swap(srcNode, destNode) {
|
|
37
38
|
const { key, val, height } = destNode;
|
|
@@ -48,22 +49,25 @@ class AVLTree extends bst_1.BST {
|
|
|
48
49
|
return destNode;
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
|
-
* The function creates a new AVL tree node with the
|
|
52
|
-
* @param {BinaryTreeNodeKey} key - The
|
|
53
|
-
*
|
|
54
|
-
* @param [val] - The `val`
|
|
55
|
-
*
|
|
52
|
+
* The function creates a new AVL tree node with the specified key and value.
|
|
53
|
+
* @param {BinaryTreeNodeKey} key - The key parameter is the key value that will be associated with
|
|
54
|
+
* the new node. It is used to determine the position of the node in the binary search tree.
|
|
55
|
+
* @param [val] - The parameter `val` is an optional value that can be assigned to the node. It is of
|
|
56
|
+
* type `N['val']`, which means it can be any value that is assignable to the `val` property of the
|
|
57
|
+
* node type `N`.
|
|
56
58
|
* @returns a new AVLTreeNode object with the specified key and value.
|
|
57
59
|
*/
|
|
58
60
|
createNode(key, val) {
|
|
59
61
|
return new AVLTreeNode(key, val);
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
62
|
-
* The function overrides the add method of a binary tree node and balances the tree after inserting
|
|
63
|
-
*
|
|
64
|
-
* @param
|
|
65
|
-
* `
|
|
66
|
-
* @
|
|
64
|
+
* The function overrides the add method of a binary tree node and balances the tree after inserting
|
|
65
|
+
* a new node.
|
|
66
|
+
* @param {BinaryTreeNodeKey | N | null} keyOrNode - The `keyOrNode` parameter can accept either a
|
|
67
|
+
* `BinaryTreeNodeKey` or a `N` (which represents a node in the binary tree) or `null`.
|
|
68
|
+
* @param [val] - The `val` parameter is the value that you want to assign to the new node that you
|
|
69
|
+
* are adding to the binary search tree.
|
|
70
|
+
* @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
|
|
67
71
|
*/
|
|
68
72
|
add(keyOrNode, val) {
|
|
69
73
|
// TODO support node as a param
|
|
@@ -73,9 +77,11 @@ class AVLTree extends bst_1.BST {
|
|
|
73
77
|
return inserted;
|
|
74
78
|
}
|
|
75
79
|
/**
|
|
76
|
-
* The function overrides the delete method of a binary tree and
|
|
80
|
+
* The function overrides the delete method of a binary tree and balances the tree after deleting a
|
|
81
|
+
* node if necessary.
|
|
82
|
+
* @param {N | BinaryTreeNodeKey} nodeOrKey - The `nodeOrKey` parameter can be either a node object
|
|
83
|
+
* (`N`) or a key value (`BinaryTreeNodeKey`).
|
|
77
84
|
* @returns The method is returning an array of `BinaryTreeDeletedResult<N>` objects.
|
|
78
|
-
* @param nodeOrKey - The `nodeOrKey` parameter is either a node or a key that needs to be deleted from the binary tree.
|
|
79
85
|
*/
|
|
80
86
|
delete(nodeOrKey) {
|
|
81
87
|
const deletedResults = super.delete(nodeOrKey);
|
|
@@ -87,10 +93,10 @@ class AVLTree extends bst_1.BST {
|
|
|
87
93
|
return deletedResults;
|
|
88
94
|
}
|
|
89
95
|
/**
|
|
90
|
-
* The balance factor of a
|
|
91
|
-
*
|
|
92
|
-
* @
|
|
93
|
-
*
|
|
96
|
+
* The function calculates the balance factor of a node in a binary tree.
|
|
97
|
+
* @param {N} node - The parameter "node" represents a node in a binary tree data structure.
|
|
98
|
+
* @returns the balance factor of a given node. The balance factor is calculated by subtracting the
|
|
99
|
+
* height of the left subtree from the height of the right subtree.
|
|
94
100
|
*/
|
|
95
101
|
_balanceFactor(node) {
|
|
96
102
|
if (!node.right)
|
|
@@ -103,8 +109,9 @@ class AVLTree extends bst_1.BST {
|
|
|
103
109
|
return node.right.height - node.left.height;
|
|
104
110
|
}
|
|
105
111
|
/**
|
|
106
|
-
* The function updates the height of a node in
|
|
107
|
-
*
|
|
112
|
+
* The function updates the height of a node in a binary tree based on the heights of its left and
|
|
113
|
+
* right children.
|
|
114
|
+
* @param {N} node - The parameter "node" represents a node in a binary tree data structure.
|
|
108
115
|
*/
|
|
109
116
|
_updateHeight(node) {
|
|
110
117
|
if (!node.left && !node.right)
|
|
@@ -119,9 +126,10 @@ class AVLTree extends bst_1.BST {
|
|
|
119
126
|
node.height = 1 + Math.max(node.right.height, node.left.height);
|
|
120
127
|
}
|
|
121
128
|
/**
|
|
122
|
-
* The `_balancePath` function
|
|
123
|
-
*
|
|
124
|
-
* @param node - The `node` parameter
|
|
129
|
+
* The `_balancePath` function is used to update the heights of nodes and perform rotation operations
|
|
130
|
+
* to restore balance in an AVL tree after inserting a node.
|
|
131
|
+
* @param {N} node - The `node` parameter in the `_balancePath` function represents the node in the
|
|
132
|
+
* AVL tree that needs to be balanced.
|
|
125
133
|
*/
|
|
126
134
|
_balancePath(node) {
|
|
127
135
|
const path = this.getPathToRoot(node, false); // first O(log n) + O(log n)
|
|
@@ -163,8 +171,8 @@ class AVLTree extends bst_1.BST {
|
|
|
163
171
|
}
|
|
164
172
|
}
|
|
165
173
|
/**
|
|
166
|
-
* The `_balanceLL`
|
|
167
|
-
* @param A -
|
|
174
|
+
* The function `_balanceLL` performs a left-left rotation to balance a binary tree.
|
|
175
|
+
* @param {N} A - A is a node in a binary tree.
|
|
168
176
|
*/
|
|
169
177
|
_balanceLL(A) {
|
|
170
178
|
const parentOfA = A.parent;
|
|
@@ -197,8 +205,8 @@ class AVLTree extends bst_1.BST {
|
|
|
197
205
|
this._updateHeight(B);
|
|
198
206
|
}
|
|
199
207
|
/**
|
|
200
|
-
* The `_balanceLR` function performs a left-right rotation to balance
|
|
201
|
-
* @param A - A is
|
|
208
|
+
* The `_balanceLR` function performs a left-right rotation to balance a binary tree.
|
|
209
|
+
* @param {N} A - A is a node in a binary tree.
|
|
202
210
|
*/
|
|
203
211
|
_balanceLR(A) {
|
|
204
212
|
const parentOfA = A.parent;
|
|
@@ -246,8 +254,8 @@ class AVLTree extends bst_1.BST {
|
|
|
246
254
|
C && this._updateHeight(C);
|
|
247
255
|
}
|
|
248
256
|
/**
|
|
249
|
-
* The `_balanceRR`
|
|
250
|
-
* @param A -
|
|
257
|
+
* The function `_balanceRR` performs a right-right rotation to balance a binary tree.
|
|
258
|
+
* @param {N} A - A is a node in a binary tree.
|
|
251
259
|
*/
|
|
252
260
|
_balanceRR(A) {
|
|
253
261
|
const parentOfA = A.parent;
|
|
@@ -281,8 +289,8 @@ class AVLTree extends bst_1.BST {
|
|
|
281
289
|
B && this._updateHeight(B);
|
|
282
290
|
}
|
|
283
291
|
/**
|
|
284
|
-
* The `_balanceRL`
|
|
285
|
-
* @param A - A is
|
|
292
|
+
* The function `_balanceRL` performs a right-left rotation to balance a binary tree.
|
|
293
|
+
* @param {N} A - A is a node in a binary tree.
|
|
286
294
|
*/
|
|
287
295
|
_balanceRL(A) {
|
|
288
296
|
const parentOfA = A.parent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avl-tree.js","sourceRoot":"","sources":["../../../src/data-structures/binary-tree/avl-tree.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,+BAAmC;AAInC,MAAa,WAAmF,SAAQ,aAGvG;IAGC,YAAY,GAAsB,EAAE,GAAO;QACzC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AAVD,kCAUC;AAED,MAAa,OAA0D,SAAQ,SAAM;IACnF;;;;;OAKG;IACH,YAAY,OAAwB;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"avl-tree.js","sourceRoot":"","sources":["../../../src/data-structures/bin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ACV,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;aACnB;YACD,IAAI,CAAC,CAAC,KAAK,EAAE;gBACX,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;aACpB;YACD,CAAC,CAAC,MAAM,GAAG,SAAS,CAAC;SACtB;QAED,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE;YACnB,IAAI,CAAC;gBAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SACzB;aAAM;YACL,IAAI,SAAS,EAAE;gBACb,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC,EAAE;oBACxB,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC;iBACpB;qBAAM;oBACL,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC;iBACrB;aACF;SACF;QAED,IAAI,CAAC;YAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC;YAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC;YAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC;YAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;QAEnB,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;CACF;AA9TD,0BA8TC"}
|
|
@@ -1,46 +1,144 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* data-structure-typed
|
|
3
|
-
*
|
|
4
|
-
* @author Tyler Zeng
|
|
5
|
-
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
|
-
* @license MIT License
|
|
7
|
-
*/
|
|
8
1
|
export declare class BinaryIndexedTree {
|
|
2
|
+
protected readonly _freq: number;
|
|
3
|
+
protected readonly _max: number;
|
|
9
4
|
/**
|
|
10
|
-
* The constructor initializes
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
constructor(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @param {number}
|
|
41
|
-
* the
|
|
42
|
-
* @
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
5
|
+
* The constructor initializes the properties of an object, including default frequency, maximum
|
|
6
|
+
* value, a freqMap data structure, the most significant bit, and the count of negative frequencies.
|
|
7
|
+
* @param - - `frequency`: The default frequency value. It is optional and has a default
|
|
8
|
+
* value of 0.
|
|
9
|
+
*/
|
|
10
|
+
constructor({ frequency, max }: {
|
|
11
|
+
frequency?: number;
|
|
12
|
+
max: number;
|
|
13
|
+
});
|
|
14
|
+
protected _freqMap: Record<number, number>;
|
|
15
|
+
get freqMap(): Record<number, number>;
|
|
16
|
+
set freqMap(value: Record<number, number>);
|
|
17
|
+
protected _msb: number;
|
|
18
|
+
get msb(): number;
|
|
19
|
+
set msb(value: number);
|
|
20
|
+
protected _negativeCount: number;
|
|
21
|
+
get negativeCount(): number;
|
|
22
|
+
set negativeCount(value: number);
|
|
23
|
+
get freq(): number;
|
|
24
|
+
get max(): number;
|
|
25
|
+
/**
|
|
26
|
+
* The function "readSingle" reads a single number from a specified index.
|
|
27
|
+
* @param {number} index - The `index` parameter is a number that represents the index of an element in a
|
|
28
|
+
* collection or array.
|
|
29
|
+
* @returns a number.
|
|
30
|
+
*/
|
|
31
|
+
readSingle(index: number): number;
|
|
32
|
+
/**
|
|
33
|
+
* The "update" function updates the value at a given index by adding a delta and triggers a callback
|
|
34
|
+
* to notify of the change.
|
|
35
|
+
* @param {number} position - The `index` parameter represents the index of the element that needs to be
|
|
36
|
+
* updated in the data structure.
|
|
37
|
+
* @param {number} change - The "delta" parameter represents the change in value that needs to be
|
|
38
|
+
* applied to the frequency at the specified index.
|
|
39
|
+
*/
|
|
40
|
+
update(position: number, change: number): void;
|
|
41
|
+
/**
|
|
42
|
+
* The function "writeSingle" checks the index and writes a single value with a given frequency.
|
|
43
|
+
* @param {number} index - The `index` parameter is a number that represents the index of an element. It
|
|
44
|
+
* is used to identify the specific element that needs to be written.
|
|
45
|
+
* @param {number} freq - The `freq` parameter represents the frequency value that needs to be
|
|
46
|
+
* written.
|
|
47
|
+
*/
|
|
48
|
+
writeSingle(index: number, freq: number): void;
|
|
49
|
+
/**
|
|
50
|
+
* The read function takes a count parameter, checks if it is an integer, and returns the result of
|
|
51
|
+
* calling the _read function with the count parameter clamped between 0 and the maximum value.
|
|
52
|
+
* @param {number} count - The `count` parameter is a number that represents the number of items to
|
|
53
|
+
* read.
|
|
54
|
+
* @returns a number.
|
|
55
|
+
*/
|
|
56
|
+
read(count: number): number;
|
|
57
|
+
/**
|
|
58
|
+
* The function returns the lower bound of a non-descending sequence that sums up to a given number.
|
|
59
|
+
* @param {number} sum - The `sum` parameter is a number that represents the target sum that we want
|
|
60
|
+
* to find in the sequence.
|
|
61
|
+
* @returns The lowerBound function is returning a number.
|
|
62
|
+
*/
|
|
63
|
+
lowerBound(sum: number): number;
|
|
64
|
+
/**
|
|
65
|
+
* The upperBound function returns the index of the first element in a sequence that is greater than
|
|
66
|
+
* or equal to a given sum.
|
|
67
|
+
* @param {number} sum - The "sum" parameter is a number that represents the target sum that we want
|
|
68
|
+
* to find in the sequence.
|
|
69
|
+
* @returns The upperBound function is returning a number.
|
|
70
|
+
*/
|
|
71
|
+
upperBound(sum: number): number;
|
|
72
|
+
/**
|
|
73
|
+
* The function returns the value of a specific index in a freqMap data structure, or a default value if
|
|
74
|
+
* the index is not found.
|
|
75
|
+
* @param {number} index - The `index` parameter is a number that represents the index of a node in a
|
|
76
|
+
* freqMap data structure.
|
|
77
|
+
* @returns a number.
|
|
78
|
+
*/
|
|
79
|
+
protected _getFrequency(index: number): number;
|
|
80
|
+
/**
|
|
81
|
+
* The function _updateFrequency adds a delta value to the element at the specified index in the freqMap array.
|
|
82
|
+
* @param {number} index - The index parameter is a number that represents the index of the freqMap
|
|
83
|
+
* element that needs to be updated.
|
|
84
|
+
* @param {number} delta - The `delta` parameter represents the change in value that needs to be
|
|
85
|
+
* added to the freqMap at the specified `index`.
|
|
86
|
+
*/
|
|
87
|
+
protected _updateFrequency(index: number, delta: number): void;
|
|
88
|
+
/**
|
|
89
|
+
* The function checks if the given index is valid and within the range.
|
|
90
|
+
* @param {number} index - The parameter "index" is of type number and represents the index value
|
|
91
|
+
* that needs to be checked.
|
|
92
|
+
*/
|
|
93
|
+
protected _checkIndex(index: number): void;
|
|
94
|
+
/**
|
|
95
|
+
* The function calculates the sum of elements in an array up to a given index using a binary indexed
|
|
96
|
+
* freqMap.
|
|
97
|
+
* @param {number} index - The `index` parameter is a number that represents the index of an element in a
|
|
98
|
+
* data structure.
|
|
99
|
+
* @returns a number.
|
|
100
|
+
*/
|
|
101
|
+
protected _readSingle(index: number): number;
|
|
102
|
+
/**
|
|
103
|
+
* The function `_updateNegativeCount` updates a counter based on changes in frequency values.
|
|
104
|
+
* @param {number} freqCur - The current frequency value.
|
|
105
|
+
* @param {number} freqNew - The freqNew parameter represents the new frequency value.
|
|
106
|
+
*/
|
|
107
|
+
protected _updateNegativeCount(freqCur: number, freqNew: number): void;
|
|
108
|
+
/**
|
|
109
|
+
* The `_update` function updates the values in a binary indexed freqMap starting from a given index and
|
|
110
|
+
* propagating the changes to its parent nodes.
|
|
111
|
+
* @param {number} index - The `index` parameter is a number that represents the index of the element in
|
|
112
|
+
* the data structure that needs to be updated.
|
|
113
|
+
* @param {number} delta - The `delta` parameter represents the change in value that needs to be
|
|
114
|
+
* applied to the elements in the data structure.
|
|
115
|
+
*/
|
|
116
|
+
protected _update(index: number, delta: number): void;
|
|
117
|
+
/**
|
|
118
|
+
* The `_writeSingle` function updates the frequency at a specific index and triggers a callback if
|
|
119
|
+
* the frequency has changed.
|
|
120
|
+
* @param {number} index - The `index` parameter is a number that represents the index of the element
|
|
121
|
+
* being modified or accessed.
|
|
122
|
+
* @param {number} freq - The `freq` parameter represents the new frequency value that needs to be
|
|
123
|
+
* written to the specified index `index`.
|
|
124
|
+
*/
|
|
125
|
+
protected _writeSingle(index: number, freq: number): void;
|
|
126
|
+
/**
|
|
127
|
+
* The `_read` function calculates the sum of values in a binary freqMap up to a given count.
|
|
128
|
+
* @param {number} count - The `count` parameter is a number that represents the number of elements
|
|
129
|
+
* to read from the freqMap.
|
|
130
|
+
* @returns the sum of the values obtained from calling the `_getFrequency` method for each index in the
|
|
131
|
+
* range from `count` to 1.
|
|
132
|
+
*/
|
|
133
|
+
protected _read(count: number): number;
|
|
134
|
+
/**
|
|
135
|
+
* The function `_binarySearch` performs a binary search to find the largest number that satisfies a given
|
|
136
|
+
* condition.
|
|
137
|
+
* @param {number} sum - The sum parameter is a number that represents the target sum value.
|
|
138
|
+
* @param before - The `before` parameter is a function that takes two numbers `x` and `y` as
|
|
139
|
+
* arguments and returns a boolean value. It is used to determine if `x` is less than or equal to
|
|
140
|
+
* `y`. The purpose of this function is to compare two numbers and determine their order.
|
|
141
|
+
* @returns the value of the variable "left".
|
|
142
|
+
*/
|
|
143
|
+
protected _binarySearch(sum: number, before: (x: number, y: number) => boolean): number;
|
|
46
144
|
}
|