Processing math: 100%
ac-library-hs-1.2.0.0: Data structures and algorithms
Safe HaskellSafe-Inferred
LanguageGHC2021

AtCoder.Extra.Monoid.RangeAdd

Description

Monoid action f:xx+d.

Since: 1.0.0.0

Synopsis

RangeAdd

newtype RangeAdd a Source #

Monoid action f:xx+d.

Example (action on Sum)

Expand
>>> import AtCoder.Extra.Monoid (SegAct(..), RangeAdd(..))
>>> import AtCoder.LazySegTree qualified as LST
>>> import Data.Semigroup (Sum(..))
>>> seg <- LST.build @_ @(RangeAdd (Sum Int)) @(Sum Int) $ VU.generate 3 Sum -- [0, 1, 2]
>>> LST.applyIn seg 0 3 $ RangeAdd (Sum 5) -- [5, 6, 7]
>>> getSum <$> LST.prod seg 0 3
18

Example (action on Max)

Expand
>>> import AtCoder.Extra.Monoid (SegAct(..), RangeAdd(..))
>>> import AtCoder.LazySegTree qualified as LST
>>> import Data.Semigroup (Max(..))
>>> seg <- LST.build @_ @(RangeAdd (Max Int)) @(Max Int) $ VU.generate 3 Max -- [0, 1, 2]
>>> LST.applyIn seg 0 3 $ RangeAdd (Max 5) -- [5, 6, 7]
>>> getMax <$> LST.prod seg 0 3
7

Since: 1.0.0.0

Constructors

RangeAdd a 

Instances

Instances details
Unbox a => Vector Vector (RangeAdd a) Source #

Since: 1.0.0.0

Instance details

Defined in AtCoder.Extra.Monoid.RangeAdd

Methods

basicUnsafeFreeze :: Mutable Vector s (RangeAdd a) -> ST s (Vector (RangeAdd a))

basicUnsafeThaw :: Vector (RangeAdd a) -> ST s (Mutable Vector s (RangeAdd a))

basicLength :: Vector (RangeAdd a) -> Int

basicUnsafeSlice :: Int -> Int -> Vector (RangeAdd a) -> Vector (RangeAdd a)

basicUnsafeIndexM :: Vector (RangeAdd a) -> Int -> Box (RangeAdd a)

basicUnsafeCopy :: Mutable Vector s (RangeAdd a) -> Vector (RangeAdd a) -> ST s ()

elemseq :: Vector (RangeAdd a) -> RangeAdd a -> b -> b

Unbox a => MVector MVector (RangeAdd a) Source #

Since: 1.0.0.0

Instance details

Defined in AtCoder.Extra.Monoid.RangeAdd

(Num a, Semigroup a) => Monoid (RangeAdd a) Source #

Since: 1.2.0.0

Instance details

Defined in AtCoder.Extra.Monoid.RangeAdd

Methods

mempty :: RangeAdd a #

mappend :: RangeAdd a -> RangeAdd a -> RangeAdd a #

mconcat :: [RangeAdd a] -> RangeAdd a #

(Semigroup a, Num a) => Semigroup (RangeAdd a) Source #

Since: 1.2.0.0

Instance details

Defined in AtCoder.Extra.Monoid.RangeAdd

Methods

(<>) :: RangeAdd a -> RangeAdd a -> RangeAdd a #

sconcat :: NonEmpty (RangeAdd a) -> RangeAdd a #

stimes :: Integral b => b -> RangeAdd a -> RangeAdd a #

Show a => Show (RangeAdd a) Source #

Since: 1.0.0.0

Instance details

Defined in AtCoder.Extra.Monoid.RangeAdd

Methods

showsPrec :: Int -> RangeAdd a -> ShowS #

show :: RangeAdd a -> String #

showList :: [RangeAdd a] -> ShowS #

Eq a => Eq (RangeAdd a) Source #

Since: 1.0.0.0

Instance details

Defined in AtCoder.Extra.Monoid.RangeAdd

Methods

(==) :: RangeAdd a -> RangeAdd a -> Bool #

(/=) :: RangeAdd a -> RangeAdd a -> Bool #

Ord a => Ord (RangeAdd a) Source #

Since: 1.0.0.0

Instance details

Defined in AtCoder.Extra.Monoid.RangeAdd

Methods

compare :: RangeAdd a -> RangeAdd a -> Ordering #

(<) :: RangeAdd a -> RangeAdd a -> Bool #

(<=) :: RangeAdd a -> RangeAdd a -> Bool #

(>) :: RangeAdd a -> RangeAdd a -> Bool #

(>=) :: RangeAdd a -> RangeAdd a -> Bool #

max :: RangeAdd a -> RangeAdd a -> RangeAdd a #

min :: RangeAdd a -> RangeAdd a -> RangeAdd a #

Unbox a => Unbox (RangeAdd a) Source #

Since: 1.0.0.0

Instance details

Defined in AtCoder.Extra.Monoid.RangeAdd

(Num a, Monoid (Max a)) => SegAct (RangeAdd (Max a)) (Max a) Source #

Since: 1.1.0.0

Instance details

Defined in AtCoder.Extra.Monoid.RangeAdd

Methods

segAct :: RangeAdd (Max a) -> Max a -> Max a Source #

segActWithLength :: Int -> RangeAdd (Max a) -> Max a -> Max a Source #

(Num a, Monoid (Min a)) => SegAct (RangeAdd (Min a)) (Min a) Source #

Since: 1.1.0.0

Instance details

Defined in AtCoder.Extra.Monoid.RangeAdd

Methods

segAct :: RangeAdd (Min a) -> Min a -> Min a Source #

segActWithLength :: Int -> RangeAdd (Min a) -> Min a -> Min a Source #

Num a => SegAct (RangeAdd (Sum a)) (Sum a) Source #

Since: 1.2.0.0

Instance details

Defined in AtCoder.Extra.Monoid.RangeAdd

Methods

segAct :: RangeAdd (Sum a) -> Sum a -> Sum a Source #

segActWithLength :: Int -> RangeAdd (Sum a) -> Sum a -> Sum a Source #

newtype MVector s (RangeAdd a) Source #

Since: 1.0.0.0

Instance details

Defined in AtCoder.Extra.Monoid.RangeAdd

newtype MVector s (RangeAdd a) = MV_RangeAdd (MVector s a)
newtype Vector (RangeAdd a) Source #

Since: 1.0.0.0

Instance details

Defined in AtCoder.Extra.Monoid.RangeAdd

newtype Vector (RangeAdd a) = V_RangeAdd (Vector a)

Constructor

new :: a -> RangeAdd a Source #

Creates RangeAdd.

Since: 1.0.0.0

unRangeAdd :: RangeAdd a -> a Source #

O(1) Retrieves the internal value of RangeAdd.

Since: 1.1.0.0

Actions

act :: Semigroup a => RangeAdd a -> a -> a Source #

O(1) Applies one-length range add: f:xd+x.

Since: 1.0.0.0