pub struct RMQ<T: Ord + Display> {
pub array: Vec<T>,
pub block_min: Vec<usize>,
pub sparse: Vec<Vec<usize>>,
pub labels: Vec<usize>,
}
Expand description
Represents a Range Minimum Query (RMQ), which can efficiently return the minimal value in a given range of an array.
Fields§
§array: Vec<T>
The full array.
block_min: Vec<usize>
The absolute position (i.e. the index in array) of the minimum for each block.
sparse: Vec<Vec<usize>>
sparse[i][j]
is the position of the minimum in block[i] to block[i + 2^(j+1) - 1].
labels: Vec<usize>
The j’th bit of labels[i] is 1 iff j is the first position (in the block) left of i where array[j] < array[i].
Implementations§
Auto Trait Implementations§
impl<T> RefUnwindSafe for RMQ<T>where
T: RefUnwindSafe,
impl<T> Send for RMQ<T>where
T: Send,
impl<T> Sync for RMQ<T>where
T: Sync,
impl<T> Unpin for RMQ<T>where
T: Unpin,
impl<T> UnwindSafe for RMQ<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more