Struct LazySegmentTree

Source
pub struct LazySegmentTree<M: ActedMonoid> {
    pub size: usize,
    /* private fields */
}
Expand description

遅延評価セグメント木

Fields§

§size: usize

Implementations§

Source§

impl<M: ActedMonoid> LazySegmentTree<M>

Source

pub fn new(n: usize) -> Self

遅延評価セグメント木を初期化する

  • n: 配列サイズ
Source

pub fn from_vec(src: Vec<M::Val>) -> Self

配列から構築する

Source

pub fn set(&mut self, i: usize, v: M::Val)

要素を更新する

Source

pub fn get_at(&mut self, i: usize) -> M::Val

要素を取得する

Source

pub fn apply_at(&mut self, i: usize, f: M::Act)

要素へ作用させる

Source

pub fn apply<R: RangeBounds<usize> + Debug>(&mut self, range: R, val: M::Act)

区間にvalを作用させる

  • range: [left, right)
Source

pub fn get<R: RangeBounds<usize> + Debug>(&mut self, range: R) -> M::Val

区間を取得する

  • range: [left, right)
Source

pub fn all_prod(&self) -> M::Val

全区間の集約

Source

pub fn max_right<Act>(&mut self, l: usize, f: Act) -> (M::Val, usize)
where Act: Fn(M::Val) -> bool,

左端を固定した2分探索

  • 返り値: (prod([l, Val)), Val)
Source

pub fn min_left<Act>(&mut self, r: usize, f: Act) -> (M::Val, usize)
where Act: Fn(M::Val) -> bool,

右端を固定した2分探索

  • 返り値: (prod([Val, r)), Val)

Trait Implementations§

Source§

impl<M: Debug + ActedMonoid> Debug for LazySegmentTree<M>
where M::Val: Debug, M::Act: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<M: ActedMonoid> FromIterator<<M as ActedMonoid>::Val> for LazySegmentTree<M>

Source§

fn from_iter<T: IntoIterator<Item = M::Val>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<M> ShowBinaryTree<usize> for LazySegmentTree<M>
where M: ActedMonoid, M::Act: Debug, M::Val: Debug,

Source§

fn get_root(&self) -> Option<usize>

<required> 根を取得する
Source§

fn get_left(&self, i: &usize) -> Option<usize>

<required> 左の子のポインタを取得する
Source§

fn get_right(&self, i: &usize) -> Option<usize>

<required> 右の子のポインタを取得する
Source§

fn print_node(&self, i: &usize) -> String

<required> ノードの値を表示する
Source§

fn print_inner(&self, ptr: P, fill: &mut Vec<&'static str>, last: &'static str)

再帰的にprintを行う
Source§

fn print_as_binary_tree(&self)

2分木としてフォーマットする

Auto Trait Implementations§

§

impl<M> Freeze for LazySegmentTree<M>

§

impl<M> RefUnwindSafe for LazySegmentTree<M>

§

impl<M> Send for LazySegmentTree<M>
where <M as ActedMonoid>::Val: Send, <M as ActedMonoid>::Act: Send,

§

impl<M> Sync for LazySegmentTree<M>
where <M as ActedMonoid>::Val: Sync, <M as ActedMonoid>::Act: Sync,

§

impl<M> Unpin for LazySegmentTree<M>
where <M as ActedMonoid>::Val: Unpin, <M as ActedMonoid>::Act: Unpin,

§

impl<M> UnwindSafe for LazySegmentTree<M>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V