class AtCoder::SegTree(T)

Overview

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

Defined in:

seg_tree.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(values : Array(T)) #

[View source]
def self.new(values : Array(T), &operator : T, T -> T) #

[View source]

Instance Method Detail

def [](index : Int) #

Implements atcoder::segtree.get(index)


[View source]
def [](range : Range) #

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


[View source]
def []=(index : Int, value : T) #

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


[View source]
def all_prod #

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


[View source]
def get(index : Int) #

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


[View source]
def max_right(left, e : T | Nil = nil, & : T -> Bool) #

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


[View source]
def min_left(right, e : T | Nil = nil, & : T -> Bool) #

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


[View source]
def prod(left : Int, right : Int) #

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


[View source]
def set(index : Int, value : T) #

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


[View source]
def values : Array(T) #

[View source]