class AtCoder::LazySegTree(S, F)

Overview

Implements atcoder::lazy_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.

Similarly, the identity map of F 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 set F.

op = ->(a : Int32, b : Int32) { [a, b].min }
mapping = ->(f : Int32, x : Int32) { f }
composition = ->(a : Int32, b : Int32) { a }
tree = AtCoder::LazySegTree(Int32, Int32).new((0...100).to_a, op, mapping, composition)
tree[10...50] # => 10
tree[20...60] = 0
tree[50...80] # => 0

Defined in:

lazy_seg_tree.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(values : Array(S), operator : S, S -> S, application : F, S -> S, composition : F, F -> F) #

[View source]

Instance Method Detail

def [](index : Int) #

Implements atcoder::lazy_segtree.get(index).


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

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


[View source]
def []=(index : Int, applicator : F) #

Implements atcoder::lazy_segtree.apply(index, applicator).


[View source]
def []=(range : Range, applicator : F) #

Implements atcoder::lazy_segtree.apply(left, right, applicator). ameba:disable Metrics/CyclomaticComplexity


[View source]
def all_prod #

Implements atcoder::lazy_segtree.all_prod().


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

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


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

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


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

Implements atcoder::lazy_segtree.set(index, applicator).


[View source]