Struct DisjointSparseTable

Source
pub struct DisjointSparseTable<S>
where S: SemiGroup,
{ /* private fields */ }

Implementations§

Source§

impl<S> DisjointSparseTable<S>
where S: SemiGroup,

Source

pub fn new(v: Vec<S::T>) -> Self

Examples found in repository?
crates/competitive/src/tree/euler_tour.rs (line 143)
141    pub fn gen_lca<D: LcaMonoidDispatch>(&'a self) -> LowestCommonAncestor<'a, D> {
142        D::set_depth(self.graph.tree_depth(self.root));
143        let dst = DisjointSparseTable::<LcaMonoid<D>>::new(self.vtrace.clone());
144        LowestCommonAncestor { euler: self, dst }
145    }
More examples
Hide additional examples
crates/library_checker/src/datastructure/staticrmq.rs (line 13)
9pub fn staticrmq_disjoint_sparse_table(reader: impl Read, mut writer: impl Write) {
10    let s = read_all_unchecked(reader);
11    let mut scanner = Scanner::new(&s);
12    scan!(scanner, n, q, a: [u64; n], lr: [(usize, usize)]);
13    let table = DisjointSparseTable::<MinOperation<_>>::new(a);
14    for (l, r) in lr.take(q) {
15        writeln!(writer, "{}", table.fold(l, r)).ok();
16    }
17}
Source

pub fn height(&self) -> usize

Examples found in repository?
crates/competitive/src/data_structure/disjoint_sparse_table.rs (line 71)
70    pub fn fold_close(&self, l: usize, r: usize) -> S::T {
71        debug_assert!(l < self.height());
72        debug_assert!(r < self.height());
73        debug_assert!(l <= r);
74        if let Some(x) = Self::most_significant_bit_place(l ^ r) {
75            S::operate(&self.table[x][l], &self.table[x][r])
76        } else {
77            self.table[0][l].clone()
78        }
79    }
Source

pub fn fold_close(&self, l: usize, r: usize) -> S::T

Examples found in repository?
crates/competitive/src/data_structure/disjoint_sparse_table.rs (line 83)
81    pub fn fold(&self, l: usize, r: usize) -> S::T {
82        debug_assert!(l < r);
83        self.fold_close(l, r - 1)
84    }
Source

pub fn fold(&self, l: usize, r: usize) -> S::T

Examples found in repository?
crates/competitive/src/tree/euler_tour.rs (line 165)
164    pub fn lca(&self, u: usize, v: usize) -> usize {
165        self.euler.query(u, v, |l, r| self.dst.fold(l, r))
166    }
More examples
Hide additional examples
crates/library_checker/src/datastructure/staticrmq.rs (line 15)
9pub fn staticrmq_disjoint_sparse_table(reader: impl Read, mut writer: impl Write) {
10    let s = read_all_unchecked(reader);
11    let mut scanner = Scanner::new(&s);
12    scan!(scanner, n, q, a: [u64; n], lr: [(usize, usize)]);
13    let table = DisjointSparseTable::<MinOperation<_>>::new(a);
14    for (l, r) in lr.take(q) {
15        writeln!(writer, "{}", table.fold(l, r)).ok();
16    }
17}

Trait Implementations§

Source§

impl<S> Clone for DisjointSparseTable<S>
where S: SemiGroup,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<S> Debug for DisjointSparseTable<S>
where S: SemiGroup, S::T: Debug,

Source§

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

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

impl<S> Index<usize> for DisjointSparseTable<S>
where S: SemiGroup,

Source§

type Output = <S as Magma>::T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<S> Freeze for DisjointSparseTable<S>

§

impl<S> RefUnwindSafe for DisjointSparseTable<S>
where <S as Magma>::T: RefUnwindSafe,

§

impl<S> Send for DisjointSparseTable<S>
where <S as Magma>::T: Send,

§

impl<S> Sync for DisjointSparseTable<S>
where <S as Magma>::T: Sync,

§

impl<S> Unpin for DisjointSparseTable<S>
where <S as Magma>::T: Unpin,

§

impl<S> UnwindSafe for DisjointSparseTable<S>
where <S as Magma>::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.