haar_lib/algebra/
add_min_count.rs

1//! Range Add Range Min-Count
2pub use crate::algebra::{action::Action, min_count::MinCount, sum::Sum, traits::*};
3use std::marker::PhantomData;
4use std::ops::Add;
5
6/// Range Add Range Min-Count用の代数的構造
7#[derive(Copy, Clone, Default, Debug, PartialEq, Eq)]
8pub struct AddMinCount<T, U>(PhantomData<(T, U)>);
9
10impl<T, U> Action for AddMinCount<T, U>
11where
12    MinCount<T, U>: Monoid,
13    Sum<T>: Monoid,
14    T: Add<Output = T>,
15{
16    type Output = MinCount<T, U>;
17    type Lazy = Sum<T>;
18
19    fn convert(value: Self::Output, lazy: Self::Lazy, _: usize) -> Self::Output {
20        MinCount(value.0.map(|x| x + lazy.0), value.1)
21    }
22}