dastal - v5.0.0 / LevelOrderSegmentTree
A SegmentTree internally represented as a binary tree within an array, with nodes stored in level-order traversal.
Memory usage: n elements require n - 1 + 2**(⌊log2(n-1)⌋ + 1) space.
Name |
---|
T |
- SegmentTree<T>
• new LevelOrderSegmentTree<T>(combine
, elements?
)
Construct a new SegmentTree
Name |
---|
T |
Name | Type | Default value | Description |
---|---|---|---|
combine |
CombineFn<T, T> | undefined |
- |
elements |
Iterable <T> |
[] | Initial elements to build into the tree |
src/segmentTree/levelOrderSegmentTree.ts:59
• get
size(): number
The number of elements in the collection.
number
src/segmentTree/levelOrderSegmentTree.ts:143
▸ [iterator](): Iterator
<T, any, undefined>
Return an iterator through the elements
Iterator
<T, any, undefined>
src/segmentTree/levelOrderSegmentTree.ts:150
▸ clear(): void
Removes all elements.
void
src/segmentTree/levelOrderSegmentTree.ts:74
▸ pop(): undefined
| T
Retrieves and removes the last element
undefined
| T
src/segmentTree/levelOrderSegmentTree.ts:80
▸ push(element
): number
Appends an element to the tree
Name | Type |
---|---|
element |
T |
number
src/segmentTree/levelOrderSegmentTree.ts:97
▸ query(min
, max
): T
Get the aggregated result of a given range in the tree
Name | Type |
---|---|
min |
number |
max |
number |
T
src/segmentTree/levelOrderSegmentTree.ts:115
▸ update(min
, max
, operation
): void
Update the elements of a given range in the tree
Name | Type |
---|---|
min |
number |
max |
number |
operation |
(element : T , index : number ) => T |
void