pub struct SuffixArray {
pub sfx: Vec<usize>,
pub rank: Vec<Vec<usize>>,
}
Expand description
Suffix array data structure, useful for a variety of string queries.
Fields§
§sfx: Vec<usize>
The suffix array itself, holding suffix indices in sorted order.
rank: Vec<Vec<usize>>
rank[i][j] = rank of the j’th suffix, considering only 2^i chars. In other words, rank[i] is a ranking of the substrings text[j..j+2^i].
Implementations§
Source§impl SuffixArray
impl SuffixArray
Sourcepub fn new(text: impl IntoIterator<Item = u8>) -> Self
pub fn new(text: impl IntoIterator<Item = u8>) -> Self
Suffix array construction in O(n log n) time.
Sourcepub fn longest_common_prefix(&self, i: usize, j: usize) -> usize
pub fn longest_common_prefix(&self, i: usize, j: usize) -> usize
Computes the length of longest common prefix of text[i..] and text[j..].
Auto Trait Implementations§
impl Freeze for SuffixArray
impl RefUnwindSafe for SuffixArray
impl Send for SuffixArray
impl Sync for SuffixArray
impl Unpin for SuffixArray
impl UnwindSafe for SuffixArray
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