SegmentTree class

A segment tree over num supporting point updates and range queries.

Constructors

SegmentTree.max(List<num> values)
Builds a max tree: range queries return the maximum over the range. The identity is double.negativeInfinity for the symmetric reason. Audited: 2026-06-12 11:26 EDT
SegmentTree.min(List<num> values)
Builds a min tree: range queries return the minimum over the range. The identity is double.infinity so an empty merge never lowers a result. Audited: 2026-06-12 11:26 EDT
SegmentTree.sum(List<num> values)
Builds a sum tree: range queries return the sum over the range. Audited: 2026-06-12 11:26 EDT

Properties

hashCode int
The hash code for this object.
no setterinherited
length int
Number of elements in the tree. Audited: 2026-06-12 11:26 EDT
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
query(int low, int high) num
Combined value over the inclusive range [low..high], in O(log n). Requires 0 <= low <= high < length.
toString() String
A string representation of this object.
override
update(int index, num value) → void
Sets the element at index (0-based) to value, in O(log n). Requires 0 <= index < length.
valueAt(int index) num
The current value at index (0-based). Requires 0 <= index < length. Audited: 2026-06-12 11:26 EDT

Operators

operator ==(Object other) bool
The equality operator.
inherited