6#include <ext/algorithm>
16namespace determinize {
18template <
class SymbolType,
class StateType >
28 todo.push_back ( std::move ( initialState ) );
42 for (
auto & transition :
range )
43 dfaState.insert ( transition.second );
47 bool existed = !
res.addState ( dfaState );
49 if ( !existed ) todo.push_back ( dfaState );
52 res.addTransition ( state, input, std::move ( dfaState ) );
54 }
while ( !todo.empty ( ) );
59 if ( !
ext::excludes ( finalLabels.
begin ( ), finalLabels.
end ( ), dfaState.begin ( ), dfaState.end ( ) ) )
60 res.addFinalState ( dfaState );
65template <
class SymbolType,
class StateType >
76 todo.push_back ( std::move ( initialState ) );
90 for (
auto & transition :
range )
91 dfaState.insert ( transition.second );
95 bool existed = !
res.addState ( dfaState );
97 if ( !existed ) todo.push_back ( dfaState );
100 res.addTransition ( state, input, std::move ( dfaState ) );
102 }
while ( !todo.empty ( ) );
107 if ( !
ext::excludes ( finalLabels.
begin ( ), finalLabels.
end ( ), dfaState.begin ( ), dfaState.end ( ) ) )
108 res.addFinalState ( dfaState );
Deterministic finite automaton. Accepts regular languages.
Definition: DFA.h:71
Nondeterministic finite automaton with multiple initial states. Accepts regular languages.
Definition: MultiInitialStateNFA.h:69
const ext::set< StateType > & getInitialStates() const &
Definition: MultiInitialStateNFA.h:117
const ext::multimap< ext::pair< StateType, SymbolType >, StateType > & getTransitions() const &
Definition: MultiInitialStateNFA.h:520
const ext::set< StateType > & getFinalStates() const &
Definition: MultiInitialStateNFA.h:215
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: MultiInitialStateNFA.h:264
Nondeterministic finite automaton. Accepts regular languages.
Definition: NFA.h:66
const StateType & getInitialState() const &
Definition: NFA.h:107
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: NFA.h:234
const ext::multimap< ext::pair< StateType, SymbolType >, StateType > & getTransitions() const &
Definition: NFA.h:484
const ext::set< StateType > & getFinalStates() const &
Definition: NFA.h:185
static automaton::DFA< SymbolType, StateType > determinize(const automaton::DFA< SymbolType, StateType > &automaton)
Definition: Determinize.h:276
Class extending the deque class from the standard library. Original reason is to allow printing of th...
Definition: deque.hpp:44
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: set.hpp:99
auto end() &
Inherited behavior of end for non-const instance.
Definition: set.hpp:129
typename T::StateType StateType
Definition: ToGrammarLeftRG.h:64
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
return res
Definition: MinimizeByPartitioning.h:145
Definition: ToGrammar.h:31
auto range(Container &&cont) -> decltype(std::forward< Container >(cont).range())
Definition: range.hpp:247
bool excludes(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp)
Tests two sorted ranges wheter all elements from the second are not present in the first.
Definition: algorithm.hpp:46
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79