diff --git a/alib2data/src/automaton/FSM/DFA.h b/alib2data/src/automaton/FSM/DFA.h index 560df1fca6e4e02b28bfeda16b3b66ac706bfd48..7296f8b8093c01214ce0f7ff6fb81cf942f0d008 100644 --- a/alib2data/src/automaton/FSM/DFA.h +++ b/alib2data/src/automaton/FSM/DFA.h @@ -512,38 +512,36 @@ ext::map < ext::pair < StateType, SymbolType >, StateType > && DFA<SymbolType, S return std::move ( transitions ); } - template < class Type, class From > - class PartialComparator { - const Type & m_data; - std::function < const Type & ( const From & ) > retrieveFunction; +template < class Type, class From > +class PartialComparator { + const Type & m_data; + std::function < const Type & ( const From & ) > retrieveFunction; - public: - PartialComparator ( const Type & data, const Type & ( * function ) ( const From & ) ) : m_data ( data ), retrieveFunction ( function ) { - - } +public: + PartialComparator ( const Type & data, const Type & ( * function ) ( const From & ) ) : m_data ( data ), retrieveFunction ( function ) { + } - friend bool operator < ( const PartialComparator & first, const Type & second ) { - return first.m_data < first.retrieveFunction ( second ); - } + friend bool operator < ( const PartialComparator & first, const Type & second ) { + return first.m_data < first.retrieveFunction ( second ); + } - friend bool operator < ( const Type & first, const PartialComparator & second ) { - return second.retrieveFunction ( first ) < second.m_data; - } - }; + friend bool operator < ( const Type & first, const PartialComparator & second ) { + return second.retrieveFunction ( first ) < second.m_data; + } +}; template<class SymbolType, class StateType > ext::range < typename ext::map < ext::pair < StateType, SymbolType >, StateType >::const_iterator > DFA<SymbolType, StateType>::getTransitionsFromState ( const StateType & from ) const { if ( !getStates ( ).count ( from ) ) throw AutomatonException ( "State \"" + ext::to_string ( from ) + "\" doesn't exist" ); + typename ext::map < ext::pair < StateType, SymbolType >, StateType >::const_iterator lower = transitions.begin ( ); - while ( lower != transitions.end ( ) && lower->first.first < from ) { + while ( lower != transitions.end ( ) && lower->first.first < from ) ++ lower; - } - typename ext::map < ext::pair < StateType, SymbolType >, StateType >::const_iterator upper = transitions.begin ( ); - while ( upper != transitions.end ( ) && upper->first.first <= from ) { + typename ext::map < ext::pair < StateType, SymbolType >, StateType >::const_iterator upper = lower; + while ( upper != transitions.end ( ) && upper->first.first <= from ) ++ upper; - } return ext::make_range ( lower, upper ); }