pub struct SuffixArray<T> { /* private fields */ }
Implementations§
Source§impl<T: Ord> SuffixArray<T>
impl<T: Ord> SuffixArray<T>
Sourcepub fn new(pat: Vec<T>) -> Self
pub fn new(pat: Vec<T>) -> Self
Examples found in repository?
More examples
crates/library_checker/src/string/number_of_substrings.rs (line 11)
6pub fn number_of_substrings(reader: impl Read, mut writer: impl Write) {
7 let s = read_all_unchecked(reader);
8 let mut scanner = Scanner::new(&s);
9 scan!(scanner, s: Chars);
10 let mut ans = s.len() * (s.len() + 1) / 2;
11 let sa = SuffixArray::new(s);
12 let lcp = sa.longest_common_prefix_array();
13 for x in lcp {
14 ans -= x;
15 }
16 writeln!(writer, "{}", ans).ok();
17}
Sourcepub fn longest_common_prefix_array(&self) -> Vec<usize>
pub fn longest_common_prefix_array(&self) -> Vec<usize>
Examples found in repository?
crates/library_checker/src/string/number_of_substrings.rs (line 12)
6pub fn number_of_substrings(reader: impl Read, mut writer: impl Write) {
7 let s = read_all_unchecked(reader);
8 let mut scanner = Scanner::new(&s);
9 scan!(scanner, s: Chars);
10 let mut ans = s.len() * (s.len() + 1) / 2;
11 let sa = SuffixArray::new(s);
12 let lcp = sa.longest_common_prefix_array();
13 for x in lcp {
14 ans -= x;
15 }
16 writeln!(writer, "{}", ans).ok();
17}
pub fn range(&self, t: &[T], next: impl Fn(&T) -> T) -> Range<usize>
Trait Implementations§
Source§impl<T: Clone> Clone for SuffixArray<T>
impl<T: Clone> Clone for SuffixArray<T>
Source§fn clone(&self) -> SuffixArray<T>
fn clone(&self) -> SuffixArray<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for SuffixArray<T>
impl<T: Debug> Debug for SuffixArray<T>
Auto Trait Implementations§
impl<T> Freeze for SuffixArray<T>
impl<T> RefUnwindSafe for SuffixArray<T>where
T: RefUnwindSafe,
impl<T> Send for SuffixArray<T>where
T: Send,
impl<T> Sync for SuffixArray<T>where
T: Sync,
impl<T> Unpin for SuffixArray<T>where
T: Unpin,
impl<T> UnwindSafe for SuffixArray<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