diff --git a/alib2algo/src/automaton/properties/AllEpsilonClosure.h b/alib2algo/src/automaton/properties/AllEpsilonClosure.h index 30d3ad40e4737eee00c2753b986a2df18f451683..9291164fc6223b01fb32091cdf53bec7a95a4f1f 100644 --- a/alib2algo/src/automaton/properties/AllEpsilonClosure.h +++ b/alib2algo/src/automaton/properties/AllEpsilonClosure.h @@ -65,41 +65,12 @@ public: * * @overload * - * @tparam SymbolType Type for the input symbols. - * @tparam StateType Type for the states. - * @param fsm nondeterministic finite automaton with multiple initial states + * @tparam T type of tested automaton. + * @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 */ - template < class SymbolType, class StateType > - static ext::map<StateType, ext::set<StateType>> allEpsilonClosure( const automaton::MultiInitialStateNFA < SymbolType, StateType > & 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); + template < class T > + 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 an extended nondeterministic finite automaton. @@ -156,27 +127,11 @@ ext::map<StateType, ext::set<StateType>> AllEpsilonClosure::allEpsilonClosure( c return Qi.at(i); } -template < class SymbolType, class StateType > -ext::map<StateType, ext::set<StateType>> AllEpsilonClosure::allEpsilonClosure( const automaton::MultiInitialStateNFA < 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::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); +template < class T > +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 < typename T::StateType, ext::set < typename T::StateType > > closure; + for ( const typename T::StateType & state : fsm.getStates ( ) ) + closure [ state ].insert ( state ); return closure; }