RangeModification: add is_no_op/is_reinitialization

This commit is contained in:
Egor Suvorov
2022-11-24 00:12:05 +02:00
parent 29b39301fe
commit 45617ceaef
2 changed files with 16 additions and 0 deletions

View File

@@ -36,6 +36,8 @@ pub trait RangeModification<Key> {
type Result: RangeQueryResult<Key>;
fn no_op() -> Self;
fn is_no_op(&self) -> bool;
fn is_reinitialization(&self) -> bool;
fn apply(&self, result: &mut Self::Result, range: &Range<Key>);
fn compose(later: &Self, earlier: &mut Self);
}

View File

@@ -76,6 +76,20 @@ where
AddAssignModification::None
}
fn is_no_op(&self) -> bool {
match self {
AddAssignModification::None => true,
_ => false,
}
}
fn is_reinitialization(&self) -> bool {
match self {
AddAssignModification::Assign(_) => true,
_ => false,
}
}
fn apply<'a>(&self, result: &'a mut SumResult<T>, range: &Range<Key>) {
use AddAssignModification::*;
match self {