pub struct Dfa<S, T> { /* private fields */ }
Expand description
A deterministic finite automaton.
Implementations§
Source§impl<S: Clone + Ord, T: Clone + Ord> Dfa<S, T>
impl<S: Clone + Ord, T: Clone + Ord> Dfa<S, T>
Sourcepub fn new(initial: S) -> Dfa<S, T>
pub fn new(initial: S) -> Dfa<S, T>
Create a new deterministic finite automaton with the given initial state.
Sourcepub fn states_insert(&mut self, state: S) -> StateIndex
pub fn states_insert(&mut self, state: S) -> StateIndex
Insert the state and return the associated state index.
Source§impl<S: Ord, T: Ord> Dfa<S, T>
impl<S: Ord, T: Ord> Dfa<S, T>
Sourcepub fn states_contains(&self, state: &S) -> Option<StateIndex>
pub fn states_contains(&self, state: &S) -> Option<StateIndex>
Return the state index of the state, if it exists.
Sourcepub fn states_index(&self, state_index: StateIndex) -> &S
pub fn states_index(&self, state_index: StateIndex) -> &S
Get the state at the state index.
Sourcepub fn states_slice<'a>(
&'a self,
state_indices: impl IntoIterator<Item = StateIndex> + 'a,
) -> Box<dyn Iterator<Item = &S> + 'a>
pub fn states_slice<'a>( &'a self, state_indices: impl IntoIterator<Item = StateIndex> + 'a, ) -> Box<dyn Iterator<Item = &S> + 'a>
Convert the state indices to states.
Sourcepub fn state_indices<'a>(&'a self) -> Box<dyn Iterator<Item = StateIndex> + 'a>
pub fn state_indices<'a>(&'a self) -> Box<dyn Iterator<Item = StateIndex> + 'a>
Get all the state indices.
Source§impl<S: Clone + Ord, T: Clone + Ord> Dfa<S, T>
impl<S: Clone + Ord, T: Clone + Ord> Dfa<S, T>
Sourcepub fn transitions_insert(
&mut self,
transition: (StateIndex, Segment<T>, StateIndex),
) -> TransitionIndex
pub fn transitions_insert( &mut self, transition: (StateIndex, Segment<T>, StateIndex), ) -> TransitionIndex
Insert the transition and return the associated transition index.
Source§impl<S: Ord, T: Ord> Dfa<S, T>
impl<S: Ord, T: Ord> Dfa<S, T>
Sourcepub fn transitions_contains(
&self,
transition: (StateIndex, &T, StateIndex),
) -> Option<TransitionIndex>
pub fn transitions_contains( &self, transition: (StateIndex, &T, StateIndex), ) -> Option<TransitionIndex>
Return the transition index of the transition, if it exists.
Sourcepub fn transitions_contains_outgoing(
&self,
transition: (StateIndex, &T),
) -> Option<TransitionIndex>
pub fn transitions_contains_outgoing( &self, transition: (StateIndex, &T), ) -> Option<TransitionIndex>
Return the transition index of the transition with the outgoing data, if it exists.
Sourcepub fn transitions_index(
&self,
transition_index: TransitionIndex,
) -> (StateIndex, &Segment<T>, StateIndex)
pub fn transitions_index( &self, transition_index: TransitionIndex, ) -> (StateIndex, &Segment<T>, StateIndex)
Get the transition at the transition index.
Sourcepub fn transitions_slice<'a>(
&'a self,
transition_indices: impl IntoIterator<Item = TransitionIndex> + 'a,
) -> Box<dyn Iterator<Item = (StateIndex, &Segment<T>, StateIndex)> + 'a>
pub fn transitions_slice<'a>( &'a self, transition_indices: impl IntoIterator<Item = TransitionIndex> + 'a, ) -> Box<dyn Iterator<Item = (StateIndex, &Segment<T>, StateIndex)> + 'a>
Convert the transition indices to transitions.
Sourcepub fn transition_indices<'a>(
&'a self,
) -> Box<dyn Iterator<Item = TransitionIndex> + 'a>
pub fn transition_indices<'a>( &'a self, ) -> Box<dyn Iterator<Item = TransitionIndex> + 'a>
Get all the transition indices.
Sourcepub fn transition_indices_from<'a>(
&'a self,
state_index: StateIndex,
) -> Box<dyn Iterator<Item = TransitionIndex> + 'a>
pub fn transition_indices_from<'a>( &'a self, state_index: StateIndex, ) -> Box<dyn Iterator<Item = TransitionIndex> + 'a>
Get the transition indices originating at the state index.
Sourcepub fn initial_index(&self) -> StateIndex
pub fn initial_index(&self) -> StateIndex
Get the index of the initial state.
Sourcepub fn is_final(&self, state_index: StateIndex) -> bool
pub fn is_final(&self, state_index: StateIndex) -> bool
Check if the state at the state index is a final state.
Sourcepub fn set_final(&mut self, state_index: StateIndex)
pub fn set_final(&mut self, state_index: StateIndex)
Set the state at the state index as a final state.
Sourcepub fn final_indices<'a>(&'a self) -> Box<dyn Iterator<Item = StateIndex> + 'a>
pub fn final_indices<'a>(&'a self) -> Box<dyn Iterator<Item = StateIndex> + 'a>
Get all the state indices for final states.