class SlopeTrick(T)

Overview

reference: https://maspypy.com/slope-trick-1-解説編

Defined in:

datastructure/slope_trick.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Lets f(x) = 0


[View source]

Instance Method Detail

def accumulate_min : self #

g(x) := min_{y <= x} f(y)


[View source]
def accumulate_min_right : self #

g(x) := min_{y >= x} f(y)


[View source]
def add(a : T) : self #

Adds constant function a


[View source]
def add_abs(a : T) : self #

Adds |x - a|


[View source]
def add_l(a : T) : self #

Adds max(a - x, 0)


[View source]
def add_r(a : T) : self #

Adds max(x - a, 0)


[View source]
def f(x : T) : T #

Calculates #f(x)


[View source]
def l0 : T? #

[View source]
def left #

[View source]
def min : T #

[View source]
def r0 : T? #

[View source]
def right #

[View source]
def shift : T #

[View source]
def slide(a : T) : self #

g(x) := f(x - a)


[View source]