From 7ad94fec212677bf35e5c8b31e8dd5256d08cae4 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Thu, 28 Mar 2019 09:28:07 +0100 Subject: [PATCH] simplify compact and epsilon NFA --- alib2data/src/automaton/FSM/CompactNFA.h | 18 +++++++++--------- alib2data/src/automaton/FSM/EpsilonNFA.h | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/alib2data/src/automaton/FSM/CompactNFA.h b/alib2data/src/automaton/FSM/CompactNFA.h index 087839b46c..13eb9521b8 100644 --- a/alib2data/src/automaton/FSM/CompactNFA.h +++ b/alib2data/src/automaton/FSM/CompactNFA.h @@ -447,11 +447,11 @@ template < class EpsilonType > CompactNFA < SymbolType, StateType >::CompactNFA ( const MultiInitialStateEpsilonNFA < SymbolType, EpsilonType, StateType > & other ) : CompactNFA ( other.getStates ( ) + ext::set < StateType > { common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ) }, other.getInputAlphabet ( ), common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) if ( transition.first.second.template is < EpsilonType > ( ) ) - transitions.insert_or_assign ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { } ), transition.second ); + transitions.insert ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { } ), transition.second ); else - transitions.insert_or_assign ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { transition.first.second.template get < SymbolType > ( ) } ), transition.second ); + transitions.insert ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { transition.first.second.template get < SymbolType > ( ) } ), transition.second ); - transitions.insert_or_assign ( ext::make_pair ( this->getInitialState ( ), ext::vector < SymbolType > { } ), other.getInitialStates ( ) ); + transitions.insert ( ext::make_pair ( this->getInitialState ( ), ext::vector < SymbolType > { } ), other.getInitialStates ( ) ); } template < class SymbolType, class StateType > @@ -459,29 +459,29 @@ template < class EpsilonType > CompactNFA < SymbolType, StateType >::CompactNFA ( const EpsilonNFA < SymbolType, EpsilonType, StateType > & other ) : CompactNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) if ( transition.first.second.template is < EpsilonType > ( ) ) - transitions.insert_or_assign ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { } ), transition.second ); + transitions.insert ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { } ), transition.second ); else - transitions.insert_or_assign ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { transition.first.second.template get < SymbolType > ( ) } ), transition.second ); + transitions.insert ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { transition.first.second.template get < SymbolType > ( ) } ), transition.second ); } template < class SymbolType, class StateType > CompactNFA < SymbolType, StateType >::CompactNFA ( const MultiInitialStateNFA < SymbolType, StateType > & other ) : CompactNFA ( other.getStates ( ) + ext::set < StateType > { common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ) }, other.getInputAlphabet ( ), common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) - transitions.insert_or_assign ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { transition.first.second } ), transition.second ); + transitions.insert ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { transition.first.second } ), transition.second ); - transitions.insert_or_assign ( ext::make_pair ( this->getInitialState ( ), ext::vector < SymbolType > { } ), other.getInitialStates ( ) ); + transitions.insert ( ext::make_pair ( this->getInitialState ( ), ext::vector < SymbolType > { } ), other.getInitialStates ( ) ); } template < class SymbolType, class StateType > CompactNFA < SymbolType, StateType >::CompactNFA ( const NFA < SymbolType, StateType > & other ) : CompactNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) - transitions.insert_or_assign ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { transition.first.second } ), transition.second ); + transitions.insert ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { transition.first.second } ), transition.second ); } template < class SymbolType, class StateType > CompactNFA < SymbolType, StateType >::CompactNFA ( const DFA < SymbolType, StateType > & other ) : CompactNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) - transitions.insert_or_assign ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { transition.first.second } ), ext::set < StateType > { transition.second } ); + transitions.insert ( ext::make_pair ( transition.first.first, ext::vector < SymbolType > { transition.first.second } ), ext::set < StateType > { transition.second } ); } template < class SymbolType, class StateType > diff --git a/alib2data/src/automaton/FSM/EpsilonNFA.h b/alib2data/src/automaton/FSM/EpsilonNFA.h index e375f3058b..8fe6191a6d 100644 --- a/alib2data/src/automaton/FSM/EpsilonNFA.h +++ b/alib2data/src/automaton/FSM/EpsilonNFA.h @@ -570,22 +570,22 @@ EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( StateType initia template<class SymbolType, class EpsilonType, class StateType > EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( const MultiInitialStateNFA < SymbolType, StateType > & other ) : EpsilonNFA ( other.getStates ( ) + ext::set < StateType > { common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ) }, other.getInputAlphabet ( ), common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) - transitions.insert_or_assign ( ext::make_pair ( transition.first.first, ext::variant < EpsilonType, SymbolType > ( transition.first.second ) ), transition.second ); + transitions.insert ( ext::make_pair ( transition.first.first, ext::variant < EpsilonType, SymbolType > ( transition.first.second ) ), transition.second ); - transitions.insert_or_assign ( ext::make_pair ( getInitialState ( ), ext::variant < EpsilonType, SymbolType >::template from < EpsilonType > ( ) ), other.getInitialStates ( ) ); + transitions.insert ( ext::make_pair ( getInitialState ( ), ext::variant < EpsilonType, SymbolType >::template from < EpsilonType > ( ) ), other.getInitialStates ( ) ); } template<class SymbolType, class EpsilonType, class StateType > EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( const NFA < SymbolType, StateType > & other ) : EpsilonNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) - transitions.insert_or_assign ( ext::make_pair ( transition.first.first, ext::variant < EpsilonType, SymbolType > ( transition.first.second ) ), transition.second ); + transitions.insert ( ext::make_pair ( transition.first.first, ext::variant < EpsilonType, SymbolType > ( transition.first.second ) ), transition.second ); } template<class SymbolType, class EpsilonType, class StateType > EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( const DFA < SymbolType, StateType > & other ) : EpsilonNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) - transitions.insert_or_assign ( ext::make_pair ( transition.first.first, ext::variant < EpsilonType, SymbolType > ( transition.first.second ) ), ext::set < StateType > { transition.second } ); + transitions.insert ( ext::make_pair ( transition.first.first, ext::variant < EpsilonType, SymbolType > ( transition.first.second ) ), ext::set < StateType > { transition.second } ); } template<class SymbolType, class EpsilonType, class StateType > -- GitLab