Skip to main content

DualSegmentTree2D

Struct DualSegmentTree2D 

Source
pub struct DualSegmentTree2D<T, F> { /* private fields */ }
Expand description

矩形更新・一点取得を行う2次元双対セグメント木です。

行区間 [upper, lower) と列区間 [left, right) はともに 0-indexed の半開区間です。 compose は結合的な演算で、identity はその単位元である必要があります。また、 2 次元の更新ノードを走査する順序に依存しないよう、演算は可換である必要があります。 更新・取得は O(log H log W)、メモリは O(HW) です。

Implementations§

Source§

impl<T: Copy, F: Fn(T, T) -> T> DualSegmentTree2D<T, F>

Source

pub fn new(height: usize, width: usize, compose: F, identity: T) -> Self

height × width の木を作り、すべての点の初期値を identity にします。 添字は行・列とも 0 始まりです。compose は結合的かつ可換で、identity を 単位元とする必要があります。メモリ量は O(HW) です。

Source

pub fn apply( &mut self, upper: usize, lower: usize, left: usize, right: usize, value: T, )

矩形 [upper, lower) × [left, right) の各点に value を適用します。

行・列区間は 0 始まりの半開区間です。各区間が対応する次元の範囲内でない場合や、 左端が右端を超える場合は panic します。空の行区間または列区間なら何もしません。 計算量は O(log H log W) です。

Source

pub fn get(&self, row: usize, column: usize) -> T

点 (row, column) の値を返します。行・列は 0 始まりで、範囲外なら panic します。 計算量は O(log H log W) です。

Source

pub fn at(&self, row: usize, column: usize) -> T

点 (row, column) の値を返します。行・列は 0 始まりです。

get と同じで、範囲外なら panic します。計算量は O(log H log W) です。

Trait Implementations§

Source§

impl<T: Clone, F: Clone> Clone for DualSegmentTree2D<T, F>

Source§

fn clone(&self) -> DualSegmentTree2D<T, F>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T, F> Freeze for DualSegmentTree2D<T, F>
where F: Freeze, T: Freeze,

§

impl<T, F> RefUnwindSafe for DualSegmentTree2D<T, F>

§

impl<T, F> Send for DualSegmentTree2D<T, F>
where F: Send, T: Send,

§

impl<T, F> Sync for DualSegmentTree2D<T, F>
where F: Sync, T: Sync,

§

impl<T, F> Unpin for DualSegmentTree2D<T, F>
where F: Unpin, T: Unpin,

§

impl<T, F> UnsafeUnpin for DualSegmentTree2D<T, F>
where F: UnsafeUnpin, T: UnsafeUnpin,

§

impl<T, F> UnwindSafe for DualSegmentTree2D<T, F>
where F: UnwindSafe, T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.