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

optimize normalisation of states

parent 1fc3dc8c
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,12 @@ namespace automaton {
* This class contains methods to print XML representation of automata to the output stream.
*/
class AutomatonNormalize {
template < class StateType >
static DefaultStateType normalizeStateInternal ( typename std::enable_if < std::is_constructible < DefaultStateType, StateType >::value, StateType && >::type symbol );
template < class StateType >
static DefaultStateType normalizeStateInternal ( typename std::enable_if < ! std::is_constructible < DefaultStateType, StateType >::value, StateType && >::type symbol );
public:
template < class StateType >
static std::set < DefaultStateType > normalizeStates ( std::set < StateType > && states );
......@@ -61,10 +67,20 @@ std::vector < DefaultStateType > AutomatonNormalize::normalizeStates ( std::vect
}
 
template < class StateType >
DefaultStateType AutomatonNormalize::normalizeState ( StateType && state) {
DefaultStateType AutomatonNormalize::normalizeStateInternal ( typename std::enable_if < std::is_constructible < DefaultStateType, StateType >::value, StateType && >::type state ) {
return DefaultStateType ( std::move ( state ) );
}
template < class StateType >
DefaultStateType AutomatonNormalize::normalizeStateInternal ( typename std::enable_if < ! std::is_constructible < DefaultStateType, StateType >::value, StateType && >::type state ) {
return DefaultStateType ( alib::AnyObject < StateType > ( std::move ( state ) ) );
}
 
template < class StateType >
DefaultStateType AutomatonNormalize::normalizeState ( StateType && state) {
return AutomatonNormalize::normalizeStateInternal < StateType > ( std::move ( state ) );
}
template < class EpsilonType, class SymbolType >
std::variant < DefaultEpsilonType, DefaultSymbolType > AutomatonNormalize::normalizeSymbolEpsilon ( std::variant < EpsilonType, SymbolType > && symbol ) {
if ( symbol.template is < EpsilonType > ( ) )
......
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