FenwickTree class

A Binary Indexed Tree over num supporting point updates and range sums.

Constructors

FenwickTree(int size)
Creates a tree of size elements, all initialized to zero. Requires size >= 0. Audited: 2026-06-12 11:26 EDT
FenwickTree.fromList(List<num> values)
Creates a tree seeded with values, in O(n). 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
prefixSum(int index) num
Sum of elements [0..index] inclusive (0-based), in O(log n). Requires 0 <= index < length. Audited: 2026-06-12 11:26 EDT
rangeSum(int low, int high) num
Sum of elements [low..high] inclusive (0-based), in O(log n). Requires 0 <= low <= high < length.
toString() String
A string representation of this object.
override
update(int index, num delta) → void
Adds delta to the element at index (0-based), in O(log n). Requires 0 <= index < length.
valueAt(int index) num
The current value at index (0-based), in O(log n). Requires 0 <= index < length. Audited: 2026-06-12 11:26 EDT

Operators

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