pub struct BIT<T: Monoid> {
    pub size: usize,
    /* private fields */
}
Expand description

BinaryIndexedTree

  • 0-indexedなインターフェースを持つBIT

Fields§

§size: usize

Implementations§

source§

impl<T: Monoid> BIT<T>

source

pub fn new(n: usize) -> Self

BITの初期化を行う

  • n: 列の長さ
source

pub fn add(&mut self, i: usize, x: T::Val)

一点加算を行う

  • i: 加算を行うインデックス(0-indexed
  • x: 加算する値
source

pub fn prefix_sum(&self, i: usize) -> T::Val

先頭からの和を求める

  • i: 区間[0,i)に対しての総和(0-indexed
source§

impl<T: Group> BIT<T>

source

pub fn sum<R: RangeBounds<usize>>(&self, range: R) -> T::Val

任意の区間の和を求める

  • range: 区間を表すRangeオブジェクト
source§

impl<T: OrderedMonoid> BIT<T>

source

pub fn lower_bound(&self, w: T::Val) -> usize

a_0 + a_1 + ... + a_i >= wとなる最小のiを求める

source

pub fn upper_bound(&self, w: T::Val) -> usize

a_0 + a_1 + ... + a_i > wとなる最小のiを求める

Trait Implementations§

source§

impl<T> Debug for BIT<T>where T: Group, T::Val: Debug,

source§

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

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

impl<T: Monoid> From<&Vec<<T as Monoid>::Val, Global>> for BIT<T>

source§

fn from(src: &Vec<T::Val>) -> Self

ベクターの参照からBITを作成

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for BIT<T>where <T as Monoid>::Val: RefUnwindSafe,

§

impl<T> Send for BIT<T>where <T as Monoid>::Val: Send,

§

impl<T> Sync for BIT<T>where <T as Monoid>::Val: Sync,

§

impl<T> Unpin for BIT<T>where <T as Monoid>::Val: Unpin,

§

impl<T> UnwindSafe for BIT<T>where <T as Monoid>::Val: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V