class

AtCoder::SegTree(T)

Inherits Reference / Object

Implements atcoder::segtree.

The identity element will be implicitly defined as nil, so you don't have to manually define it. In the other words, you cannot include nil into an element of the monoid.

tree = AtCoder::SegTree.new((0...100).to_a) { |a, b| [a, b].min }
tree[10...50] # => 10

Constructors

new(values : Array(T))
Source
new(values : Array(T), &operator : T, T -> T)
Source

Instance methods

[](index : Int)

Implements atcoder::segtree.get(index)

Source
[](range : Range)

Implements atcoder::segtree.prod(l, r)

Source
[]=(index : Int, value : T)

Implements atcoder::segtree.set(index, value)

Source
all_prod

Implements atcoder::segtree.all_prod(l, r)

Source
get(index : Int)

Implements atcoder::segtree.get(index) alias of .[]

Source
max_right(left, e : T | Nil = nil, & : T -> Bool)

Implements atcoder::lazy_segtree.max_right(left, g).

Source
min_left(right, e : T | Nil = nil, & : T -> Bool)

Implements atcoder::lazy_segtree.min_left(right, g).

Source
prod(left : Int, right : Int)

Implements atcoder::segtree.prod(left, right)

Source
set(index : Int, value : T)

Implements atcoder::segtree.set(index, value) alias of .[]=

Source
values
Source