data-structure-typed 1.37.4 → 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/CHANGELOG.md +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.js.map +1 -1
- package/dist/data-structures/binary-tree/bst.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/binary-indexed-tree.d.ts +141 -43
- package/lib/data-structures/binary-tree/binary-indexed-tree.js +230 -42
- 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 +10 -10
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +264 -42
- package/src/data-structures/binary-tree/binary-tree.ts +2 -3
- package/src/data-structures/binary-tree/bst.ts +12 -3
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './heap';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
export * from './binary-tree';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './segment-tree';
|
|
5
|
-
export * from './tree-multiset';
|
|
6
|
-
export * from './abstract-graph';
|
|
7
|
-
export * from './map-graph';
|
|
8
|
-
export * from './rb-tree';
|
|
9
|
-
export * from './directed-graph';
|
|
2
|
+
export * from './graph';
|
|
3
|
+
export * from './linked-list';
|
|
10
4
|
export * from './heap';
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './doubly-linked-list';
|
|
13
|
-
export * from './navigator';
|
|
5
|
+
export * from './matrix';
|
|
14
6
|
export * from './hash';
|
|
15
|
-
|
|
16
|
-
export
|
|
17
|
-
export
|
|
7
|
+
export * from './priority-queue';
|
|
8
|
+
export * from './queue';
|
|
9
|
+
export * from './stack';
|
|
10
|
+
export * from './tree';
|
|
11
|
+
export * from './trie';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './navigator';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './stack';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tree';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './trie';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/src/types/helpers.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export type Comparator<T> = (a: T, b: T) => number;
|
|
2
2
|
|
|
3
|
-
// export enum DFSOrderPattern {'pre' = 'pre', 'in' = 'in', 'post' = 'post'}
|
|
4
3
|
export type DFSOrderPattern = 'pre' | 'in' | 'post';
|
|
4
|
+
|
|
5
|
+
export type MapCallback<N> = (node: N) => any;
|
|
6
|
+
|
|
7
|
+
export type MapCallbackReturn<N> = ReturnType<MapCallback<N>>;
|
package/src/utils/utils.ts
CHANGED
package/test/config.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return m[k];
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}
|
|
18
|
+
: function (o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
});
|
|
22
|
+
var __exportStar =
|
|
23
|
+
(this && this.__exportStar) ||
|
|
24
|
+
function (m, exports) {
|
|
25
|
+
for (var p in m)
|
|
26
|
+
if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, '__esModule', {value: true});
|
|
29
|
+
__exportStar(require('./utils'), exports);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return m[k];
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}
|
|
18
|
+
: function (o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
});
|
|
22
|
+
var __exportStar =
|
|
23
|
+
(this && this.__exportStar) ||
|
|
24
|
+
function (m, exports) {
|
|
25
|
+
for (var p in m)
|
|
26
|
+
if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, '__esModule', {value: true});
|
|
29
|
+
__exportStar(require('./big-o'), exports);
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import {BinaryIndexedTree} from '../../../../src';
|
|
2
|
+
import {isDebugTest} from '../../../config';
|
|
3
|
+
|
|
4
|
+
const isDebug = isDebugTest;
|
|
5
|
+
|
|
6
|
+
describe('BinaryIndexedTree simple', () => {
|
|
7
|
+
let bit: BinaryIndexedTree;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
//Create a new BinaryIndexedTree instance before each test case
|
|
11
|
+
bit = new BinaryIndexedTree({frequency: 0, max: 10}); // Modify the value of max as needed
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should initialize correctly', () => {
|
|
15
|
+
expect(bit.freq).toBe(0);
|
|
16
|
+
expect(bit.max).toBe(10);
|
|
17
|
+
expect(bit.freqMap).toEqual({0: 0}); // Modify the initialized record value according to the actual situation
|
|
18
|
+
// More initialization checks can be added
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should read a single value correctly', () => {
|
|
22
|
+
// Test the function of reading a single value
|
|
23
|
+
bit.writeSingle(5, 5); //Write test data
|
|
24
|
+
expect(bit.readSingle(5)).toBe(5); // Read and verify
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should update a value correctly', () => {
|
|
28
|
+
// Test the ability to update a single value
|
|
29
|
+
bit.writeSingle(5, 5); //Write test data
|
|
30
|
+
bit.update(5, 2); // update value
|
|
31
|
+
expect(bit.readSingle(5)).toBe(7); // Verify the updated value
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should find lower bound correctly', () => {
|
|
35
|
+
//Test the function of finding the lower bound
|
|
36
|
+
bit.writeSingle(2, 10);
|
|
37
|
+
bit.writeSingle(5, 20);
|
|
38
|
+
bit.writeSingle(8, 30);
|
|
39
|
+
expect(bit.lowerBound(15)).toBe(5); // Find and verify the lower bound
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should find upper bound correctly', () => {
|
|
43
|
+
//Test the function of finding the upper bound
|
|
44
|
+
bit.writeSingle(2, 10);
|
|
45
|
+
bit.writeSingle(5, 20);
|
|
46
|
+
bit.writeSingle(8, 30);
|
|
47
|
+
expect(bit.upperBound(25)).toBe(5); // Find and verify the upper bound
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('BinaryIndexedTree', () => {
|
|
52
|
+
const frequency = 999;
|
|
53
|
+
const max = 10;
|
|
54
|
+
let bit: BinaryIndexedTree;
|
|
55
|
+
|
|
56
|
+
beforeEach(function () {
|
|
57
|
+
bit = new BinaryIndexedTree({frequency, max});
|
|
58
|
+
});
|
|
59
|
+
it('should validate the index', function () {
|
|
60
|
+
expect(() => bit.readSingle(-1)).toThrow('Index out of range');
|
|
61
|
+
expect(() => bit.readSingle(10)).toThrow('Index out of range');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should read a single frequency correctly', function () {
|
|
65
|
+
for (let i = 0; i < max; i++) {
|
|
66
|
+
expect(bit.readSingle(i)).toBe(frequency);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
it('should validate the index', function () {
|
|
70
|
+
expect(() => bit.update(-1, 100)).toThrow('Index out of range');
|
|
71
|
+
expect(() => bit.update(10, 100)).toThrow('Index out of range');
|
|
72
|
+
});
|
|
73
|
+
it('should frequency and max', function () {
|
|
74
|
+
const frequency = 200;
|
|
75
|
+
const max = 1000;
|
|
76
|
+
const bit = new BinaryIndexedTree({frequency, max});
|
|
77
|
+
|
|
78
|
+
expect(bit.freq).toBe(frequency);
|
|
79
|
+
expect(bit.max).toBe(max);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should update the frequency with the given delta', function () {
|
|
83
|
+
for (let i = 0; i < max; i++) {
|
|
84
|
+
bit.update(i, i * 2);
|
|
85
|
+
}
|
|
86
|
+
for (let i = 0; i < max; i++) {
|
|
87
|
+
expect(bit.readSingle(i)).toBe(i * 2 + frequency);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
it('should validate the index', function () {
|
|
91
|
+
expect(() => bit.writeSingle(-1, 100)).toThrow('Index out of range');
|
|
92
|
+
expect(() => bit.writeSingle(10, 100)).toThrow('Index out of range');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should writeSingle to be correctly invoked', function () {
|
|
96
|
+
for (let i = 0; i < max; i++) {
|
|
97
|
+
bit.writeSingle(i, i * 2);
|
|
98
|
+
}
|
|
99
|
+
for (let i = 0; i < max; i++) {
|
|
100
|
+
expect(bit.readSingle(i)).toBe(i * 2);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('should read the frequency', function () {
|
|
105
|
+
for (let c = 0; c <= max; c++) {
|
|
106
|
+
expect(bit.read(c)).toBe(c * frequency);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const values = [-5, 0, 5, 10, 95, 100, 1000];
|
|
111
|
+
it('should find the upper-bound index', function () {
|
|
112
|
+
loopUpperBoundTests(bit, values);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should find the lower-bound index', function () {
|
|
116
|
+
loopLowerBoundTests(bit, values);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe('designated values', function () {
|
|
121
|
+
const array = [1, 8, 6, 10, 7, 9, 0, 2, 6, 3];
|
|
122
|
+
const sumArray = (sum => array.map(value => (sum += value)))(0);
|
|
123
|
+
let bit: BinaryIndexedTree;
|
|
124
|
+
|
|
125
|
+
beforeEach(function () {
|
|
126
|
+
bit = new BinaryIndexedTree({max: array.length});
|
|
127
|
+
array.forEach((value, i) => bit.writeSingle(i, value));
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
describe('readSingle', function () {
|
|
131
|
+
it('should read a single frequency correctly', function () {
|
|
132
|
+
array.forEach((value, i) => {
|
|
133
|
+
expect(bit.readSingle(i)).toBe(array[i]);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('update', function () {
|
|
139
|
+
it('should update the frequency with the given delta', function () {
|
|
140
|
+
array.forEach((value, i) => bit.update(i, value + i));
|
|
141
|
+
array.forEach((value, i) => {
|
|
142
|
+
expect(bit.readSingle(i)).toBe(array[i] * 2 + i);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('writeSingle', function () {
|
|
148
|
+
it('should write a single frequency correctly', function () {
|
|
149
|
+
array.forEach((value, i) => bit.writeSingle(i, value + i));
|
|
150
|
+
array.forEach((value, i) => {
|
|
151
|
+
expect(bit.readSingle(i)).toBe(array[i] + i);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe('read', function () {
|
|
157
|
+
it('should read the cumulative frequency correctly', function () {
|
|
158
|
+
expect(bit.read(0)).toBe(0);
|
|
159
|
+
sumArray.forEach((sum, i) => {
|
|
160
|
+
expect(bit.read(i + 1)).toBe(sum);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const values = [-5, 0, 15, 25, 43, 53, 100];
|
|
166
|
+
|
|
167
|
+
describe('upperBound', function () {
|
|
168
|
+
it('should find the upper-bound index', function () {
|
|
169
|
+
loopUpperBoundTests(bit, values);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
describe('lowerBound', function () {
|
|
174
|
+
it('should find the lower-bound index', function () {
|
|
175
|
+
loopLowerBoundTests(bit, values);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
describe('descending sequence', function () {
|
|
181
|
+
const array = [1, 8, -6, 10, 7, 9, 0, -2, 6, 3];
|
|
182
|
+
let bit: BinaryIndexedTree;
|
|
183
|
+
|
|
184
|
+
beforeEach(function () {
|
|
185
|
+
bit = new BinaryIndexedTree({max: array.length});
|
|
186
|
+
array.forEach((value, i) => bit.writeSingle(i, value));
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('should have a correct negativeCount property', function () {
|
|
190
|
+
expect(bit.negativeCount).toBe(2);
|
|
191
|
+
bit.update(2, 6);
|
|
192
|
+
expect(bit.negativeCount).toBe(1);
|
|
193
|
+
bit.update(7, 3);
|
|
194
|
+
expect(bit.negativeCount).toBe(0);
|
|
195
|
+
bit.update(8, -7);
|
|
196
|
+
expect(bit.negativeCount).toBe(1);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const values = [-5, 0, 15, 25, 43, 53, 100];
|
|
200
|
+
|
|
201
|
+
describe('upperBound', function () {
|
|
202
|
+
it('should validate the non-descending', function () {
|
|
203
|
+
expect(() => bit.upperBound(20)).toThrow('Must not be descending');
|
|
204
|
+
bit.update(2, 12);
|
|
205
|
+
bit.update(7, 4);
|
|
206
|
+
loopUpperBoundTests(bit, values);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
describe('BinaryIndexedTree lowerBound', function () {
|
|
211
|
+
it('should validate the non-descending', function () {
|
|
212
|
+
expect(() => bit.lowerBound(20)).toThrow('Sequence is not non-descending');
|
|
213
|
+
bit.update(2, 12);
|
|
214
|
+
bit.update(7, 4);
|
|
215
|
+
loopLowerBoundTests(bit, values);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
describe('BinaryIndexedTree additional tests', () => {
|
|
221
|
+
it('should handle read method correctly', () => {
|
|
222
|
+
const bit = new BinaryIndexedTree({max: 10});
|
|
223
|
+
bit.writeSingle(2, 10);
|
|
224
|
+
bit.writeSingle(5, 20);
|
|
225
|
+
bit.writeSingle(8, 30);
|
|
226
|
+
expect(bit.read(5)).toBe(10); // Ensure read method accumulates correctly
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('should handle consecutive operations', () => {
|
|
230
|
+
const bit = new BinaryIndexedTree({max: 10});
|
|
231
|
+
bit.writeSingle(2, 10);
|
|
232
|
+
bit.update(2, 5);
|
|
233
|
+
expect(bit.readSingle(2)).toBe(15);
|
|
234
|
+
bit.writeSingle(5, 20);
|
|
235
|
+
expect(bit.readSingle(5)).toBe(20);
|
|
236
|
+
expect(bit.lowerBound(15)).toBe(2);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('should handle frequent increment updates', () => {
|
|
240
|
+
const bit = new BinaryIndexedTree({max: 10});
|
|
241
|
+
for (let i = 0; i < 10; i++) {
|
|
242
|
+
bit.update(2, 5);
|
|
243
|
+
}
|
|
244
|
+
expect(bit.readSingle(2)).toBe(50);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('should handle edge cases', () => {
|
|
248
|
+
const bit = new BinaryIndexedTree({max: 10});
|
|
249
|
+
bit.writeSingle(9, 100);
|
|
250
|
+
expect(bit.readSingle(9)).toBe(100);
|
|
251
|
+
expect(bit.lowerBound(200)).toBe(10);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
function loopUpperBoundTests(bit: BinaryIndexedTree, values: number[]) {
|
|
255
|
+
for (const value of values) {
|
|
256
|
+
const index = bit.upperBound(value);
|
|
257
|
+
if (index > 0) {
|
|
258
|
+
expect(bit.read(index)).toBeLessThanOrEqual(value);
|
|
259
|
+
} else {
|
|
260
|
+
expect(index).toBe(0);
|
|
261
|
+
}
|
|
262
|
+
if (index < bit.max) {
|
|
263
|
+
expect(bit.read(index + 1)).toBeGreaterThan(value);
|
|
264
|
+
} else {
|
|
265
|
+
expect(index).toBe(bit.max);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function loopLowerBoundTests(bit: BinaryIndexedTree, values: number[]) {
|
|
271
|
+
for (const value of values) {
|
|
272
|
+
const index = bit.lowerBound(value);
|
|
273
|
+
if (index > 0) {
|
|
274
|
+
expect(bit.read(index)).toBeLessThan(value);
|
|
275
|
+
} else {
|
|
276
|
+
expect(index).toBe(0);
|
|
277
|
+
}
|
|
278
|
+
if (index < bit.max) {
|
|
279
|
+
expect(bit.read(index + 1)).toBeGreaterThanOrEqual(value);
|
|
280
|
+
} else {
|
|
281
|
+
expect(index).toBe(bit.max);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|