Skip to content
Snippets Groups Projects
Commit c5465969 authored by Jan Travnicek's avatar Jan Travnicek Committed by Jan Trávníček
Browse files

shorten code

parent 315480f2
No related branches found
No related tags found
1 merge request!102Merge jt
...@@ -65,41 +65,12 @@ public: ...@@ -65,41 +65,12 @@ public:
* *
* @overload * @overload
* *
* @tparam SymbolType Type for the input symbols. * @tparam T type of tested automaton.
* @tparam StateType Type for the states. * @param fsm (nondeterministic) finite automaton (with multiple initial states)
* @param fsm nondeterministic finite automaton with multiple initial states
* @return mapping of states to set of states representing the epsilon closures for each state of @p fsm * @return mapping of states to set of states representing the epsilon closures for each state of @p fsm
*/ */
template < class SymbolType, class StateType > template < class T >
static ext::map<StateType, ext::set<StateType>> allEpsilonClosure( const automaton::MultiInitialStateNFA < SymbolType, StateType > & fsm); static ext::require < isDFA < T > || isNFA < T > || isMultiInitialStateNFA < T >, ext::map < typename T::StateType, ext::set < typename T::StateType > > > allEpsilonClosure ( const T & fsm );
/**
* Computes epsilon closure for all states of a nondeterministic finite automaton.
* Epsilon closure of a state q of an automaton without epsilon transitions is eps-closure(q) = {q}.
*
* @overload
*
* @tparam SymbolType Type for the input symbols.
* @tparam StateType Type for the states.
* @param fsm nondeterministic finite automaton
* @return mapping of states to set of states representing the epsilon closures for each state of @p fsm
*/
template < class SymbolType, class StateType >
static ext::map<StateType, ext::set<StateType>> allEpsilonClosure( const automaton::NFA < SymbolType, StateType > & fsm);
/**
* Computes epsilon closure for all states of a deterministic finite automaton.
* Epsilon closure of a state q of an automaton without epsilon transitions is eps-closure(q) = {q}.
*
* @overload
*
* @tparam SymbolType Type for the input symbols.
* @tparam StateType Type for the states.
* @param fsm deterministic finite automaton
* @return mapping of states to set of states representing the epsilon closures for each state of @p fsm
*/
template < class SymbolType, class StateType >
static ext::map<StateType, ext::set<StateType>> allEpsilonClosure( const automaton::DFA < SymbolType, StateType > & fsm);
   
/** /**
* Computes epsilon closure for all states of an extended nondeterministic finite automaton. * Computes epsilon closure for all states of an extended nondeterministic finite automaton.
...@@ -156,27 +127,11 @@ ext::map<StateType, ext::set<StateType>> AllEpsilonClosure::allEpsilonClosure( c ...@@ -156,27 +127,11 @@ ext::map<StateType, ext::set<StateType>> AllEpsilonClosure::allEpsilonClosure( c
return Qi.at(i); return Qi.at(i);
} }
   
template < class SymbolType, class StateType > template < class T >
ext::map<StateType, ext::set<StateType>> AllEpsilonClosure::allEpsilonClosure( const automaton::MultiInitialStateNFA < SymbolType, StateType > & fsm) { ext::require < isDFA < T > || isNFA < T > || isMultiInitialStateNFA < T >, ext::map < typename T::StateType, ext::set < typename T::StateType > > > AllEpsilonClosure::allEpsilonClosure ( const T & fsm ) {
ext::map<StateType, ext::set<StateType>> closure; ext::map < typename T::StateType, ext::set < typename T::StateType > > closure;
for(const StateType& state : fsm.getStates()) for ( const typename T::StateType & state : fsm.getStates ( ) )
closure[state].insert(state); closure [ state ].insert ( state );
return closure;
}
template < class SymbolType, class StateType >
ext::map<StateType, ext::set<StateType>> AllEpsilonClosure::allEpsilonClosure( const automaton::NFA < SymbolType, StateType > & fsm) {
ext::map<StateType, ext::set<StateType>> closure;
for(const StateType& state : fsm.getStates())
closure[state].insert(state);
return closure;
}
template < class SymbolType, class StateType >
ext::map<StateType, ext::set<StateType>> AllEpsilonClosure::allEpsilonClosure( const automaton::DFA < SymbolType, StateType > & fsm) {
ext::map<StateType, ext::set<StateType>> closure;
for(const StateType& state : fsm.getStates())
closure[state].insert(state);
return closure; return closure;
} }
   
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment