SuffixAutomaton

Struct SuffixAutomaton 

Source
pub struct SuffixAutomaton {
    states: Vec<State>,
    last: usize,
}

Fields§

§states: Vec<State>§last: usize

Implementations§

Source§

impl SuffixAutomaton

Source

pub fn new() -> Self

Examples found in repository?
crates/competitive/src/string/suffix_automaton.rs (line 95)
94    fn from_iter<I: IntoIterator<Item = usize>>(iter: I) -> Self {
95        let mut sa = SuffixAutomaton::new();
96        sa.extend(iter);
97        sa
98    }
Source

pub fn state_size(&self) -> usize

Examples found in repository?
crates/competitive/src/string/suffix_automaton.rs (line 52)
50    pub fn number_of_substrings(&self) -> usize {
51        let mut total = 0;
52        for state in 1..self.state_size() {
53            let link = self.link(state);
54            total += self.length(state) - self.length(link);
55        }
56        total
57    }
Source

pub fn transitions(&self, state: usize) -> &HashMap<usize, usize>

Source

pub fn length(&self, state: usize) -> usize

Examples found in repository?
crates/competitive/src/string/suffix_automaton.rs (line 54)
50    pub fn number_of_substrings(&self) -> usize {
51        let mut total = 0;
52        for state in 1..self.state_size() {
53            let link = self.link(state);
54            total += self.length(state) - self.length(link);
55        }
56        total
57    }
Examples found in repository?
crates/competitive/src/string/suffix_automaton.rs (line 53)
50    pub fn number_of_substrings(&self) -> usize {
51        let mut total = 0;
52        for state in 1..self.state_size() {
53            let link = self.link(state);
54            total += self.length(state) - self.length(link);
55        }
56        total
57    }
Source

pub fn number_of_substrings(&self) -> usize

Examples found in repository?
crates/library_checker/src/string/number_of_substrings.rs (line 25)
20pub fn number_of_substrings_suffix_automaton(reader: impl Read, mut writer: impl Write) {
21    let s = read_all_unchecked(reader);
22    let mut scanner = Scanner::new(&s);
23    scan!(scanner, s: Bytes);
24    let sa = SuffixAutomaton::from_iter(s.iter().map(|&c| c as usize));
25    writeln!(writer, "{}", sa.number_of_substrings()).ok();
26}
Source

fn push(&mut self, c: usize)

Examples found in repository?
crates/competitive/src/string/suffix_automaton.rs (line 104)
102    fn extend<T: IntoIterator<Item = usize>>(&mut self, iter: T) {
103        for c in iter {
104            self.push(c);
105        }
106    }

Trait Implementations§

Source§

impl Debug for SuffixAutomaton

Source§

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

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

impl Default for SuffixAutomaton

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Extend<usize> for SuffixAutomaton

Source§

fn extend<T: IntoIterator<Item = usize>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl FromIterator<usize> for SuffixAutomaton

Source§

fn from_iter<I: IntoIterator<Item = usize>>(iter: I) -> Self

Creates a value from an iterator. Read more

Auto Trait Implementations§

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> 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, 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.