pub struct State { /* private fields */ }Expand description
Stores a set of Phrases.
Implementations§
Source§impl State
impl State
Sourcepub fn remove_phrase(&mut self, phrase: &Phrase) -> bool
pub fn remove_phrase(&mut self, phrase: &Phrase) -> bool
Removes the first occurrence of phrase from the state.
Returns false if the phrase could not be found.
Sourcepub fn remove_pattern<const N: usize>(
&mut self,
pattern: [Option<Atom>; N],
match_pattern_length: bool,
)
pub fn remove_pattern<const N: usize>( &mut self, pattern: [Option<Atom>; N], match_pattern_length: bool, )
Removes any phrases matching the provided pattern.
If match_pattern_length is true, only phrases matching the exact length of the provided
pattern will be removed. Otherwise, phrases longer than the provided pattern may be removed,
if their beginning subset matches the pattern.
Sourcepub fn push(&mut self, phrase: Vec<Token>) -> PhraseId
pub fn push(&mut self, phrase: Vec<Token>) -> PhraseId
Adds a new phrase to the State and returns a PhraseId referencing the newly added phrase.
Sourcepub fn iter(&self) -> impl Iterator<Item = PhraseId> + '_
pub fn iter(&self) -> impl Iterator<Item = PhraseId> + '_
Returns an iterator of references to phrases in the State.
Sourcepub fn get_all(&self) -> Vec<Vec<Token>>
pub fn get_all(&self) -> Vec<Vec<Token>>
Constructs and returns a Vec of all phrases in the State.
Sourcepub fn iter_pattern<const N: usize>(
&self,
pattern: [Option<Atom>; N],
match_pattern_length: bool,
) -> impl Iterator<Item = PhraseId> + '_
pub fn iter_pattern<const N: usize>( &self, pattern: [Option<Atom>; N], match_pattern_length: bool, ) -> impl Iterator<Item = PhraseId> + '_
Returns an iterator of references to phrases matching the provided pattern.
If match_pattern_length is true, only phrases matching the exact length of the provided
pattern will be returned. Otherwise, phrases longer than the provided pattern may be returned,
if their beginning subset matches the pattern.