Struct Dfa

Source
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>

Source

pub fn new(initial: S) -> Dfa<S, T>

Create a new deterministic finite automaton with the given initial state.

Source

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>

Source

pub fn states_contains(&self, state: &S) -> Option<StateIndex>

Return the state index of the state, if it exists.

Source

pub fn states_index(&self, state_index: StateIndex) -> &S

Get the state at the state index.

Source

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.

Source

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>

Source

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>

Source

pub fn transitions_contains( &self, transition: (StateIndex, &T, StateIndex), ) -> Option<TransitionIndex>

Return the transition index of the transition, if it exists.

Source

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.

Source

pub fn transitions_index( &self, transition_index: TransitionIndex, ) -> (StateIndex, &Segment<T>, StateIndex)

Get the transition at the transition index.

Source

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.

Source

pub fn transition_indices<'a>( &'a self, ) -> Box<dyn Iterator<Item = TransitionIndex> + 'a>

Get all the transition indices.

Source

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.

Source

pub fn initial_index(&self) -> StateIndex

Get the index of the initial state.

Source

pub fn is_final(&self, state_index: StateIndex) -> bool

Check if the state at the state index is a final state.

Source

pub fn set_final(&mut self, state_index: StateIndex)

Set the state at the state index as a final state.

Source

pub fn final_indices<'a>(&'a self) -> Box<dyn Iterator<Item = StateIndex> + 'a>

Get all the state indices for final states.

Trait Implementations§

Source§

impl<S: Clone, T: Clone> Clone for Dfa<S, T>

Source§

fn clone(&self) -> Dfa<S, T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug, T: Debug> Debug for Dfa<S, T>

Source§

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

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

impl<S: Clone + Ord, T: Clone + Ord> From<&Dfa<S, T>> for Enfa<S, T>

Source§

fn from(dfa: &Dfa<S, T>) -> Enfa<S, T>

Create a new nondeterministic finite automaton with epsilon moves from the deterministic finite automaton.

Source§

impl<S: Clone + Ord, T: Clone + Ord> From<&Dfa<S, T>> for Nfa<S, T>

Source§

fn from(dfa: &Dfa<S, T>) -> Nfa<S, T>

Create a new nondeterministic finite automaton from the deterministic finite automaton.

Source§

impl<S: Clone + Ord, T: Clone + Ord> From<&Enfa<S, T>> for Dfa<BTreeSet<S>, T>

Source§

fn from(enfa: &Enfa<S, T>) -> Dfa<Set<S>, T>

Create a new deterministic finite automaton from the nondeterministic finite automaton with epsilon moves.

Source§

impl<S: Clone + Ord, T: Clone + Ord> From<&Nfa<S, T>> for Dfa<BTreeSet<S>, T>

Source§

fn from(nfa: &Nfa<S, T>) -> Dfa<Set<S>, T>

Create a new deterministic finite automaton from the nondeterministic finite automaton.

Source§

impl<S: Ord, T: Ord> Ord for Dfa<S, T>

Source§

fn cmp(&self, other: &Dfa<S, T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<S: PartialEq, T: PartialEq> PartialEq for Dfa<S, T>

Source§

fn eq(&self, other: &Dfa<S, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: PartialOrd, T: PartialOrd> PartialOrd for Dfa<S, T>

Source§

fn partial_cmp(&self, other: &Dfa<S, T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S: Ord, T: Ord> StatesContains<S> for Dfa<S, T>

Source§

fn states_contains(&self, state: &S) -> Option<StateIndex>

Return the state index of the state, if it exists.
Source§

impl<S: Ord, T: Ord> StatesIndex<S> for Dfa<S, T>

Source§

fn states_index(&self, state_index: StateIndex) -> &S

Get the state at the state index.
Source§

impl<S: Ord, T: Ord> StatesSlice<S> for Dfa<S, T>

Source§

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.
Source§

impl<S: Clone + Ord, T: Clone + Ord> Subsume<Dfa<S, T>> for Dfa<S, T>

Source§

fn subsume(&mut self, dfa: &Dfa<S, T>)

Insert all the states and transitions of the deterministic finite automaton.

Source§

impl<S: Clone + Ord, T: Clone + Ord> Subsume<Dfa<S, T>> for Enfa<S, T>

Source§

fn subsume(&mut self, dfa: &Dfa<S, T>)

Insert all the states and transitions of the deterministic finite automaton.

Source§

impl<S: Clone + Ord, T: Clone + Ord> Subsume<Dfa<S, T>> for Nfa<S, T>

Source§

fn subsume(&mut self, dfa: &Dfa<S, T>)

Insert all the states and transitions of the deterministic finite automaton.

Source§

impl<S: Clone + Ord, T: Clone + Ord> Subsume<Enfa<S, T>> for Dfa<BTreeSet<S>, T>

Source§

fn subsume(&mut self, enfa: &Enfa<S, T>)

Insert all the states and transitions of the nondeterministic finite automaton with epsilon moves.

Source§

impl<S: Clone + Ord, T: Clone + Ord> Subsume<Nfa<S, T>> for Dfa<BTreeSet<S>, T>

Source§

fn subsume(&mut self, nfa: &Nfa<S, T>)

Insert all the states and transitions of the nondeterministic finite automaton.

Source§

impl<S: Eq, T: Eq> Eq for Dfa<S, T>

Source§

impl<S, T> StructuralPartialEq for Dfa<S, T>

Auto Trait Implementations§

§

impl<S, T> Freeze for Dfa<S, T>

§

impl<S, T> RefUnwindSafe for Dfa<S, T>

§

impl<S, T> Send for Dfa<S, T>
where S: Send, T: Send,

§

impl<S, T> Sync for Dfa<S, T>
where S: Sync, T: Sync,

§

impl<S, T> Unpin for Dfa<S, T>

§

impl<S, T> UnwindSafe for Dfa<S, T>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.