diff --git a/aaccess2/src/StringAccess.cpp b/aaccess2/src/StringAccess.cpp index 811ab707901ca7918f01134111ab911fbb4f1728..88b670a2d400954a2a2ba662555302112003ccbe 100644 --- a/aaccess2/src/StringAccess.cpp +++ b/aaccess2/src/StringAccess.cpp @@ -22,18 +22,18 @@ void StringAccess::access ( const string::String & string, const std::set < Stri dispatch ( string.getData ( ), settings ); } -void StringAccess::access ( const string::LinearString & string, const std::set < StringSettings::Settings > & settings ) { +void StringAccess::access ( const string::LinearString < > & string, const std::set < StringSettings::Settings > & settings ) { if ( settings.count ( StringSettings::Settings::ALPHABET ) ) alib::XmlDataFactory::toStdout ( string.getAlphabet ( ) ); if ( settings.count ( StringSettings::Settings::CONTENT ) ) alib::XmlDataFactory::toStdout ( string.getContent ( ) ); } -auto StringAccessFormalString = StringAccess::RegistratorWrapper < void, string::LinearString > ( StringAccess::access ); +auto StringAccessFormalString = StringAccess::RegistratorWrapper < void, string::LinearString < > > ( StringAccess::access ); -void StringAccess::access ( const string::CyclicString & string, const std::set < StringSettings::Settings > & settings ) { +void StringAccess::access ( const string::CyclicString < > & string, const std::set < StringSettings::Settings > & settings ) { if ( settings.count ( StringSettings::Settings::ALPHABET ) ) alib::XmlDataFactory::toStdout ( string.getAlphabet ( ) ); if ( settings.count ( StringSettings::Settings::CONTENT ) ) alib::XmlDataFactory::toStdout ( string.getContent ( ) ); } -auto StringAccessUnboundedString = StringAccess::RegistratorWrapper < void, string::CyclicString > ( StringAccess::access ); +auto StringAccessUnboundedString = StringAccess::RegistratorWrapper < void, string::CyclicString < > > ( StringAccess::access ); diff --git a/aaccess2/src/StringAccess.h b/aaccess2/src/StringAccess.h index ecced5ee2f91977524dcb6a735c12149562723f2..85e7998e1ad289ee3f058e986aead8594ada9c59 100644 --- a/aaccess2/src/StringAccess.h +++ b/aaccess2/src/StringAccess.h @@ -20,8 +20,8 @@ class StringAccess : public std::SingleDispatchLastStaticParam < StringAccess, v public: static void access ( const string::String & string, const std::set < StringSettings::Settings > & settings ); - static void access ( const string::LinearString & string, const std::set < StringSettings::Settings > & settings ); - static void access ( const string::CyclicString & string, const std::set < StringSettings::Settings > & settings ); + static void access ( const string::LinearString < > & string, const std::set < StringSettings::Settings > & settings ); + static void access ( const string::CyclicString < > & string, const std::set < StringSettings::Settings > & settings ); }; #endif /* STRING_ACCESS_H_ */ diff --git a/aderivation2/src/aderivation.cpp b/aderivation2/src/aderivation.cpp index e4b8010f7e31fcff06d494d2ef9b0d21120b2238..2b3aa2f478c4e3913dea3636064bb33b28e26ca0 100644 --- a/aderivation2/src/aderivation.cpp +++ b/aderivation2/src/aderivation.cpp @@ -43,7 +43,7 @@ int main(int argc, char** argv) { measurements::start("Overal", measurements::Type::OVERALL); measurements::start("Input read", measurements::Type::AUXILIARY); - string::LinearString stringData = alib::XmlDataFactory::fromTokens<string::LinearString>(sax::FromXMLParserHelper::parseInput(string)); + string::LinearString < > stringData = alib::XmlDataFactory::fromTokens<string::LinearString < >>(sax::FromXMLParserHelper::parseInput(string)); regexp::RegExp regexpData = alib::XmlDataFactory::fromTokens<regexp::RegExp>(sax::FromXMLParserHelper::parseInput(regexp)); measurements::end(); diff --git a/agenerate2/src/agenerate.cpp b/agenerate2/src/agenerate.cpp index 9cb35ea75c005af7b3b9b6add11257de48f11155..cc0243a7b8be623d4d7ea0c0ac503a42c34a7650 100644 --- a/agenerate2/src/agenerate.cpp +++ b/agenerate2/src/agenerate.cpp @@ -67,7 +67,7 @@ int main ( int argc, char * argv[] ) { measurements::end ( ); measurements::start ( "Algorithm", measurements::Type::MAIN ); - std::set < string::LinearString > res = grammar::generate::GenerateUpToLength::generate ( grammar, upto.getValue ( ) ); + std::set < string::LinearString < > > res = grammar::generate::GenerateUpToLength::generate ( grammar, upto.getValue ( ) ); measurements::end ( ); measurements::start ( "Output write", measurements::Type::AUXILIARY ); @@ -75,7 +75,7 @@ int main ( int argc, char * argv[] ) { alib::XmlDataFactory::toStdout ( res ); } else if ( type.getValue ( ) == "CYK" ) { grammar::Grammar grammar = alib::XmlDataFactory::fromTokens < grammar::Grammar > ( sax::FromXMLParserHelper::parseInput(grammarInput) ); - string::LinearString string = alib::XmlDataFactory::fromTokens < string::LinearString > ( sax::FromXMLParserHelper::parseInput(stringInput) ); + string::LinearString < > string = alib::XmlDataFactory::fromTokens < string::LinearString < > > ( sax::FromXMLParserHelper::parseInput(stringInput) ); measurements::end ( ); measurements::start ( "Algorithm", measurements::Type::MAIN ); diff --git a/aintegral2/src/aintegral.cpp b/aintegral2/src/aintegral.cpp index 4e7824901ec6770d052551f96d302134952f60fc..1a394871f51ca279579df2729ff2d18c882672b0 100644 --- a/aintegral2/src/aintegral.cpp +++ b/aintegral2/src/aintegral.cpp @@ -43,7 +43,7 @@ int main(int argc, char** argv) { measurements::start("Overal", measurements::Type::OVERALL); measurements::start("Input read", measurements::Type::AUXILIARY); - string::LinearString stringData = alib::XmlDataFactory::fromTokens<string::LinearString>(sax::FromXMLParserHelper::parseInput(string)); + string::LinearString < > stringData = alib::XmlDataFactory::fromTokens<string::LinearString < >>(sax::FromXMLParserHelper::parseInput(string)); regexp::RegExp regexpData = alib::XmlDataFactory::fromTokens<regexp::RegExp>(sax::FromXMLParserHelper::parseInput(regexp)); measurements::end(); diff --git a/alib2algo/src/automaton/run/Accept.cpp b/alib2algo/src/automaton/run/Accept.cpp index f8b7772d65982c779f7041ace2744b5c1493690e..6711981fd5924fea43df8972f6be545df7c0cd7b 100644 --- a/alib2algo/src/automaton/run/Accept.cpp +++ b/alib2algo/src/automaton/run/Accept.cpp @@ -29,7 +29,7 @@ bool Accept::accept ( const automaton::Automaton & automaton, const alib::Object return dispatch ( automaton.getData ( ), object.getData ( ) ); } -bool Accept::accept ( const automaton::Automaton & automaton, const string::LinearString & string ) { +bool Accept::accept ( const automaton::Automaton & automaton, const string::LinearString < > & string ) { return dispatch ( automaton.getData ( ), string ); } @@ -37,15 +37,15 @@ bool Accept::accept ( const automaton::Automaton & automaton, const tree::Ranked return dispatch ( automaton.getData ( ), tree ); } -bool Accept::accept ( const automaton::DFA<> & automaton, const string::LinearString & string ) { +bool Accept::accept ( const automaton::DFA<> & automaton, const string::LinearString < > & string ) { std::tuple < bool, label::Label, std::set < unsigned > > res = Run::calculateState ( automaton, string ); return std::get < 0 > ( res ) && automaton.getFinalStates ( ).count ( std::get < 1 > ( res ) ); } -auto AcceptDFALinearString = Accept::RegistratorWrapper < bool, automaton::DFA<>, string::LinearString > ( Accept::accept ); +auto AcceptDFALinearString = Accept::RegistratorWrapper < bool, automaton::DFA<>, string::LinearString < > > ( Accept::accept ); -bool Accept::accept ( const automaton::NFA < > & automaton, const string::LinearString & string ) { +bool Accept::accept ( const automaton::NFA < > & automaton, const string::LinearString < > & string ) { std::tuple < bool, std::set < label::Label >, std::set < unsigned > > res = Run::calculateStates ( automaton, string ); return std::get < 0 > ( res ) && std::any_of ( std::get < 1 > ( res ).begin ( ), std::get < 1 > ( res ).end ( ), [&] ( const label::Label & state ) { @@ -53,7 +53,7 @@ bool Accept::accept ( const automaton::NFA < > & automaton, const string::Linear } ); } -auto AcceptNFALinearString = Accept::RegistratorWrapper < bool, automaton::NFA < > , string::LinearString > ( Accept::accept ); +auto AcceptNFALinearString = Accept::RegistratorWrapper < bool, automaton::NFA < > , string::LinearString < > > ( Accept::accept ); bool Accept::accept ( const automaton::DFTA & automaton, const tree::RankedTree & tree ) { std::tuple < bool, label::Label, std::set < unsigned > > res = Run::calculateState ( automaton, tree ); @@ -73,44 +73,44 @@ bool Accept::accept ( const automaton::NFTA & automaton, const tree::RankedTree auto AcceptNFTARankedTree = Accept::RegistratorWrapper < bool, automaton::NFTA, tree::RankedTree > ( Accept::accept ); -bool Accept::accept ( const automaton::InputDrivenDPDA & automaton, const string::LinearString & string ) { +bool Accept::accept ( const automaton::InputDrivenDPDA & automaton, const string::LinearString < > & string ) { std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > res = Run::calculateState ( automaton, string ); return std::get < 0 > ( res ) && ( automaton.getFinalStates ( ).count ( std::get < 1 > ( res ) ) || ( automaton.getFinalStates ( ).size ( ) == 0 && std::get < 3 > ( res ).size ( ) == 0 ) ); } -auto AcceptInputDrivenDPDALinearString = Accept::RegistratorWrapper < bool, automaton::InputDrivenDPDA, string::LinearString > ( Accept::accept ); +auto AcceptInputDrivenDPDALinearString = Accept::RegistratorWrapper < bool, automaton::InputDrivenDPDA, string::LinearString < > > ( Accept::accept ); -bool Accept::accept ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString & string ) { +bool Accept::accept ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString < > & string ) { std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > res = Run::calculateState ( automaton, string ); return std::get < 0 > ( res ) && automaton.getFinalStates ( ).count ( std::get < 1 > ( res ) ); } -auto AcceptVisiblyPushdownDPDALinearString = Accept::RegistratorWrapper < bool, automaton::VisiblyPushdownDPDA, string::LinearString > ( Accept::accept ); +auto AcceptVisiblyPushdownDPDALinearString = Accept::RegistratorWrapper < bool, automaton::VisiblyPushdownDPDA, string::LinearString < > > ( Accept::accept ); -bool Accept::accept ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString & string ) { +bool Accept::accept ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString < > & string ) { std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > res = Run::calculateState ( automaton, string ); return std::get < 0 > ( res ) && automaton.getFinalStates ( ).count ( std::get < 1 > ( res ) ); } -auto AcceptRealTimeHeightDeterministicDPDALinearString = Accept::RegistratorWrapper < bool, automaton::RealTimeHeightDeterministicDPDA, string::LinearString > ( Accept::accept ); +auto AcceptRealTimeHeightDeterministicDPDALinearString = Accept::RegistratorWrapper < bool, automaton::RealTimeHeightDeterministicDPDA, string::LinearString < > > ( Accept::accept ); -bool Accept::accept ( const automaton::DPDA & automaton, const string::LinearString & string ) { +bool Accept::accept ( const automaton::DPDA & automaton, const string::LinearString < > & string ) { std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > res = Run::calculateState ( automaton, string ); return std::get < 0 > ( res ) && ( automaton.getFinalStates ( ).count ( std::get < 1 > ( res ) ) || ( automaton.getFinalStates ( ).size ( ) == 0 && std::get < 3 > ( res ).size ( ) == 0 ) ); } -auto AcceptDPDALinearString = Accept::RegistratorWrapper < bool, automaton::DPDA, string::LinearString > ( Accept::accept ); +auto AcceptDPDALinearString = Accept::RegistratorWrapper < bool, automaton::DPDA, string::LinearString < > > ( Accept::accept ); -bool Accept::accept ( const automaton::NPDTA & automaton, const string::LinearString & string ) { +bool Accept::accept ( const automaton::NPDTA & automaton, const string::LinearString < > & string ) { std::tuple < bool, std::set < label::Label >, std::set < std::vector < alphabet::Symbol > > > res = Run::calculateStates ( automaton, string ); return std::get<0>(res); } -auto AcceptNPDTALinearString = Accept::RegistratorWrapper < bool, automaton::NPDTA, string::LinearString > ( Accept::accept ); +auto AcceptNPDTALinearString = Accept::RegistratorWrapper < bool, automaton::NPDTA, string::LinearString < > > ( Accept::accept ); } /* namespace run */ diff --git a/alib2algo/src/automaton/run/Accept.h b/alib2algo/src/automaton/run/Accept.h index 102239ab20831714836d086f4486272ad401fc43..b12fb9c0f77062d911c18f37f66a8f6debcffff5 100644 --- a/alib2algo/src/automaton/run/Accept.h +++ b/alib2algo/src/automaton/run/Accept.h @@ -26,18 +26,18 @@ public: * @return left regular grammar equivalent to source automaton. */ static bool accept ( const automaton::Automaton & automaton, const alib::Object & object ); - static bool accept ( const automaton::Automaton & automaton, const string::LinearString & string ); + static bool accept ( const automaton::Automaton & automaton, const string::LinearString < > & string ); static bool accept ( const automaton::Automaton & automaton, const tree::RankedTree & string ); - static bool accept ( const automaton::DFA<> & automaton, const string::LinearString & string ); - static bool accept ( const automaton::NFA < > & automaton, const string::LinearString & string ); + static bool accept ( const automaton::DFA<> & automaton, const string::LinearString < > & string ); + static bool accept ( const automaton::NFA < > & automaton, const string::LinearString < > & string ); static bool accept ( const automaton::DFTA & automaton, const tree::RankedTree & tree ); static bool accept ( const automaton::NFTA & automaton, const tree::RankedTree & tree ); - static bool accept ( const automaton::InputDrivenDPDA & automaton, const string::LinearString & string ); - static bool accept ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString & string ); - static bool accept ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString & string ); - static bool accept ( const automaton::DPDA & automaton, const string::LinearString & string ); - static bool accept ( const automaton::NPDTA & automaton, const string::LinearString & string ); + static bool accept ( const automaton::InputDrivenDPDA & automaton, const string::LinearString < > & string ); + static bool accept ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString < > & string ); + static bool accept ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString < > & string ); + static bool accept ( const automaton::DPDA & automaton, const string::LinearString < > & string ); + static bool accept ( const automaton::NPDTA & automaton, const string::LinearString < > & string ); }; diff --git a/alib2algo/src/automaton/run/Occurrences.cpp b/alib2algo/src/automaton/run/Occurrences.cpp index 311a7b55e5d2c521c5b7e0f32376c42cd272cde3..bed11e74dcc8eb7fdcc68bf936aa4cab929b7b6c 100644 --- a/alib2algo/src/automaton/run/Occurrences.cpp +++ b/alib2algo/src/automaton/run/Occurrences.cpp @@ -25,7 +25,7 @@ std::set < unsigned > Occurrences::occurrences ( const automaton::Automaton & au return dispatch ( automaton.getData ( ), object.getData ( ) ); } -std::set < unsigned > Occurrences::occurrences ( const automaton::Automaton & automaton, const string::LinearString & string ) { +std::set < unsigned > Occurrences::occurrences ( const automaton::Automaton & automaton, const string::LinearString < > & string ) { return dispatch ( automaton.getData ( ), string ); } @@ -33,13 +33,13 @@ std::set < unsigned > Occurrences::occurrences ( const automaton::Automaton & au return dispatch ( automaton.getData ( ), tree ); } -std::set < unsigned > Occurrences::occurrences ( const automaton::DFA < > & automaton, const string::LinearString & string ) { +std::set < unsigned > Occurrences::occurrences ( const automaton::DFA < > & automaton, const string::LinearString < > & string ) { std::tuple < bool, label::Label, std::set < unsigned > > res = Run::calculateState ( automaton, string ); return std::get < 2 > ( res ); } -auto OccurrencesDFALinearString = Occurrences::RegistratorWrapper < std::set < unsigned >, automaton::DFA<>, string::LinearString > ( Occurrences::occurrences ); +auto OccurrencesDFALinearString = Occurrences::RegistratorWrapper < std::set < unsigned >, automaton::DFA<>, string::LinearString < > > ( Occurrences::occurrences ); std::set < unsigned > Occurrences::occurrences ( const automaton::DFTA & automaton, const tree::RankedTree & tree ) { std::tuple < bool, label::Label, std::set < unsigned > > res = Run::calculateState ( automaton, tree ); @@ -49,37 +49,37 @@ std::set < unsigned > Occurrences::occurrences ( const automaton::DFTA & automat auto OccurrencesDFTARankedTree = Occurrences::RegistratorWrapper < std::set < unsigned >, automaton::DFTA, tree::RankedTree > ( Occurrences::occurrences ); -std::set < unsigned > Occurrences::occurrences ( const automaton::InputDrivenDPDA & automaton, const string::LinearString & string ) { +std::set < unsigned > Occurrences::occurrences ( const automaton::InputDrivenDPDA & automaton, const string::LinearString < > & string ) { std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > res = Run::calculateState ( automaton, string ); return std::get < 2 > ( res ); } -auto OccurrencesInputDrivenDPDALinearString = Occurrences::RegistratorWrapper < std::set < unsigned >, automaton::InputDrivenDPDA, string::LinearString > ( Occurrences::occurrences ); +auto OccurrencesInputDrivenDPDALinearString = Occurrences::RegistratorWrapper < std::set < unsigned >, automaton::InputDrivenDPDA, string::LinearString < > > ( Occurrences::occurrences ); -std::set < unsigned > Occurrences::occurrences ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString & string ) { +std::set < unsigned > Occurrences::occurrences ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString < > & string ) { std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > res = Run::calculateState ( automaton, string ); return std::get < 2 > ( res ); } -auto OccurrencesVisiblyPushdownDPDALinearString = Occurrences::RegistratorWrapper < std::set < unsigned >, automaton::VisiblyPushdownDPDA, string::LinearString > ( Occurrences::occurrences ); +auto OccurrencesVisiblyPushdownDPDALinearString = Occurrences::RegistratorWrapper < std::set < unsigned >, automaton::VisiblyPushdownDPDA, string::LinearString < > > ( Occurrences::occurrences ); -std::set < unsigned > Occurrences::occurrences ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString & string ) { +std::set < unsigned > Occurrences::occurrences ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString < > & string ) { std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > res = Run::calculateState ( automaton, string ); return std::get < 2 > ( res ); } -auto OccurrencesRealTimeHeightDeterministicDPDALinearString = Occurrences::RegistratorWrapper < std::set < unsigned >, automaton::RealTimeHeightDeterministicDPDA, string::LinearString > ( Occurrences::occurrences ); +auto OccurrencesRealTimeHeightDeterministicDPDALinearString = Occurrences::RegistratorWrapper < std::set < unsigned >, automaton::RealTimeHeightDeterministicDPDA, string::LinearString < > > ( Occurrences::occurrences ); -std::set < unsigned > Occurrences::occurrences ( const automaton::DPDA & automaton, const string::LinearString & string ) { +std::set < unsigned > Occurrences::occurrences ( const automaton::DPDA & automaton, const string::LinearString < > & string ) { std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > res = Run::calculateState ( automaton, string ); return std::get < 2 > ( res ); } -auto OccurrencesDPDALinearString = Occurrences::RegistratorWrapper < std::set < unsigned >, automaton::DPDA, string::LinearString > ( Occurrences::occurrences ); +auto OccurrencesDPDALinearString = Occurrences::RegistratorWrapper < std::set < unsigned >, automaton::DPDA, string::LinearString < > > ( Occurrences::occurrences ); } /* namespace run */ diff --git a/alib2algo/src/automaton/run/Occurrences.h b/alib2algo/src/automaton/run/Occurrences.h index c89fcad4c3e2a42e129dc03b41b83c3304568af0..61d458a9d35f052eef12c80776d97bfd9a66fc2c 100644 --- a/alib2algo/src/automaton/run/Occurrences.h +++ b/alib2algo/src/automaton/run/Occurrences.h @@ -26,15 +26,15 @@ public: * @return left regular grammar equivalent to source automaton. */ static std::set < unsigned > occurrences ( const automaton::Automaton & automaton, const alib::Object & object ); - static std::set < unsigned > occurrences ( const automaton::Automaton & automaton, const string::LinearString & string ); + static std::set < unsigned > occurrences ( const automaton::Automaton & automaton, const string::LinearString < > & string ); static std::set < unsigned > occurrences ( const automaton::Automaton & automaton, const tree::RankedTree & string ); - static std::set < unsigned > occurrences ( const automaton::DFA<> & automaton, const string::LinearString & string ); + static std::set < unsigned > occurrences ( const automaton::DFA<> & automaton, const string::LinearString < > & string ); static std::set < unsigned > occurrences ( const automaton::DFTA & automaton, const tree::RankedTree & tree ); - static std::set < unsigned > occurrences ( const automaton::InputDrivenDPDA & automaton, const string::LinearString & string ); - static std::set < unsigned > occurrences ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString & string ); - static std::set < unsigned > occurrences ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString & string ); - static std::set < unsigned > occurrences ( const automaton::DPDA & automaton, const string::LinearString & string ); + static std::set < unsigned > occurrences ( const automaton::InputDrivenDPDA & automaton, const string::LinearString < > & string ); + static std::set < unsigned > occurrences ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString < > & string ); + static std::set < unsigned > occurrences ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString < > & string ); + static std::set < unsigned > occurrences ( const automaton::DPDA & automaton, const string::LinearString < > & string ); }; diff --git a/alib2algo/src/automaton/run/Result.cpp b/alib2algo/src/automaton/run/Result.cpp index bca3759288d6af7f5d99e18e68a2973471d99eb3..8a37ce6b4eb527f9770e97ef36563d59adf53f55 100644 --- a/alib2algo/src/automaton/run/Result.cpp +++ b/alib2algo/src/automaton/run/Result.cpp @@ -25,7 +25,7 @@ label::Label Result::result ( const automaton::Automaton & automaton, const alib return dispatch ( automaton.getData ( ), object.getData ( ), failLabel ); } -label::Label Result::result ( const automaton::DFA < > & automaton, const string::LinearString & string, const label::Label & failLabel ) { +label::Label Result::result ( const automaton::DFA < > & automaton, const string::LinearString < > & string, const label::Label & failLabel ) { std::tuple < bool, label::Label, std::set < unsigned > > res = Run::calculateState ( automaton, string ); if ( std::get < 0 > ( res ) ) return std::get < 1 > ( res ); @@ -33,7 +33,7 @@ label::Label Result::result ( const automaton::DFA < > & automaton, const string return failLabel; } -auto ResultDFALinearString = Result::RegistratorWrapper < label::Label, automaton::DFA<>, string::LinearString > ( Result::result ); +auto ResultDFALinearString = Result::RegistratorWrapper < label::Label, automaton::DFA<>, string::LinearString < > > ( Result::result ); label::Label Result::result ( const automaton::DFTA & automaton, const tree::RankedTree & tree, const label::Label & failLabel ) { std::tuple < bool, label::Label, std::set < unsigned > > res = Run::calculateState ( automaton, tree ); @@ -45,7 +45,7 @@ label::Label Result::result ( const automaton::DFTA & automaton, const tree::Ran auto ResultDFTARankedTree = Result::RegistratorWrapper < label::Label, automaton::DFTA, tree::RankedTree > ( Result::result ); -label::Label Result::result ( const automaton::InputDrivenDPDA & automaton, const string::LinearString & string, const label::Label & failLabel ) { +label::Label Result::result ( const automaton::InputDrivenDPDA & automaton, const string::LinearString < > & string, const label::Label & failLabel ) { std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > res = Run::calculateState ( automaton, string ); if ( std::get < 0 > ( res ) ) return std::get < 1 > ( res ); @@ -53,9 +53,9 @@ label::Label Result::result ( const automaton::InputDrivenDPDA & automaton, cons return failLabel; } -auto ResultInputDrivenDPDALinearString = Result::RegistratorWrapper < label::Label, automaton::InputDrivenDPDA, string::LinearString > ( Result::result ); +auto ResultInputDrivenDPDALinearString = Result::RegistratorWrapper < label::Label, automaton::InputDrivenDPDA, string::LinearString < > > ( Result::result ); -label::Label Result::result ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString & string, const label::Label & failLabel ) { +label::Label Result::result ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString < > & string, const label::Label & failLabel ) { std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > res = Run::calculateState ( automaton, string ); if ( std::get < 0 > ( res ) ) return std::get < 1 > ( res ); @@ -63,9 +63,9 @@ label::Label Result::result ( const automaton::VisiblyPushdownDPDA & automaton, return failLabel; } -auto ResultVisiblyPushdownDPDALinearString = Result::RegistratorWrapper < label::Label, automaton::VisiblyPushdownDPDA, string::LinearString > ( Result::result ); +auto ResultVisiblyPushdownDPDALinearString = Result::RegistratorWrapper < label::Label, automaton::VisiblyPushdownDPDA, string::LinearString < > > ( Result::result ); -label::Label Result::result ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString & string, const label::Label & failLabel ) { +label::Label Result::result ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString < > & string, const label::Label & failLabel ) { std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > res = Run::calculateState ( automaton, string ); if ( std::get < 0 > ( res ) ) return std::get < 1 > ( res ); @@ -73,9 +73,9 @@ label::Label Result::result ( const automaton::RealTimeHeightDeterministicDPDA & return failLabel; } -auto ResultRealTimeHeightDeterministicDPDALinearString = Result::RegistratorWrapper < label::Label, automaton::RealTimeHeightDeterministicDPDA, string::LinearString > ( Result::result ); +auto ResultRealTimeHeightDeterministicDPDALinearString = Result::RegistratorWrapper < label::Label, automaton::RealTimeHeightDeterministicDPDA, string::LinearString < > > ( Result::result ); -label::Label Result::result ( const automaton::DPDA & automaton, const string::LinearString & string, const label::Label & failLabel ) { +label::Label Result::result ( const automaton::DPDA & automaton, const string::LinearString < > & string, const label::Label & failLabel ) { std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > res = Run::calculateState ( automaton, string ); if ( std::get < 0 > ( res ) ) return std::get < 1 > ( res ); @@ -83,7 +83,7 @@ label::Label Result::result ( const automaton::DPDA & automaton, const string::L return failLabel; } -auto ResultDPDALinearString = Result::RegistratorWrapper < label::Label, automaton::DPDA, string::LinearString > ( Result::result ); +auto ResultDPDALinearString = Result::RegistratorWrapper < label::Label, automaton::DPDA, string::LinearString < > > ( Result::result ); } /* namespace run */ diff --git a/alib2algo/src/automaton/run/Result.h b/alib2algo/src/automaton/run/Result.h index b8b7f765eec1e23504c03b0e492ca29b7dd17d48..93154c9c99b77851607e13f4eea8d15c7fab8bdd 100644 --- a/alib2algo/src/automaton/run/Result.h +++ b/alib2algo/src/automaton/run/Result.h @@ -29,12 +29,12 @@ public: */ static label::Label result ( const automaton::Automaton & automaton, const alib::Object & object, const label::Label & failLabel = label::FailStateLabel::FAIL_STATE_LABEL ); - static label::Label result ( const automaton::DFA < > & automaton, const string::LinearString & string, const label::Label & failLabel = label::FailStateLabel::FAIL_STATE_LABEL ); + static label::Label result ( const automaton::DFA < > & automaton, const string::LinearString < > & string, const label::Label & failLabel = label::FailStateLabel::FAIL_STATE_LABEL ); static label::Label result ( const automaton::DFTA & automaton, const tree::RankedTree & tree, const label::Label & failLabel = label::FailStateLabel::FAIL_STATE_LABEL ); - static label::Label result ( const automaton::InputDrivenDPDA & automaton, const string::LinearString & string, const label::Label & failLabel = label::FailStateLabel::FAIL_STATE_LABEL ); - static label::Label result ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString & string, const label::Label & failLabel = label::FailStateLabel::FAIL_STATE_LABEL ); - static label::Label result ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString & string, const label::Label & failLabel = label::FailStateLabel::FAIL_STATE_LABEL ); - static label::Label result ( const automaton::DPDA & automaton, const string::LinearString & string, const label::Label & failLabel = label::FailStateLabel::FAIL_STATE_LABEL ); + static label::Label result ( const automaton::InputDrivenDPDA & automaton, const string::LinearString < > & string, const label::Label & failLabel = label::FailStateLabel::FAIL_STATE_LABEL ); + static label::Label result ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString < > & string, const label::Label & failLabel = label::FailStateLabel::FAIL_STATE_LABEL ); + static label::Label result ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString < > & string, const label::Label & failLabel = label::FailStateLabel::FAIL_STATE_LABEL ); + static label::Label result ( const automaton::DPDA & automaton, const string::LinearString < > & string, const label::Label & failLabel = label::FailStateLabel::FAIL_STATE_LABEL ); }; diff --git a/alib2algo/src/automaton/run/Run.cpp b/alib2algo/src/automaton/run/Run.cpp index e2a7f5fafdd0c6322f70d1d82dfa44add57c3d95..e429191c1eb573539fdfb727155d19d2f4bac60f 100644 --- a/alib2algo/src/automaton/run/Run.cpp +++ b/alib2algo/src/automaton/run/Run.cpp @@ -29,7 +29,7 @@ namespace run { // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -std::tuple < bool, label::Label, std::set < unsigned > > Run::calculateState ( const automaton::DFA < > & automaton, const string::LinearString & string ) { +std::tuple < bool, label::Label, std::set < unsigned > > Run::calculateState ( const automaton::DFA < > & automaton, const string::LinearString < > & string ) { bool res = true; unsigned i = 0; std::set < unsigned > occurrences; @@ -64,7 +64,7 @@ std::tuple < bool, label::Label, std::set < unsigned > > Run::calculateState ( c // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -std::tuple < bool, std::set < label::Label >, std::set < unsigned > > Run::calculateStates ( const automaton::NFA < > & automaton, const string::LinearString & string ) { +std::tuple < bool, std::set < label::Label >, std::set < unsigned > > Run::calculateStates ( const automaton::NFA < > & automaton, const string::LinearString < > & string ) { bool res = true; unsigned i = 0; std::set < unsigned > occurrences; @@ -217,7 +217,7 @@ bool Run::canPop ( const std::deque < alphabet::Symbol > & pushdownStore, const // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > Run::calculateState ( const automaton::InputDrivenDPDA & automaton, const string::LinearString & string ) { +std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > Run::calculateState ( const automaton::InputDrivenDPDA & automaton, const string::LinearString < > & string ) { label::Label state = automaton.getInitialState ( ); std::deque < alphabet::Symbol > pushdownStore { automaton.getInitialSymbol ( ) @@ -266,7 +266,7 @@ std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::S // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > Run::calculateState ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString & string ) { +std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > Run::calculateState ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString < > & string ) { label::Label state = automaton.getInitialState ( ); std::deque < alphabet::Symbol > pushdownStore { automaton.getBottomOfTheStackSymbol ( ) @@ -331,7 +331,7 @@ std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::S // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > Run::calculateState ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString & string ) { +std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > Run::calculateState ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString < > & string ) { label::Label state = automaton.getInitialState ( ); std::deque < alphabet::Symbol > pushdownStore { automaton.getBottomOfTheStackSymbol ( ) @@ -413,7 +413,7 @@ std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::S // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > Run::calculateState ( const automaton::DPDA & automaton, const string::LinearString & string ) { +std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > Run::calculateState ( const automaton::DPDA & automaton, const string::LinearString < > & string ) { label::Label state = automaton.getInitialState ( ); std::deque < alphabet::Symbol > pushdownStore { automaton.getInitialSymbol ( ) @@ -479,7 +479,7 @@ struct graphStructuredStack { alphabet::Symbol data; }; -std::tuple < bool, std::set < label::Label >, std::set < std::vector < alphabet::Symbol > > > Run::calculateStates ( const automaton::NPDTA & automaton, const string::LinearString & string ) { +std::tuple < bool, std::set < label::Label >, std::set < std::vector < alphabet::Symbol > > > Run::calculateStates ( const automaton::NPDTA & automaton, const string::LinearString < > & string ) { bool res = false; unsigned i = 0; std::set < unsigned > occurrences; diff --git a/alib2algo/src/automaton/run/Run.h b/alib2algo/src/automaton/run/Run.h index 61df7941aa2c625218a3ee4a9ddf160c832a0432..a9e196fd5903708b1424273bfd32b644db5ed170 100644 --- a/alib2algo/src/automaton/run/Run.h +++ b/alib2algo/src/automaton/run/Run.h @@ -25,15 +25,15 @@ class Run { static bool canPop ( const std::deque < alphabet::Symbol > & pushdownStore, const std::vector < alphabet::Symbol > & pop ); public: - static std::tuple < bool, label::Label, std::set < unsigned > > calculateState ( const automaton::DFA < > & automaton, const string::LinearString & string ); - static std::tuple < bool, std::set < label::Label >, std::set < unsigned > > calculateStates ( const automaton::NFA < > & automaton, const string::LinearString & string ); + static std::tuple < bool, label::Label, std::set < unsigned > > calculateState ( const automaton::DFA < > & automaton, const string::LinearString < > & string ); + static std::tuple < bool, std::set < label::Label >, std::set < unsigned > > calculateStates ( const automaton::NFA < > & automaton, const string::LinearString < > & string ); static std::tuple < bool, label::Label, std::set < unsigned > > calculateState ( const automaton::DFTA & automaton, const tree::RankedTree & tree ); static std::tuple < bool, std::set < label::Label >, std::set < unsigned > > calculateStates ( const automaton::NFTA & automaton, const tree::RankedTree & tree ); - static std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > calculateState ( const automaton::InputDrivenDPDA & automaton, const string::LinearString & string ); - static std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > calculateState ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString & string ); - static std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > calculateState ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString & string ); - static std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > calculateState ( const automaton::DPDA & automaton, const string::LinearString & string ); - static std::tuple < bool, std::set < label::Label >, std::set < std::vector < alphabet::Symbol > > > calculateStates ( const automaton::NPDTA & automaton, const string::LinearString & string ); + static std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > calculateState ( const automaton::InputDrivenDPDA & automaton, const string::LinearString < > & string ); + static std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > calculateState ( const automaton::VisiblyPushdownDPDA & automaton, const string::LinearString < > & string ); + static std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > calculateState ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const string::LinearString < > & string ); + static std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::Symbol > > calculateState ( const automaton::DPDA & automaton, const string::LinearString < > & string ); + static std::tuple < bool, std::set < label::Label >, std::set < std::vector < alphabet::Symbol > > > calculateStates ( const automaton::NPDTA & automaton, const string::LinearString < > & string ); }; } /* namespace run */ diff --git a/alib2algo/src/automaton/run/Translate.cpp b/alib2algo/src/automaton/run/Translate.cpp index 4cb73977fb0fc5d4e841a41d4a9a521efc25545c..285f05f9ee192519c1f131ef4bbe831a23e91236 100644 --- a/alib2algo/src/automaton/run/Translate.cpp +++ b/alib2algo/src/automaton/run/Translate.cpp @@ -16,25 +16,25 @@ namespace automaton { namespace run { -std::set < string::LinearString > Translate::translate ( const automaton::Automaton & automaton, const alib::Object & object ) { +std::set < string::LinearString < > > Translate::translate ( const automaton::Automaton & automaton, const alib::Object & object ) { return dispatch ( automaton.getData ( ), object.getData ( ) ); } -std::set < string::LinearString > Translate::translate ( const automaton::Automaton & automaton, const string::LinearString & string ) { +std::set < string::LinearString < > > Translate::translate ( const automaton::Automaton & automaton, const string::LinearString < > & string ) { return dispatch ( automaton.getData ( ), string ); } -std::set < string::LinearString > Translate::translate ( const automaton::NPDTA & automaton, const string::LinearString & string ) { +std::set < string::LinearString < > > Translate::translate ( const automaton::NPDTA & automaton, const string::LinearString < > & string ) { std::tuple < bool, std::set < label::Label >, std::set < std::vector < alphabet::Symbol > > > res = Run::calculateStates ( automaton, string ); - std::set < string::LinearString > strings; + std::set < string::LinearString < > > strings; for ( auto iter = std::get<2>(res).begin(); iter != std::get<2>(res).end(); iter ++ ) { - string::LinearString str (* iter); + string::LinearString < > str (* iter); strings . insert ( str ); } return strings; } -auto TranslateNPDTALinearString = Translate::RegistratorWrapper < std::set < string::LinearString >, automaton::NPDTA, string::LinearString > ( Translate::translate ); +auto TranslateNPDTALinearString = Translate::RegistratorWrapper < std::set < string::LinearString < > >, automaton::NPDTA, string::LinearString < > > ( Translate::translate ); } /* namespace run */ diff --git a/alib2algo/src/automaton/run/Translate.h b/alib2algo/src/automaton/run/Translate.h index 5bf6eae9888cdd404898ec7bbf7f60f518d5ca8e..2c338877e5015daa8b37bedcc1b724832b2ccf10 100644 --- a/alib2algo/src/automaton/run/Translate.h +++ b/alib2algo/src/automaton/run/Translate.h @@ -19,16 +19,16 @@ namespace automaton { namespace run { -class Translate : public std::DoubleDispatch < Translate, std::set < string::LinearString >, automaton::AutomatonBase, alib::ObjectBase > { +class Translate : public std::DoubleDispatch < Translate, std::set < string::LinearString < > >, automaton::AutomatonBase, alib::ObjectBase > { public: /** * Performs conversion. * @return left regular grammar equivalent to source automaton. */ - static std::set < string::LinearString > translate ( const automaton::Automaton & automaton, const alib::Object & object ); - static std::set < string::LinearString > translate ( const automaton::Automaton & automaton, const string::LinearString & string ); + static std::set < string::LinearString < > > translate ( const automaton::Automaton & automaton, const alib::Object & object ); + static std::set < string::LinearString < > > translate ( const automaton::Automaton & automaton, const string::LinearString < > & string ); - static std::set < string::LinearString > translate ( const automaton::NPDTA & automaton, const string::LinearString & string ); + static std::set < string::LinearString < > > translate ( const automaton::NPDTA & automaton, const string::LinearString < > & string ); }; diff --git a/alib2algo/src/grammar/generate/CockeYoungerKasami.cpp b/alib2algo/src/grammar/generate/CockeYoungerKasami.cpp index 653c54274320c4271111133ed329ea648ab6bf1c..76e4b3b9777820e67cf7b2cbcaaf49eb9ea7d6e1 100644 --- a/alib2algo/src/grammar/generate/CockeYoungerKasami.cpp +++ b/alib2algo/src/grammar/generate/CockeYoungerKasami.cpp @@ -12,7 +12,7 @@ namespace grammar { namespace generate { -bool CockeYoungerKasami::generate ( const grammar::CNF & grammar, const string::LinearString & string ) { +bool CockeYoungerKasami::generate ( const grammar::CNF & grammar, const string::LinearString < > & string ) { unsigned stringSize = string.getContent ( ).size ( ); if ( ( stringSize == 0 ) && grammar.getGeneratesEpsilon ( ) ) return true; @@ -78,7 +78,7 @@ bool CockeYoungerKasami::generate ( const grammar::CNF & grammar, const string:: auto CockeYoungerKasamiCNF = CockeYoungerKasami::RegistratorWrapper < bool, grammar::CNF > ( CockeYoungerKasami::generate ); -bool CockeYoungerKasami::generate ( const grammar::Grammar & grammar, const string::LinearString & string ) { +bool CockeYoungerKasami::generate ( const grammar::Grammar & grammar, const string::LinearString < > & string ) { return dispatch ( grammar.getData ( ), string ); } diff --git a/alib2algo/src/grammar/generate/CockeYoungerKasami.h b/alib2algo/src/grammar/generate/CockeYoungerKasami.h index f2a4086f288b3790e2e6dfcefa7c98d36537f80d..45e5db61d6a6e2b05c975a3732c1cc8ccee1b5ea 100644 --- a/alib2algo/src/grammar/generate/CockeYoungerKasami.h +++ b/alib2algo/src/grammar/generate/CockeYoungerKasami.h @@ -21,11 +21,11 @@ namespace generate { /** * Implements algorithms from Melichar, chapter 3.3 */ -class CockeYoungerKasami : public std::SingleDispatchLastStaticParam < CockeYoungerKasami, bool, grammar::GrammarBase, const string::LinearString & > { +class CockeYoungerKasami : public std::SingleDispatchLastStaticParam < CockeYoungerKasami, bool, grammar::GrammarBase, const string::LinearString < > & > { public: - static bool generate ( const grammar::Grammar & grammar, const string::LinearString & string ); + static bool generate ( const grammar::Grammar & grammar, const string::LinearString < > & string ); - static bool generate ( const grammar::CNF & grammar, const string::LinearString & string ); + static bool generate ( const grammar::CNF & grammar, const string::LinearString < > & string ); }; diff --git a/alib2algo/src/grammar/generate/GenerateUpToLength.cpp b/alib2algo/src/grammar/generate/GenerateUpToLength.cpp index b115a89c8a177eee931b46a80407c62e7dc4a373..93631bb7b1873b150a210610bc71ed7653db6387 100644 --- a/alib2algo/src/grammar/generate/GenerateUpToLength.cpp +++ b/alib2algo/src/grammar/generate/GenerateUpToLength.cpp @@ -20,12 +20,12 @@ namespace grammar { namespace generate { template<class T> -std::set<string::LinearString> GenerateUpToLength::generate( const T & grammar, unsigned length ) { - std::set<string::LinearString> res; +std::set<string::LinearString < >> GenerateUpToLength::generate( const T & grammar, unsigned length ) { + std::set<string::LinearString < >> res; std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> rules = grammar.getRawRules(); if(grammar.getGeneratesEpsilon()) { - res.insert(string::LinearString {}); + res.insert(string::LinearString < > {}); rules[grammar.getInitialSymbol()].erase(std::vector<alphabet::Symbol> {}); } @@ -52,7 +52,7 @@ std::set<string::LinearString> GenerateUpToLength::generate( const T & grammar, } if(newStack.empty()) { - res.insert(string::LinearString(newString)); + res.insert(string::LinearString < >(newString)); } else { data.push_back(std::make_pair(std::move(newString), std::move(newStack))); } @@ -61,13 +61,13 @@ std::set<string::LinearString> GenerateUpToLength::generate( const T & grammar, return res; } -auto GenerateUpToLengthEpsilonFreeCFG = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::EpsilonFreeCFG>(GenerateUpToLength::generate); -auto GenerateUpToLengthGNF = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::GNF>(GenerateUpToLength::generate); -auto GenerateUpToLengthCNF = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::CNF>(GenerateUpToLength::generate); -auto GenerateUpToLengthLeftRG = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::LeftRG>(GenerateUpToLength::generate); -auto GenerateUpToLengthRightRG = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::RightRG>(GenerateUpToLength::generate); +auto GenerateUpToLengthEpsilonFreeCFG = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString < >>, grammar::EpsilonFreeCFG>(GenerateUpToLength::generate); +auto GenerateUpToLengthGNF = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString < >>, grammar::GNF>(GenerateUpToLength::generate); +auto GenerateUpToLengthCNF = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString < >>, grammar::CNF>(GenerateUpToLength::generate); +auto GenerateUpToLengthLeftRG = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString < >>, grammar::LeftRG>(GenerateUpToLength::generate); +auto GenerateUpToLengthRightRG = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString < >>, grammar::RightRG>(GenerateUpToLength::generate); -std::set<string::LinearString> GenerateUpToLength::generate(const grammar::Grammar& grammar, unsigned length) { +std::set<string::LinearString < >> GenerateUpToLength::generate(const grammar::Grammar& grammar, unsigned length) { return dispatch(grammar.getData(), length); } diff --git a/alib2algo/src/grammar/generate/GenerateUpToLength.h b/alib2algo/src/grammar/generate/GenerateUpToLength.h index afc67f0b30424901019507479631150a385e54ec..70913f28aee2029a3e7e318a9b160dbb396477f2 100644 --- a/alib2algo/src/grammar/generate/GenerateUpToLength.h +++ b/alib2algo/src/grammar/generate/GenerateUpToLength.h @@ -21,12 +21,12 @@ namespace generate { /** * Implements algorithms from Melichar, chapter 3.3 */ -class GenerateUpToLength : public std::SingleDispatchLastStaticParam<GenerateUpToLength, std::set<string::LinearString>, grammar::GrammarBase, unsigned> { +class GenerateUpToLength : public std::SingleDispatchLastStaticParam<GenerateUpToLength, std::set<string::LinearString < >>, grammar::GrammarBase, unsigned> { public: - static std::set<string::LinearString> generate( const grammar::Grammar & grammar, unsigned length ); + static std::set<string::LinearString < >> generate( const grammar::Grammar & grammar, unsigned length ); template<class T> - static std::set<string::LinearString> generate( const T & grammar, unsigned length ); + static std::set<string::LinearString < >> generate( const T & grammar, unsigned length ); }; } /* namespace generate */ diff --git a/alib2algo/src/regexp/convert/ToAutomatonDerivation.cpp b/alib2algo/src/regexp/convert/ToAutomatonDerivation.cpp index 662c92a23f830d9b72f008b21446e28d3a490fad..95bd4c0f568a41ea0712ca97b482f25e37a8bb90 100644 --- a/alib2algo/src/regexp/convert/ToAutomatonDerivation.cpp +++ b/alib2algo/src/regexp/convert/ToAutomatonDerivation.cpp @@ -48,7 +48,7 @@ automaton::DFA<> ToAutomatonDerivation::convert(const T& regexp) { regexp::RegExpDerivation deriv; for(const auto& a : regexp.getAlphabet()) { - string::LinearString string(std::vector<alphabet::Symbol>{a}); + string::LinearString < > string(std::vector<alphabet::Symbol>{a}); regexp::RegExp derived = deriv.derivation(dregexp, string); derived = regexp::simplify::RegExpOptimize::optimize(derived); @@ -85,7 +85,7 @@ automaton::DFA<> ToAutomatonDerivation::convert(const T& regexp) { regexp::RegExpDerivation deriv; for(const auto& a: regexp.getAlphabet()) { - string::LinearString string(std::vector<alphabet::Symbol>{a}); + string::LinearString < > string(std::vector<alphabet::Symbol>{a}); regexp::RegExp derived = deriv.derivation(r, string); derived = regexp::simplify::RegExpOptimize::optimize(derived); diff --git a/alib2algo/src/regexp/convert/ToGrammarRightRGDerivation.cpp b/alib2algo/src/regexp/convert/ToGrammarRightRGDerivation.cpp index 5d688cae8fa55bea54ba7d2bf761a7385815e2ef..7abbca785f32f2af99eb8eddc36509e351fc4361 100644 --- a/alib2algo/src/regexp/convert/ToGrammarRightRGDerivation.cpp +++ b/alib2algo/src/regexp/convert/ToGrammarRightRGDerivation.cpp @@ -47,7 +47,7 @@ grammar::RightRG ToGrammarRightRGDerivation::convert(const T& regexp) { for(const auto & dregexp : Ni.at( i - 1 )) { for(const auto & a : regexp.getAlphabet()) { - string::LinearString string(std::vector<alphabet::Symbol>{a}); + string::LinearString < > string(std::vector<alphabet::Symbol>{a}); regexp::RegExp derived = regexp::RegExpDerivation::derivation(dregexp, string); derived = regexp::simplify::RegExpOptimize::optimize(derived); @@ -83,7 +83,7 @@ grammar::RightRG ToGrammarRightRGDerivation::convert(const T& regexp) { for(const auto & r : N) { for(const auto & a : regexp.getAlphabet()) { - string::LinearString string(std::vector<alphabet::Symbol>{a}); + string::LinearString < > string(std::vector<alphabet::Symbol>{a}); regexp::RegExp derived = regexp::RegExpDerivation::derivation(r, string); derived = regexp::simplify::RegExpOptimize::optimize(derived); diff --git a/alib2algo/src/regexp/transform/RegExpDerivation.cpp b/alib2algo/src/regexp/transform/RegExpDerivation.cpp index 1c132c81bc7f01a3004e8f73c7ef993a2e8cc4f0..0464ea4f9dd48b4da0938fc770edad3568c4227d 100644 --- a/alib2algo/src/regexp/transform/RegExpDerivation.cpp +++ b/alib2algo/src/regexp/transform/RegExpDerivation.cpp @@ -14,11 +14,11 @@ namespace regexp { -regexp::RegExp RegExpDerivation::derivation(const regexp::RegExp& regexp, const string::LinearString& string) { +regexp::RegExp RegExpDerivation::derivation(const regexp::RegExp& regexp, const string::LinearString < >& string) { return dispatch(regexp.getData(), string); } -regexp::FormalRegExp RegExpDerivation::derivation(const regexp::FormalRegExp& regexp, const string::LinearString& string) { +regexp::FormalRegExp RegExpDerivation::derivation(const regexp::FormalRegExp& regexp, const string::LinearString < >& string) { std::unique_ptr < regexp::FormalRegExpElement > newRegExp ( regexp.getRegExp().clone() ); for(const auto& symbol : string.getContent()) { @@ -32,7 +32,7 @@ regexp::FormalRegExp RegExpDerivation::derivation(const regexp::FormalRegExp& re auto RegExpDerivationFormalRegExp = RegExpDerivation::RegistratorWrapper<regexp::FormalRegExp, regexp::FormalRegExp>(RegExpDerivation::derivation); -regexp::UnboundedRegExp RegExpDerivation::derivation(const regexp::UnboundedRegExp& regexp, const string::LinearString& string) { +regexp::UnboundedRegExp RegExpDerivation::derivation(const regexp::UnboundedRegExp& regexp, const string::LinearString < >& string) { std::unique_ptr < regexp::UnboundedRegExpElement > newRegExp ( regexp.getRegExp().clone() ); for(const auto& symbol : string.getContent()) { diff --git a/alib2algo/src/regexp/transform/RegExpDerivation.h b/alib2algo/src/regexp/transform/RegExpDerivation.h index 6649a57ea2e65d28181bb7b49e9eadda3322512d..c7caabf24be07107fb3bd5858593314b5880ca41 100644 --- a/alib2algo/src/regexp/transform/RegExpDerivation.h +++ b/alib2algo/src/regexp/transform/RegExpDerivation.h @@ -27,7 +27,7 @@ namespace regexp { * - Melichar, definition 2.91 in chapter 2.4.3 * - Brzozowski, J. A. - Derivatives of regular expressions (1964) */ -class RegExpDerivation : public std::SingleDispatchLastStaticParam<RegExpDerivation, regexp::RegExp, regexp::RegExpBase, const string::LinearString&>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { +class RegExpDerivation : public std::SingleDispatchLastStaticParam<RegExpDerivation, regexp::RegExp, regexp::RegExpBase, const string::LinearString < >&>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { public: RegExpDerivation() {} @@ -36,10 +36,10 @@ public: * @param string String to derivate given RegExp over * @return derivative of regexp */ - static regexp::RegExp derivation(const regexp::RegExp& regexp, const string::LinearString& string); + static regexp::RegExp derivation(const regexp::RegExp& regexp, const string::LinearString < >& string); - static regexp::FormalRegExp derivation(const regexp::FormalRegExp& regexp, const string::LinearString& string); - static regexp::UnboundedRegExp derivation(const regexp::UnboundedRegExp& regexp, const string::LinearString& string); + static regexp::FormalRegExp derivation(const regexp::FormalRegExp& regexp, const string::LinearString < >& string); + static regexp::UnboundedRegExp derivation(const regexp::UnboundedRegExp& regexp, const string::LinearString < >& string); private: void Visit(void*, const regexp::FormalRegExpAlternation& alternation) const; diff --git a/alib2algo/src/regexp/transform/RegExpIntegral.cpp b/alib2algo/src/regexp/transform/RegExpIntegral.cpp index 80444ede0ffa9d2eb16ffb9d653a57d0e4967c5a..a8493826d78fd1a8bb3bf1919dd66c03f925e350 100644 --- a/alib2algo/src/regexp/transform/RegExpIntegral.cpp +++ b/alib2algo/src/regexp/transform/RegExpIntegral.cpp @@ -11,11 +11,11 @@ namespace regexp{ -regexp::RegExp RegExpIntegral::integral(const regexp::RegExp& regexp, const string::LinearString& string) { +regexp::RegExp RegExpIntegral::integral(const regexp::RegExp& regexp, const string::LinearString < >& string) { return dispatch(regexp.getData(), string); } -regexp::FormalRegExp RegExpIntegral::integral(const regexp::FormalRegExp& regexp, const string::LinearString& string) { +regexp::FormalRegExp RegExpIntegral::integral(const regexp::FormalRegExp& regexp, const string::LinearString < >& string) { std::unique_ptr < regexp::FormalRegExpElement > newRegExp ( regexp.getRegExp().clone() ); for(const auto& symbol : string.getContent()) { @@ -29,7 +29,7 @@ regexp::FormalRegExp RegExpIntegral::integral(const regexp::FormalRegExp& regexp auto RegExpIntegralFormalRegExp = RegExpIntegral::RegistratorWrapper<regexp::FormalRegExp, regexp::FormalRegExp>(RegExpIntegral::integral); -regexp::UnboundedRegExp RegExpIntegral::integral(const regexp::UnboundedRegExp& regexp, const string::LinearString& string) { +regexp::UnboundedRegExp RegExpIntegral::integral(const regexp::UnboundedRegExp& regexp, const string::LinearString < >& string) { std::unique_ptr < regexp::UnboundedRegExpElement > newRegExp ( regexp.getRegExp().clone() ); for(const auto& symbol : string.getContent()) { diff --git a/alib2algo/src/regexp/transform/RegExpIntegral.h b/alib2algo/src/regexp/transform/RegExpIntegral.h index 3f201c2029c4b942c99c26f51f98c31ce959936a..392129bb4792f4b88c3d1ed9c8600d2794aed60b 100644 --- a/alib2algo/src/regexp/transform/RegExpIntegral.h +++ b/alib2algo/src/regexp/transform/RegExpIntegral.h @@ -25,7 +25,7 @@ namespace regexp * Calculates integral of regular expression * Source: Melichar definition 2.93 in chapter 2.4.4 */ -class RegExpIntegral : public std::SingleDispatchLastStaticParam<RegExpIntegral, regexp::RegExp, regexp::RegExpBase, const string::LinearString&>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor +class RegExpIntegral : public std::SingleDispatchLastStaticParam<RegExpIntegral, regexp::RegExp, regexp::RegExpBase, const string::LinearString < >&>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { public: RegExpIntegral() {} @@ -35,10 +35,10 @@ public: * @param string String to integrate given RegExp over * @return integral of regexp */ - static regexp::RegExp integral(const regexp::RegExp& regexp, const string::LinearString& string); + static regexp::RegExp integral(const regexp::RegExp& regexp, const string::LinearString < >& string); - static regexp::FormalRegExp integral(const regexp::FormalRegExp& regexp, const string::LinearString& string); - static regexp::UnboundedRegExp integral(const regexp::UnboundedRegExp& regexp, const string::LinearString& string); + static regexp::FormalRegExp integral(const regexp::FormalRegExp& regexp, const string::LinearString < >& string); + static regexp::UnboundedRegExp integral(const regexp::UnboundedRegExp& regexp, const string::LinearString < >& string); private: void Visit(void*, const regexp::FormalRegExpAlternation& alternation) const; diff --git a/alib2algo/src/string/generate/RandomStringFactory.cpp b/alib2algo/src/string/generate/RandomStringFactory.cpp index 17c925014aaa2852ca747ffa0564f949289de61d..1c1e45f3dee51781ab55b8d1bc4ed650c347b349 100644 --- a/alib2algo/src/string/generate/RandomStringFactory.cpp +++ b/alib2algo/src/string/generate/RandomStringFactory.cpp @@ -17,7 +17,7 @@ namespace string { namespace generate { -string::LinearString RandomStringFactory::generateLinearString ( size_t size, size_t alphabetSize, bool randomizedAlphabet, bool integerSymbols ) { +string::LinearString < > RandomStringFactory::generateLinearString ( size_t size, size_t alphabetSize, bool randomizedAlphabet, bool integerSymbols ) { if ( !integerSymbols ) return generateLinearString ( size, alphabetSize, randomizedAlphabet ); if ( alphabetSize <= 0 ) @@ -28,10 +28,10 @@ string::LinearString RandomStringFactory::generateLinearString ( size_t size, si for ( size_t i = 0; i < size; i++ ) elems.push_back ( alphabet::symbolFrom ( static_cast < int > ( std::random_devices::semirandom ( ) % alphabetSize ) ) ); - return string::LinearString ( elems ); + return string::LinearString < > ( elems ); } -string::LinearString RandomStringFactory::generateLinearString ( size_t size, size_t alphabetSize, bool randomizedAlphabet ) { +string::LinearString < > RandomStringFactory::generateLinearString ( size_t size, size_t alphabetSize, bool randomizedAlphabet ) { if ( alphabetSize > 26 ) throw exception::CommonException ( "Too big alphabet." ); @@ -49,7 +49,7 @@ string::LinearString RandomStringFactory::generateLinearString ( size_t size, si return RandomStringFactory::generateLinearString ( size, alphabet ); } -string::LinearString RandomStringFactory::generateLinearString ( size_t size, std::set < alphabet::Symbol > alphabet ) { +string::LinearString < > RandomStringFactory::generateLinearString ( size_t size, std::set < alphabet::Symbol > alphabet ) { if ( alphabet.size ( ) > 26 ) throw exception::CommonException ( "Too big alphabet." ); @@ -63,7 +63,7 @@ string::LinearString RandomStringFactory::generateLinearString ( size_t size, st for ( size_t i = 0; i < size; i++ ) elems.push_back ( alphabetList[std::random_devices::semirandom ( ) % alphabetList.size ( )] ); - return string::LinearString ( elems ); + return string::LinearString < > ( elems ); } } /* namespace generate */ diff --git a/alib2algo/src/string/generate/RandomStringFactory.h b/alib2algo/src/string/generate/RandomStringFactory.h index 39f1a8e3945aa047b46dd68b463c69f259da9c0e..9fe6c00e6647c63c14cd62cfd0aa33f84b3e500d 100644 --- a/alib2algo/src/string/generate/RandomStringFactory.h +++ b/alib2algo/src/string/generate/RandomStringFactory.h @@ -17,9 +17,9 @@ namespace generate { class RandomStringFactory { public: - static string::LinearString generateLinearString ( size_t size, size_t alphabetSize, bool randomizedAlphabet, bool integerSymbols ); - static string::LinearString generateLinearString ( size_t size, size_t alphabetSize, bool randomizedAlphabet ); - static string::LinearString generateLinearString ( size_t size, std::set < alphabet::Symbol > alphabet ); + static string::LinearString < > generateLinearString ( size_t size, size_t alphabetSize, bool randomizedAlphabet, bool integerSymbols ); + static string::LinearString < > generateLinearString ( size_t size, size_t alphabetSize, bool randomizedAlphabet ); + static string::LinearString < > generateLinearString ( size_t size, std::set < alphabet::Symbol > alphabet ); }; } /* namespace generate */ diff --git a/alib2algo/src/string/generate/RandomSubstringFactory.cpp b/alib2algo/src/string/generate/RandomSubstringFactory.cpp index 4c2d212cd474a3722ca4174a2fc73465b5570591..2f945b3da6bb24abdbf48e33c01f016737acaf23 100644 --- a/alib2algo/src/string/generate/RandomSubstringFactory.cpp +++ b/alib2algo/src/string/generate/RandomSubstringFactory.cpp @@ -21,7 +21,7 @@ string::String RandomSubstringFactory::generateSubstring ( size_t size, const st return dispatch ( size, v.getData ( ) ); } -string::LinearString RandomSubstringFactory::generateSubstring ( size_t size, const string::LinearString & string ) { +string::LinearString < > RandomSubstringFactory::generateSubstring ( size_t size, const string::LinearString < > & string ) { if ( size > string.getContent ( ).size ( ) ) throw exception::CommonException ( "String not long enough" ); @@ -29,12 +29,12 @@ string::LinearString RandomSubstringFactory::generateSubstring ( size_t size, co std::vector < alphabet::Symbol > data ( string.getContent ( ).begin ( ) + begin, string.getContent ( ).begin ( ) + begin + size ); - return LinearString { + return LinearString < > { string.getAlphabet ( ), data }; } -auto RandomSubstringFactoryLinearString = RandomSubstringFactory::RegistratorWrapper < string::LinearString, string::LinearString > ( RandomSubstringFactory::generateSubstring ); +auto RandomSubstringFactoryLinearString = RandomSubstringFactory::RegistratorWrapper < string::LinearString < >, string::LinearString < > > ( RandomSubstringFactory::generateSubstring ); } /* namespace generate */ diff --git a/alib2algo/src/string/generate/RandomSubstringFactory.h b/alib2algo/src/string/generate/RandomSubstringFactory.h index e9e8304a27cc84da889c6941955cc6d637d7b77c..0e83f3fcecb9d4a20b1248bf296c9a05b414817c 100644 --- a/alib2algo/src/string/generate/RandomSubstringFactory.h +++ b/alib2algo/src/string/generate/RandomSubstringFactory.h @@ -20,7 +20,7 @@ class RandomSubstringFactory : public std::SingleDispatchFirstStaticParam < Rand public: static string::String generateSubstring ( size_t size, const string::String & ); - static string::LinearString generateSubstring ( size_t size, const string::LinearString & ); + static string::LinearString < > generateSubstring ( size_t size, const string::LinearString < > & ); }; diff --git a/alib2algo/src/string/naive/ExactCompare.cpp b/alib2algo/src/string/naive/ExactCompare.cpp index 6b6ccee2cc5749cee40be1411e8316fbcd180e8f..d3bc8d3ef59b191703c6bd03a6dfa2d209e09d2e 100644 --- a/alib2algo/src/string/naive/ExactCompare.cpp +++ b/alib2algo/src/string/naive/ExactCompare.cpp @@ -24,7 +24,7 @@ int ExactCompare::compare ( const string::Epsilon < > &, const string::Epsilon < auto ExactCompareEpsilon = ExactCompare::RegistratorWrapper < int, string::Epsilon < > > ( ExactCompare::compare ); -int ExactCompare::compare ( const string::LinearString & u, const string::LinearString & v ) { +int ExactCompare::compare ( const string::LinearString < > & u, const string::LinearString < > & v ) { int n = ( int ) u.getContent ( ).size ( ), m = ( int ) v.getContent ( ).size ( ); int k = 0; @@ -42,9 +42,9 @@ int ExactCompare::compare ( const string::LinearString & u, const string::Linear return 1; } -auto ExactCompareLinearString = ExactCompare::RegistratorWrapper < int, string::LinearString > ( ExactCompare::compare ); +auto ExactCompareLinearString = ExactCompare::RegistratorWrapper < int, string::LinearString < > > ( ExactCompare::compare ); -int ExactCompare::compare ( const string::CyclicString & u, const string::CyclicString & v ) { +int ExactCompare::compare ( const string::CyclicString < > & u, const string::CyclicString < > & v ) { int n = ( int ) u.getContent ( ).size ( ), m = ( int ) v.getContent ( ).size ( ); int i = -1, j = -1, k; @@ -68,7 +68,7 @@ int ExactCompare::compare ( const string::CyclicString & u, const string::Cyclic return last ? 1 : -1; } -auto ExactCompareCyclicString = ExactCompare::RegistratorWrapper < int, string::CyclicString > ( ExactCompare::compare ); +auto ExactCompareCyclicString = ExactCompare::RegistratorWrapper < int, string::CyclicString < > > ( ExactCompare::compare ); } /* namespace naive */ diff --git a/alib2algo/src/string/naive/ExactCompare.h b/alib2algo/src/string/naive/ExactCompare.h index 5f0419b6693cef8b6478d8656848d9e17df5c4dd..19a05e326568893ed4e003de48a7f67c3e02600b 100644 --- a/alib2algo/src/string/naive/ExactCompare.h +++ b/alib2algo/src/string/naive/ExactCompare.h @@ -21,8 +21,8 @@ public: static int compare(const string::String& u, const string::String& v); static int compare(const string::Epsilon < >& u, const string::Epsilon < >& v); - static int compare(const string::LinearString& u, const string::LinearString& v); - static int compare(const string::CyclicString& u, const string::CyclicString& v); + static int compare(const string::LinearString < >& u, const string::LinearString < >& v); + static int compare(const string::CyclicString < >& u, const string::CyclicString < >& v); }; } /* namespace naive */ diff --git a/alib2algo/src/string/naive/ExactEqual.cpp b/alib2algo/src/string/naive/ExactEqual.cpp index 43572b11f1e08b8c925f113e7ab46d61f6361a37..89d3c05b7f03062aafce751897a8dc89b3be9b9e 100644 --- a/alib2algo/src/string/naive/ExactEqual.cpp +++ b/alib2algo/src/string/naive/ExactEqual.cpp @@ -24,7 +24,7 @@ bool ExactEqual::equals ( const string::Epsilon < > &, const string::Epsilon < > auto ExactEqualEpsilon = ExactEqual::RegistratorWrapper < bool, string::Epsilon < > > ( ExactEqual::equals ); -bool ExactEqual::equals ( const string::LinearString & u, const string::LinearString & v ) { +bool ExactEqual::equals ( const string::LinearString < > & u, const string::LinearString < > & v ) { int n = ( int ) u.getContent ( ).size ( ), m = ( int ) v.getContent ( ).size ( ); int k = 0; @@ -36,9 +36,9 @@ bool ExactEqual::equals ( const string::LinearString & u, const string::LinearSt return false; } -auto ExactEqualLinearString = ExactEqual::RegistratorWrapper < bool, string::LinearString > ( ExactEqual::equals ); +auto ExactEqualLinearString = ExactEqual::RegistratorWrapper < bool, string::LinearString < > > ( ExactEqual::equals ); -bool ExactEqual::equals ( const string::CyclicString & u, const string::CyclicString & v ) { +bool ExactEqual::equals ( const string::CyclicString < > & u, const string::CyclicString < > & v ) { int n = ( int ) u.getContent ( ).size ( ); int i = -1, j = -1, k; @@ -60,7 +60,7 @@ bool ExactEqual::equals ( const string::CyclicString & u, const string::CyclicSt return false; } -auto ExactEqualCyclicString = ExactEqual::RegistratorWrapper < bool, string::CyclicString > ( ExactEqual::equals ); +auto ExactEqualCyclicString = ExactEqual::RegistratorWrapper < bool, string::CyclicString < > > ( ExactEqual::equals ); } /* namespace naive */ diff --git a/alib2algo/src/string/naive/ExactEqual.h b/alib2algo/src/string/naive/ExactEqual.h index aa13df39ac806ea2e1a89084cead13aa06e16d64..94f9a2f117d212a61d152a4b373ae3f72c76cf1c 100644 --- a/alib2algo/src/string/naive/ExactEqual.h +++ b/alib2algo/src/string/naive/ExactEqual.h @@ -21,8 +21,8 @@ public: static bool equals(const string::String& u, const string::String& v); static bool equals(const string::Epsilon < >& u, const string::Epsilon < >& v); - static bool equals(const string::LinearString& u, const string::LinearString& v); - static bool equals(const string::CyclicString& u, const string::CyclicString& v); + static bool equals(const string::LinearString < >& u, const string::LinearString < >& v); + static bool equals(const string::CyclicString < >& u, const string::CyclicString < >& v); }; } /* namespace naive */ diff --git a/alib2algo/src/string/simplify/NormalizeAlphabet.cpp b/alib2algo/src/string/simplify/NormalizeAlphabet.cpp index bfb81842b04382c2b77d54e1bda8dcd4b0d454d0..9e41d1cc3b467d6173047af0c43614ca960324d0 100644 --- a/alib2algo/src/string/simplify/NormalizeAlphabet.cpp +++ b/alib2algo/src/string/simplify/NormalizeAlphabet.cpp @@ -21,7 +21,7 @@ string::String NormalizeAlphabet::normalize(const string::String& string) { return dispatch(string.getData()); } -string::LinearString NormalizeAlphabet::normalize(const string::LinearString& string) { +string::LinearString < > NormalizeAlphabet::normalize(const string::LinearString < >& string) { int counter = 0; std::map<alphabet::Symbol, char > normalizationData; @@ -41,11 +41,11 @@ string::LinearString NormalizeAlphabet::normalize(const string::LinearString& st data.push_back(alphabet::symbolFrom((char) (normalizationData.find(symbol)->second + 'a'))); } - string::LinearString result(alphabet, data); + string::LinearString < > result(alphabet, data); return result; } -auto NormalizeAlphabetLinearString = NormalizeAlphabet::RegistratorWrapper<string::LinearString, string::LinearString>(NormalizeAlphabet::normalize); +auto NormalizeAlphabetLinearString = NormalizeAlphabet::RegistratorWrapper<string::LinearString < >, string::LinearString < >>(NormalizeAlphabet::normalize); } /* namespace simplify */ diff --git a/alib2algo/src/string/simplify/NormalizeAlphabet.h b/alib2algo/src/string/simplify/NormalizeAlphabet.h index 72260afaa5392d0b43a013f0a9ab7d9d0b3e12f9..c92ef87992cb0336ad229eaa1bdd369c1d5ea117 100644 --- a/alib2algo/src/string/simplify/NormalizeAlphabet.h +++ b/alib2algo/src/string/simplify/NormalizeAlphabet.h @@ -24,7 +24,7 @@ public: */ static string::String normalize(const string::String& str); - static string::LinearString normalize(const string::LinearString& str); + static string::LinearString < > normalize(const string::LinearString < >& str); }; } /* namespace simplify */ diff --git a/alib2algo/src/string/simplify/NormalizeRotation.cpp b/alib2algo/src/string/simplify/NormalizeRotation.cpp index b55f435850544d1662d5f7a095eaf76841e14e34..a2d3adc8314d1148e2b65cab7574292c43b21672 100644 --- a/alib2algo/src/string/simplify/NormalizeRotation.cpp +++ b/alib2algo/src/string/simplify/NormalizeRotation.cpp @@ -17,7 +17,7 @@ string::String NormalizeRotation::normalize(const string::String& string) { return dispatch(string.getData()); } -string::CyclicString NormalizeRotation::normalize(const string::CyclicString& string) { +string::CyclicString < > NormalizeRotation::normalize(const string::CyclicString < >& string) { /** * Lexicographically least circular substrings * Kellogg S. Booth @@ -51,10 +51,10 @@ string::CyclicString NormalizeRotation::normalize(const string::CyclicString& st rotated.push_back(data[l % data.size()]); } - return string::CyclicString { string.getAlphabet(), rotated }; + return string::CyclicString < > { string.getAlphabet(), rotated }; } -auto NormalizeRotationCyclicString = NormalizeRotation::RegistratorWrapper<string::CyclicString, string::CyclicString>(NormalizeRotation::normalize); +auto NormalizeRotationCyclicString = NormalizeRotation::RegistratorWrapper<string::CyclicString < >, string::CyclicString < >>(NormalizeRotation::normalize); } /* namespace simplify */ diff --git a/alib2algo/src/string/simplify/NormalizeRotation.h b/alib2algo/src/string/simplify/NormalizeRotation.h index 4352a866bdabfae7d41d80153cc03b2e97bb3968..adb1e28ac95b8fb9f95bf8880532771491e765c2 100644 --- a/alib2algo/src/string/simplify/NormalizeRotation.h +++ b/alib2algo/src/string/simplify/NormalizeRotation.h @@ -25,7 +25,7 @@ public: */ static string::String normalize(const string::String& string); - static string::CyclicString normalize(const string::CyclicString& string); + static string::CyclicString < > normalize(const string::CyclicString < >& string); }; } /* namespace simplify */ diff --git a/alib2algo/src/stringology/exact/BackwardDAWGMatching.cpp b/alib2algo/src/stringology/exact/BackwardDAWGMatching.cpp index 15adaa4eb07ba82bd4a8aafa4a0f0895beff2e7b..e31c88aeae4f80aae5c83f6897b159ecc340a2a8 100644 --- a/alib2algo/src/stringology/exact/BackwardDAWGMatching.cpp +++ b/alib2algo/src/stringology/exact/BackwardDAWGMatching.cpp @@ -21,7 +21,7 @@ std::set < unsigned > BackwardDAWGMatching::match ( const string::String & subje return dispatch ( subject.getData ( ), pattern.getData ( ) ); } -std::set < unsigned > BackwardDAWGMatching::match ( const string::LinearString & subject, const string::LinearString & pattern ) { +std::set < unsigned > BackwardDAWGMatching::match ( const string::LinearString < > & subject, const string::LinearString < > & pattern ) { std::set < unsigned > occ; measurements::start ( "Preprocess", measurements::Type::PREPROCESS ); @@ -30,7 +30,7 @@ std::set < unsigned > BackwardDAWGMatching::match ( const string::LinearString & reverse ( patternData.begin ( ), patternData.end ( ) ); - const string::LinearString reversedPattern ( std::move ( patternData ) ); + const string::LinearString < > reversedPattern ( std::move ( patternData ) ); automaton::DFA<> suffixAutomaton = SuffixAutomaton::construct ( reversedPattern ); @@ -75,7 +75,7 @@ std::set < unsigned > BackwardDAWGMatching::match ( const string::LinearString & return occ; } -auto BackwardDAWGMatchingLinearStringLinearString = BackwardDAWGMatching::RegistratorWrapper < std::set < unsigned >, string::LinearString, string::LinearString > ( BackwardDAWGMatching::match ); +auto BackwardDAWGMatchingLinearStringLinearString = BackwardDAWGMatching::RegistratorWrapper < std::set < unsigned >, string::LinearString < >, string::LinearString < > > ( BackwardDAWGMatching::match ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/BackwardDAWGMatching.h b/alib2algo/src/stringology/exact/BackwardDAWGMatching.h index 0e7a1291d8299a534f177b560934f70f56ec2835..ec745f41201d37d42c642a62d8f54932f8b4b855 100644 --- a/alib2algo/src/stringology/exact/BackwardDAWGMatching.h +++ b/alib2algo/src/stringology/exact/BackwardDAWGMatching.h @@ -25,7 +25,7 @@ public: * @return set set of occurences */ static std::set < unsigned > match ( const string::String & subject, const string::String & pattern ); - static std::set < unsigned > match ( const string::LinearString & subject, const string::LinearString & pattern ); + static std::set < unsigned > match ( const string::LinearString < > & subject, const string::LinearString < > & pattern ); }; diff --git a/alib2algo/src/stringology/exact/BackwardNondeterministicDAWGMatching.cpp b/alib2algo/src/stringology/exact/BackwardNondeterministicDAWGMatching.cpp index 13281689cf9175e34c29bc837b85163a3fe4ed4e..43982f7d2e91099c9e241a384b0d2e9fe41e17bf 100644 --- a/alib2algo/src/stringology/exact/BackwardNondeterministicDAWGMatching.cpp +++ b/alib2algo/src/stringology/exact/BackwardNondeterministicDAWGMatching.cpp @@ -21,7 +21,7 @@ std::set < unsigned > BackwardNondeterministicDAWGMatching::matchTemplate ( cons } template < size_t BitmaskBitCount > -std::set < unsigned > BackwardNondeterministicDAWGMatching::matchTemplate ( const string::LinearString & subject, const string::LinearString & pattern ) { +std::set < unsigned > BackwardNondeterministicDAWGMatching::matchTemplate ( const string::LinearString < > & subject, const string::LinearString < > & pattern ) { std::set < unsigned > occ; // Setup helper variables @@ -95,7 +95,7 @@ std::set < unsigned > BackwardNondeterministicDAWGMatching::match ( const string return BackwardNondeterministicDAWGMatching::match32 ( subject, pattern ); } -std::set < unsigned > BackwardNondeterministicDAWGMatching::match ( const string::LinearString & subject, const string::LinearString & pattern ) { +std::set < unsigned > BackwardNondeterministicDAWGMatching::match ( const string::LinearString < > & subject, const string::LinearString < > & pattern ) { return BackwardNondeterministicDAWGMatching::match32 ( subject, pattern ); } @@ -103,7 +103,7 @@ std::set < unsigned > BackwardNondeterministicDAWGMatching::match32 ( const stri return BackwardNondeterministicDAWGMatching::matchTemplate < 32 > ( subject, pattern ); } -std::set < unsigned > BackwardNondeterministicDAWGMatching::match32 ( const string::LinearString & subject, const string::LinearString & pattern ) { +std::set < unsigned > BackwardNondeterministicDAWGMatching::match32 ( const string::LinearString < > & subject, const string::LinearString < > & pattern ) { return BackwardNondeterministicDAWGMatching::matchTemplate < 32 > ( subject, pattern ); } @@ -111,7 +111,7 @@ std::set < unsigned > BackwardNondeterministicDAWGMatching::match64 ( const stri return BackwardNondeterministicDAWGMatching::matchTemplate < 64 > ( subject, pattern ); } -std::set < unsigned > BackwardNondeterministicDAWGMatching::match64 ( const string::LinearString & subject, const string::LinearString & pattern ) { +std::set < unsigned > BackwardNondeterministicDAWGMatching::match64 ( const string::LinearString < > & subject, const string::LinearString < > & pattern ) { return BackwardNondeterministicDAWGMatching::matchTemplate < 64 > ( subject, pattern ); } @@ -119,11 +119,11 @@ std::set < unsigned > BackwardNondeterministicDAWGMatching::match128 ( const str return BackwardNondeterministicDAWGMatching::matchTemplate < 128 > ( subject, pattern ); } -std::set < unsigned > BackwardNondeterministicDAWGMatching::match128 ( const string::LinearString & subject, const string::LinearString & pattern ) { +std::set < unsigned > BackwardNondeterministicDAWGMatching::match128 ( const string::LinearString < > & subject, const string::LinearString < > & pattern ) { return BackwardNondeterministicDAWGMatching::matchTemplate < 128 > ( subject, pattern ); } -auto BackwardNondeterministicDAWGMatchingLinearStringLinearString = BackwardNondeterministicDAWGMatching::RegistratorWrapper < std::set < unsigned >, string::LinearString, string::LinearString > ( BackwardNondeterministicDAWGMatching::match ); +auto BackwardNondeterministicDAWGMatchingLinearStringLinearString = BackwardNondeterministicDAWGMatching::RegistratorWrapper < std::set < unsigned >, string::LinearString < >, string::LinearString < > > ( BackwardNondeterministicDAWGMatching::match ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/BackwardNondeterministicDAWGMatching.hpp b/alib2algo/src/stringology/exact/BackwardNondeterministicDAWGMatching.hpp index d428ca01a50ff8472ff2c3c0427bc0719ac99a4d..1c2ea27fe52ac6ad2585a4b204d4216d8b9f1ec7 100644 --- a/alib2algo/src/stringology/exact/BackwardNondeterministicDAWGMatching.hpp +++ b/alib2algo/src/stringology/exact/BackwardNondeterministicDAWGMatching.hpp @@ -28,21 +28,21 @@ private: static std::set < unsigned > matchTemplate ( const string::String & subject, const string::String & pattern ); template <size_t BitmaskBitCount > - static std::set < unsigned > matchTemplate ( const string::LinearString & subject, const string::LinearString & pattern ); + static std::set < unsigned > matchTemplate ( const string::LinearString < > & subject, const string::LinearString < > & pattern ); public: // Defaults to 32 bits static std::set < unsigned > match ( const string::String & subject, const string::String & pattern ); - static std::set < unsigned > match ( const string::LinearString & subject, const string::LinearString & pattern ); + static std::set < unsigned > match ( const string::LinearString < > & subject, const string::LinearString < > & pattern ); static std::set < unsigned > match32 ( const string::String & subject, const string::String & pattern ); - static std::set < unsigned > match32 ( const string::LinearString & subject, const string::LinearString & pattern ); + static std::set < unsigned > match32 ( const string::LinearString < > & subject, const string::LinearString < > & pattern ); static std::set < unsigned > match64 ( const string::String & subject, const string::String & pattern ); - static std::set < unsigned > match64 ( const string::LinearString & subject, const string::LinearString & pattern ); + static std::set < unsigned > match64 ( const string::LinearString < > & subject, const string::LinearString < > & pattern ); static std::set < unsigned > match128 ( const string::String & subject, const string::String & pattern ); - static std::set < unsigned > match128 ( const string::LinearString & subject, const string::LinearString & pattern ); + static std::set < unsigned > match128 ( const string::LinearString < > & subject, const string::LinearString < > & pattern ); }; diff --git a/alib2algo/src/stringology/exact/BackwardOracleMatching.cpp b/alib2algo/src/stringology/exact/BackwardOracleMatching.cpp index 1dc04f5c89d1ef6fe076b733921c3b85448c8b68..ffb2f5513aca355a3a56c0188a00c6515e3d907e 100644 --- a/alib2algo/src/stringology/exact/BackwardOracleMatching.cpp +++ b/alib2algo/src/stringology/exact/BackwardOracleMatching.cpp @@ -21,7 +21,7 @@ std::set < unsigned > BackwardOracleMatching::match ( const string::String & sub return dispatch ( subject.getData ( ), pattern.getData ( ) ); } -std::set < unsigned > BackwardOracleMatching::match ( const string::LinearString & subject, const string::LinearString & pattern ) { +std::set < unsigned > BackwardOracleMatching::match ( const string::LinearString < > & subject, const string::LinearString < > & pattern ) { std::set < unsigned > occ; measurements::start ( "Preprocess", measurements::Type::PREPROCESS ); @@ -30,7 +30,7 @@ std::set < unsigned > BackwardOracleMatching::match ( const string::LinearString reverse ( patternData.begin ( ), patternData.end ( ) ); - const string::LinearString reversedPattern ( std::move ( patternData ) ); + const string::LinearString < > reversedPattern ( std::move ( patternData ) ); automaton::DFA<> factorOracle = FactorOracleAutomaton::construct ( reversedPattern ); @@ -71,7 +71,7 @@ std::set < unsigned > BackwardOracleMatching::match ( const string::LinearString return occ; } -auto BackwardOracleMatchingLinearStringLinearString = BackwardOracleMatching::RegistratorWrapper < std::set < unsigned >, string::LinearString, string::LinearString > ( BackwardOracleMatching::match ); +auto BackwardOracleMatchingLinearStringLinearString = BackwardOracleMatching::RegistratorWrapper < std::set < unsigned >, string::LinearString < >, string::LinearString < > > ( BackwardOracleMatching::match ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/BackwardOracleMatching.h b/alib2algo/src/stringology/exact/BackwardOracleMatching.h index d602d2fd03bfe653cbd4cdf671947209aeb0f9e3..9661283dae028af1c05fcfff1eb42eed9528e6e7 100644 --- a/alib2algo/src/stringology/exact/BackwardOracleMatching.h +++ b/alib2algo/src/stringology/exact/BackwardOracleMatching.h @@ -25,7 +25,7 @@ public: * @return set set of occurences */ static std::set < unsigned > match ( const string::String & subject, const string::String & pattern ); - static std::set < unsigned > match ( const string::LinearString & subject, const string::LinearString & pattern ); + static std::set < unsigned > match ( const string::LinearString < > & subject, const string::LinearString < > & pattern ); }; diff --git a/alib2algo/src/stringology/exact/BadCharacterShiftTable.cpp b/alib2algo/src/stringology/exact/BadCharacterShiftTable.cpp index ae0a9a84ac63681eb3b34df0e5960bc2323c6dba..9b0cca0bd6f69f536b27bf791defd29205a126d5 100644 --- a/alib2algo/src/stringology/exact/BadCharacterShiftTable.cpp +++ b/alib2algo/src/stringology/exact/BadCharacterShiftTable.cpp @@ -18,7 +18,7 @@ std::map<alphabet::Symbol, size_t> BadCharacterShiftTable::bcs(const string::Str return dispatch(pattern.getData()); } -std::map<alphabet::Symbol, size_t> BadCharacterShiftTable::bcs(const string::LinearString& pattern) { +std::map<alphabet::Symbol, size_t> BadCharacterShiftTable::bcs(const string::LinearString < >& pattern) { const std::set<alphabet::Symbol>& alphabet = pattern.getAlphabet(); std::map<alphabet::Symbol, size_t> bcs; @@ -40,7 +40,7 @@ std::map<alphabet::Symbol, size_t> BadCharacterShiftTable::bcs(const string::Lin return bcs; } -auto BadCharacterShiftTableLinearString = BadCharacterShiftTable::RegistratorWrapper<std::map<alphabet::Symbol, size_t>, string::LinearString>(BadCharacterShiftTable::bcs); +auto BadCharacterShiftTableLinearString = BadCharacterShiftTable::RegistratorWrapper<std::map<alphabet::Symbol, size_t>, string::LinearString < >>(BadCharacterShiftTable::bcs); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/BadCharacterShiftTable.h b/alib2algo/src/stringology/exact/BadCharacterShiftTable.h index b8f97bc5f4aa9cca5b42929b789447ddb5ffbb04..ba68c20b2f773a0b999a11b4c91dd9cff2b2e4d4 100644 --- a/alib2algo/src/stringology/exact/BadCharacterShiftTable.h +++ b/alib2algo/src/stringology/exact/BadCharacterShiftTable.h @@ -31,7 +31,7 @@ public: */ static std::map < alphabet::Symbol, size_t > bcs ( const string::String & pattern ); - static std::map < alphabet::Symbol, size_t > bcs ( const string::LinearString & pattern ); + static std::map < alphabet::Symbol, size_t > bcs ( const string::LinearString < > & pattern ); }; diff --git a/alib2algo/src/stringology/exact/BorderArray.cpp b/alib2algo/src/stringology/exact/BorderArray.cpp index 2b2ad25be70c9b2d7b004a5331aa4905a0d76498..8ca9734ab757b348b113979bfda6b0cadbd6e503 100644 --- a/alib2algo/src/stringology/exact/BorderArray.cpp +++ b/alib2algo/src/stringology/exact/BorderArray.cpp @@ -21,7 +21,7 @@ std::vector<unsigned> BorderArray::construct(const string::String& string) { return dispatch(string.getData()); } -std::vector<unsigned> BorderArray::construct(const string::LinearString& string) { +std::vector<unsigned> BorderArray::construct(const string::LinearString < >& string) { const auto& w = string.getContent(); std::vector<unsigned> res(w.size() + 1); @@ -41,7 +41,7 @@ std::vector<unsigned> BorderArray::construct(const string::LinearString& string) return res; } -auto BorderArrayLinearString = BorderArray::RegistratorWrapper<std::vector<unsigned>, string::LinearString>(BorderArray::construct); +auto BorderArrayLinearString = BorderArray::RegistratorWrapper<std::vector<unsigned>, string::LinearString < >>(BorderArray::construct); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/BorderArray.h b/alib2algo/src/stringology/exact/BorderArray.h index 8e526ccbe7e2ecda438e4f7918fbe388e135cc88..e60236e6a58efcd4400319369aeff8afabf80c38 100644 --- a/alib2algo/src/stringology/exact/BorderArray.h +++ b/alib2algo/src/stringology/exact/BorderArray.h @@ -25,7 +25,7 @@ public: */ static std::vector<unsigned> construct(const string::String& string); - static std::vector<unsigned> construct(const string::LinearString& string); + static std::vector<unsigned> construct(const string::LinearString < >& string); }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/BoyerMooreHorspool.cpp b/alib2algo/src/stringology/exact/BoyerMooreHorspool.cpp index c3e084ddb03cefbf59f5ab6fdb0a404ed6eb11e6..01c0fae31c337ce28864af070fc74dca9848f36d 100644 --- a/alib2algo/src/stringology/exact/BoyerMooreHorspool.cpp +++ b/alib2algo/src/stringology/exact/BoyerMooreHorspool.cpp @@ -22,7 +22,7 @@ std::set<unsigned> BoyerMooreHorspool::match(const string::String& subject, cons return dispatch(subject.getData(), pattern.getData()); } -std::set<unsigned> BoyerMooreHorspool::match(const string::LinearString& string, const string::LinearString& pattern) +std::set<unsigned> BoyerMooreHorspool::match(const string::LinearString < >& string, const string::LinearString < >& pattern) { std::set<unsigned> occ; @@ -48,7 +48,7 @@ std::set<unsigned> BoyerMooreHorspool::match(const string::LinearString& string, return occ; } -auto BoyerMooreHorpoolLinearStringLinearString = BoyerMooreHorspool::RegistratorWrapper<std::set<unsigned>, string::LinearString, string::LinearString>(BoyerMooreHorspool::match); +auto BoyerMooreHorpoolLinearStringLinearString = BoyerMooreHorspool::RegistratorWrapper<std::set<unsigned>, string::LinearString < >, string::LinearString < >>(BoyerMooreHorspool::match); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/BoyerMooreHorspool.h b/alib2algo/src/stringology/exact/BoyerMooreHorspool.h index f6faba17bd4832183f3bf352e79eda9c9a41835b..fc5e5205ec2f9ca2af0f92a67535de1b8398811c 100644 --- a/alib2algo/src/stringology/exact/BoyerMooreHorspool.h +++ b/alib2algo/src/stringology/exact/BoyerMooreHorspool.h @@ -29,7 +29,7 @@ public: */ static std::set < unsigned > match ( const string::String & subject, const string::String & pattern ); - static std::set < unsigned > match ( const string::LinearString & subject, const string::LinearString & pattern ); + static std::set < unsigned > match ( const string::LinearString < > & subject, const string::LinearString < > & pattern ); }; diff --git a/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.cpp b/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.cpp index e52bbe2d26c9ceecd1142757a3adef34bec3b8c5..38ae488a66886cba3ee908397213c3545d079128 100644 --- a/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.cpp +++ b/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.cpp @@ -22,7 +22,7 @@ std::set < unsigned > DeadZoneUsingBadCharacterShift::match ( const string::Stri return dispatch ( subject.getData ( ), pattern.getData ( ) ); } -std::set < unsigned > DeadZoneUsingBadCharacterShift::match ( const string::LinearString & string, const string::LinearString & pattern ) { +std::set < unsigned > DeadZoneUsingBadCharacterShift::match ( const string::LinearString < > & string, const string::LinearString < > & pattern ) { std::set < unsigned > occ; std::map < alphabet::Symbol, size_t > fbcs = BadCharacterShiftTable::bcs ( pattern ); // NOTE: the subjects alphabet must be a subset or equal to the pattern std::map < alphabet::Symbol, size_t > bbcs = ReversedBadCharacterShiftTable::bcs ( pattern ); // NOTE: the subjects alphabet must be a subset or equal to the pattern @@ -31,7 +31,7 @@ std::set < unsigned > DeadZoneUsingBadCharacterShift::match ( const string::Line return occ; } -void DeadZoneUsingBadCharacterShift::match_rec ( std::set < unsigned > & occ, const string::LinearString & string, const string::LinearString & pattern, std::map < alphabet::Symbol, size_t > & fbcs, std::map < alphabet::Symbol, size_t > & bbcs, int low, int high ) { +void DeadZoneUsingBadCharacterShift::match_rec ( std::set < unsigned > & occ, const string::LinearString < > & string, const string::LinearString < > & pattern, std::map < alphabet::Symbol, size_t > & fbcs, std::map < alphabet::Symbol, size_t > & bbcs, int low, int high ) { if ( low >= high ) return; int middle = ( low + high ) / 2; @@ -47,7 +47,7 @@ void DeadZoneUsingBadCharacterShift::match_rec ( std::set < unsigned > & occ, co match_rec ( occ, string, pattern, fbcs, bbcs, middle + fbcs[string.getContent ( )[middle + pattern.getContent ( ).size ( ) - 1]], high ); } -auto DeadZoneUsingBadCharacterShiftLinearStringLinearString = DeadZoneUsingBadCharacterShift::RegistratorWrapper < std::set < unsigned >, string::LinearString, string::LinearString > ( DeadZoneUsingBadCharacterShift::match ); +auto DeadZoneUsingBadCharacterShiftLinearStringLinearString = DeadZoneUsingBadCharacterShift::RegistratorWrapper < std::set < unsigned >, string::LinearString < >, string::LinearString < > > ( DeadZoneUsingBadCharacterShift::match ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.h b/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.h index 0e8f178a791ee44f46e5362f998369662db0b739..a6977adc8739f60800669b3b9157fb1845abfc9e 100644 --- a/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.h +++ b/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.h @@ -28,8 +28,8 @@ public: */ static std::set < unsigned > match ( const string::String & subject, const string::String & pattern ); - static std::set < unsigned > match ( const string::LinearString & subject, const string::LinearString & pattern ); - static void match_rec ( std::set < unsigned > & occ, const string::LinearString & string, const string::LinearString & pattern, std::map < alphabet::Symbol, size_t > & fbcs, std::map < alphabet::Symbol, size_t > & bbcs, int low, int high ); + static std::set < unsigned > match ( const string::LinearString < > & subject, const string::LinearString < > & pattern ); + static void match_rec ( std::set < unsigned > & occ, const string::LinearString < > & string, const string::LinearString < > & pattern, std::map < alphabet::Symbol, size_t > & fbcs, std::map < alphabet::Symbol, size_t > & bbcs, int low, int high ); }; diff --git a/alib2algo/src/stringology/exact/ExactFactorAutomaton.cpp b/alib2algo/src/stringology/exact/ExactFactorAutomaton.cpp index 5a679c98890f2350869b333f8f62c39be5eafc2f..2dad6106643ac8b7ae722c5920b3d64d7e9f685e 100644 --- a/alib2algo/src/stringology/exact/ExactFactorAutomaton.cpp +++ b/alib2algo/src/stringology/exact/ExactFactorAutomaton.cpp @@ -19,7 +19,7 @@ automaton::Automaton ExactFactorAutomaton::construct(const string::String& text) return dispatch(text.getData()); } -automaton::EpsilonNFA < > ExactFactorAutomaton::construct(const string::LinearString& text) { +automaton::EpsilonNFA < > ExactFactorAutomaton::construct(const string::LinearString < >& text) { automaton::EpsilonNFA < > res(label::labelFrom(0)); res.addFinalState(label::labelFrom(0)); res.setInputAlphabet(text.getAlphabet()); @@ -34,7 +34,7 @@ automaton::EpsilonNFA < > ExactFactorAutomaton::construct(const string::LinearSt return res; } -auto ExactFactorAutomatonLinearString = ExactFactorAutomaton::RegistratorWrapper<automaton::EpsilonNFA < >, string::LinearString>(ExactFactorAutomaton::construct); +auto ExactFactorAutomatonLinearString = ExactFactorAutomaton::RegistratorWrapper<automaton::EpsilonNFA < >, string::LinearString < >>(ExactFactorAutomaton::construct); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactFactorAutomaton.h b/alib2algo/src/stringology/exact/ExactFactorAutomaton.h index ba7d395db42342f4b69804e22afce5c6be030030..5a806478541375582b332ae923c244cf5eaa75d3 100644 --- a/alib2algo/src/stringology/exact/ExactFactorAutomaton.h +++ b/alib2algo/src/stringology/exact/ExactFactorAutomaton.h @@ -26,7 +26,7 @@ public: */ static automaton::Automaton construct(const string::String& text); - static automaton::EpsilonNFA < > construct(const string::LinearString& text); + static automaton::EpsilonNFA < > construct(const string::LinearString < >& text); }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactFactorMatch.cpp b/alib2algo/src/stringology/exact/ExactFactorMatch.cpp index 5172a2c4e03aeba076178c3e40b7e32f00d474c2..1afd9953be6f7adddd7c8c7df65bb64613c5b938 100644 --- a/alib2algo/src/stringology/exact/ExactFactorMatch.cpp +++ b/alib2algo/src/stringology/exact/ExactFactorMatch.cpp @@ -18,7 +18,7 @@ std::set < unsigned > ExactFactorMatch::match ( const string::String & subject, return dispatch ( subject.getData ( ), pattern.getData ( ) ); } -std::set < unsigned > ExactFactorMatch::match ( const string::LinearString & subject, const string::LinearString & pattern ) { +std::set < unsigned > ExactFactorMatch::match ( const string::LinearString < > & subject, const string::LinearString < > & pattern ) { std::set < unsigned > occ; for ( unsigned i = 0; i + pattern.getContent ( ).size ( ) <= subject.getContent ( ).size ( ); i++ ) { @@ -34,7 +34,7 @@ std::set < unsigned > ExactFactorMatch::match ( const string::LinearString & sub return occ; } -auto ExactFactorMatchLinearString = ExactFactorMatch::RegistratorWrapper < std::set < unsigned >, string::LinearString > ( ExactFactorMatch::match ); +auto ExactFactorMatchLinearString = ExactFactorMatch::RegistratorWrapper < std::set < unsigned >, string::LinearString < > > ( ExactFactorMatch::match ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactFactorMatch.h b/alib2algo/src/stringology/exact/ExactFactorMatch.h index 4acb2883f1977c51037cfa3b047c4fa23ac592ce..6251ec8f5439b628673de6d0dd3bd1cc072f7dc7 100644 --- a/alib2algo/src/stringology/exact/ExactFactorMatch.h +++ b/alib2algo/src/stringology/exact/ExactFactorMatch.h @@ -25,7 +25,7 @@ public: */ static std::set<unsigned> match(const string::String& subject, const string::String& pattern); - static std::set<unsigned> match(const string::LinearString& subject, const string::LinearString& pattern); + static std::set<unsigned> match(const string::LinearString < >& subject, const string::LinearString < >& pattern); }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactMatchingAutomaton.cpp b/alib2algo/src/stringology/exact/ExactMatchingAutomaton.cpp index 3e1a8ae62394dffcb6b987464fc94812c536eb95..e419a65b1febfc6bc2b91d38197bea78322a15e0 100644 --- a/alib2algo/src/stringology/exact/ExactMatchingAutomaton.cpp +++ b/alib2algo/src/stringology/exact/ExactMatchingAutomaton.cpp @@ -19,7 +19,7 @@ automaton::Automaton ExactMatchingAutomaton::construct(const string::String& pat return dispatch(pattern.getData()); } -automaton::NFA < > ExactMatchingAutomaton::construct(const string::LinearString& pattern) { +automaton::NFA < > ExactMatchingAutomaton::construct(const string::LinearString < >& pattern) { automaton::NFA < > res(label::labelFrom(0)); res.setInputAlphabet(pattern.getAlphabet()); for(const alphabet::Symbol& symbol : pattern.getAlphabet()) { @@ -35,7 +35,7 @@ automaton::NFA < > ExactMatchingAutomaton::construct(const string::LinearString& return res; } -auto ExactMatchingAutomatonLinearString = ExactMatchingAutomaton::RegistratorWrapper<automaton::NFA < > , string::LinearString>(ExactMatchingAutomaton::construct); +auto ExactMatchingAutomatonLinearString = ExactMatchingAutomaton::RegistratorWrapper<automaton::NFA < > , string::LinearString < >>(ExactMatchingAutomaton::construct); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactMatchingAutomaton.h b/alib2algo/src/stringology/exact/ExactMatchingAutomaton.h index 8d166f803f08218177d189a9c692b1b7cc3ea643..36c0a72fb0febed15b4ee8929b5d29e97070bab2 100644 --- a/alib2algo/src/stringology/exact/ExactMatchingAutomaton.h +++ b/alib2algo/src/stringology/exact/ExactMatchingAutomaton.h @@ -26,7 +26,7 @@ public: */ static automaton::Automaton construct(const string::String& pattern); - static automaton::NFA < > construct(const string::LinearString& pattern); + static automaton::NFA < > construct(const string::LinearString < >& pattern); }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactMultiNondeterministicSubsequenceAutomaton.cpp b/alib2algo/src/stringology/exact/ExactMultiNondeterministicSubsequenceAutomaton.cpp index 7449a5b0ee61083ab3d9ef21601cebd463935fd2..09397943751ae628d3ea93c8c0a7e69c06ee8ee9 100644 --- a/alib2algo/src/stringology/exact/ExactMultiNondeterministicSubsequenceAutomaton.cpp +++ b/alib2algo/src/stringology/exact/ExactMultiNondeterministicSubsequenceAutomaton.cpp @@ -15,15 +15,15 @@ namespace stringology { namespace exact { automaton::Automaton ExactMultiNondeterministicSubsequenceAutomaton::construct(const std::set<string::String>& texts) { - return automaton::Automaton(ExactMultiNondeterministicSubsequenceAutomaton::construct(common::ContainerConverter<std::set<string::LinearString>, std::set<string::String>, string::LinearString>::convert(texts))); + return automaton::Automaton(ExactMultiNondeterministicSubsequenceAutomaton::construct(common::ContainerConverter<std::set<string::LinearString < >>, std::set<string::String>, string::LinearString < >>::convert(texts))); } -automaton::EpsilonNFA < > ExactMultiNondeterministicSubsequenceAutomaton::construct(const std::set<string::LinearString>& texts) { +automaton::EpsilonNFA < > ExactMultiNondeterministicSubsequenceAutomaton::construct(const std::set<string::LinearString < >>& texts) { automaton::EpsilonNFA < > res(label::labelFrom(0)); res.addFinalState(label::labelFrom(0)); int j = 0; - for(const string::LinearString& text : texts) { + for(const string::LinearString < >& text : texts) { res.addInputSymbols(text.getAlphabet()); res.addState(label::labelFrom(0, j)); diff --git a/alib2algo/src/stringology/exact/ExactMultiNondeterministicSubsequenceAutomaton.h b/alib2algo/src/stringology/exact/ExactMultiNondeterministicSubsequenceAutomaton.h index 746e0f2cb9093b512bddde1823895d3d4fbb2cb3..af468031cc7c05c5fccb9d3e0f7177defc79e65f 100644 --- a/alib2algo/src/stringology/exact/ExactMultiNondeterministicSubsequenceAutomaton.h +++ b/alib2algo/src/stringology/exact/ExactMultiNondeterministicSubsequenceAutomaton.h @@ -25,7 +25,7 @@ public: */ static automaton::Automaton construct(const std::set<string::String>& text); - static automaton::EpsilonNFA < > construct(const std::set<string::LinearString>& text); + static automaton::EpsilonNFA < > construct(const std::set<string::LinearString < >>& text); }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.cpp b/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.cpp index 48bbd2e973d5de5802a437c2e10a7636b5b5036f..4ff89c5b075776dea7596ea3e67ccdc88c6772ac 100644 --- a/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.cpp +++ b/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.cpp @@ -19,7 +19,7 @@ automaton::Automaton ExactNondeterministicSubsequenceAutomaton::construct(const return dispatch(text.getData()); } -automaton::EpsilonNFA < > ExactNondeterministicSubsequenceAutomaton::construct(const string::LinearString& text) { +automaton::EpsilonNFA < > ExactNondeterministicSubsequenceAutomaton::construct(const string::LinearString < >& text) { automaton::EpsilonNFA < > res(label::labelFrom(0)); res.addFinalState(label::labelFrom(0)); res.setInputAlphabet(text.getAlphabet()); @@ -36,7 +36,7 @@ automaton::EpsilonNFA < > ExactNondeterministicSubsequenceAutomaton::construct(c return res; } -auto ExactNondeterministicSubsequenceAutomatonLinearString = ExactNondeterministicSubsequenceAutomaton::RegistratorWrapper<automaton::EpsilonNFA < >, string::LinearString>( ExactNondeterministicSubsequenceAutomaton::construct ); +auto ExactNondeterministicSubsequenceAutomatonLinearString = ExactNondeterministicSubsequenceAutomaton::RegistratorWrapper<automaton::EpsilonNFA < >, string::LinearString < >>( ExactNondeterministicSubsequenceAutomaton::construct ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.h b/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.h index 77846c7d386b4a7f2372d57a5177b1e749fb0250..5912d0bdb2671126a1ff2c5c11ad51f4b9f310e1 100644 --- a/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.h +++ b/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.h @@ -26,7 +26,7 @@ public: */ static automaton::Automaton construct(const string::String& text); - static automaton::EpsilonNFA < > construct(const string::LinearString& text); + static automaton::EpsilonNFA < > construct(const string::LinearString < >& text); }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.cpp b/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.cpp index 1f8e55d7bb580e40a6a5dd5b7db861ef68ac6ed6..bded235021e3615fe197e4b374732e9a7cce5fca 100644 --- a/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.cpp +++ b/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.cpp @@ -19,7 +19,7 @@ automaton::Automaton ExactSubsequenceAutomaton::construct(const string::String& return dispatch(text.getData()); } -automaton::DFA<> ExactSubsequenceAutomaton::construct(const string::LinearString& text) { +automaton::DFA<> ExactSubsequenceAutomaton::construct(const string::LinearString < >& text) { std::map<alphabet::Symbol, int> f; for(const alphabet::Symbol& symbol : text.getAlphabet()) { f[symbol] = 0; @@ -43,7 +43,7 @@ automaton::DFA<> ExactSubsequenceAutomaton::construct(const string::LinearString return res; } -auto ExactSubsequenceAutomatonLinearString = ExactSubsequenceAutomaton::RegistratorWrapper<automaton::DFA<>, string::LinearString>(ExactSubsequenceAutomaton::construct); +auto ExactSubsequenceAutomatonLinearString = ExactSubsequenceAutomaton::RegistratorWrapper<automaton::DFA<>, string::LinearString < >>(ExactSubsequenceAutomaton::construct); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.h b/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.h index 371c0c4771375904b75ee6e388297fd5be92a75e..dc7a758d66aa0df818b7eaab38eec8850e2e2971 100644 --- a/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.h +++ b/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.h @@ -26,7 +26,7 @@ public: */ static automaton::Automaton construct(const string::String& text); - static automaton::DFA<> construct(const string::LinearString& text); + static automaton::DFA<> construct(const string::LinearString < >& text); }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/FactorOracleAutomaton.cpp b/alib2algo/src/stringology/exact/FactorOracleAutomaton.cpp index 2c11770e9eb5cde2e49431e190518b5820ff6d9f..8f4571cd7dba1dbacaf5185aa5c9560d28b98b5c 100644 --- a/alib2algo/src/stringology/exact/FactorOracleAutomaton.cpp +++ b/alib2algo/src/stringology/exact/FactorOracleAutomaton.cpp @@ -13,7 +13,7 @@ automaton::Automaton FactorOracleAutomaton::construct ( const string::String & p return dispatch ( pattern.getData ( ) ); } -automaton::DFA<> FactorOracleAutomaton::construct ( const string::LinearString & pattern ) { +automaton::DFA<> FactorOracleAutomaton::construct ( const string::LinearString < > & pattern ) { automaton::DFA<> oracle ( label::labelFrom ( 0 ) ); oracle.addFinalState ( oracle.getInitialState ( ) ); @@ -53,7 +53,7 @@ void FactorOracleAutomaton::oracleAddLetter ( automaton::DFA<> & oracle, const a supplyFunction.insert( { newState, supplyState } ); } -auto FactorOracleAutomatonLinearString = FactorOracleAutomaton::RegistratorWrapper < automaton::DFA<>, string::LinearString > ( FactorOracleAutomaton::construct ); +auto FactorOracleAutomatonLinearString = FactorOracleAutomaton::RegistratorWrapper < automaton::DFA<>, string::LinearString < > > ( FactorOracleAutomaton::construct ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/FactorOracleAutomaton.h b/alib2algo/src/stringology/exact/FactorOracleAutomaton.h index d72f09681c6c916a3cfb55c63a6127b1f2ab9e82..0be180afba60f20e77042d16a2c1eec76a873c8b 100644 --- a/alib2algo/src/stringology/exact/FactorOracleAutomaton.h +++ b/alib2algo/src/stringology/exact/FactorOracleAutomaton.h @@ -26,7 +26,7 @@ public: */ static automaton::Automaton construct ( const string::String & pattern ); - static automaton::DFA<> construct ( const string::LinearString & pattern ); + static automaton::DFA<> construct ( const string::LinearString < > & pattern ); }; diff --git a/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.cpp b/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.cpp index 5332c673a0405a67a321a60bf1b853c16a9708a0..81c74bf1c083767dff0b12053a09b17c808f2402 100644 --- a/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.cpp +++ b/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.cpp @@ -18,7 +18,7 @@ std::map < alphabet::Symbol, size_t > ReversedBadCharacterShiftTable::bcs ( cons return dispatch ( pattern.getData ( ) ); } -std::map < alphabet::Symbol, size_t > ReversedBadCharacterShiftTable::bcs ( const string::LinearString & pattern ) { +std::map < alphabet::Symbol, size_t > ReversedBadCharacterShiftTable::bcs ( const string::LinearString < > & pattern ) { const std::set < alphabet::Symbol > & alphabet = pattern.getAlphabet ( ); std::map < alphabet::Symbol, size_t > bcs; @@ -33,7 +33,7 @@ std::map < alphabet::Symbol, size_t > ReversedBadCharacterShiftTable::bcs ( cons return bcs; } -auto ReversedBadCharacterShiftTableLinearString = ReversedBadCharacterShiftTable::RegistratorWrapper < std::map < alphabet::Symbol, size_t >, string::LinearString > ( ReversedBadCharacterShiftTable::bcs ); +auto ReversedBadCharacterShiftTableLinearString = ReversedBadCharacterShiftTable::RegistratorWrapper < std::map < alphabet::Symbol, size_t >, string::LinearString < > > ( ReversedBadCharacterShiftTable::bcs ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.h b/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.h index 4bdc76cd2f95d115cdc3f5101f0084b9ad6166fa..c7fd6c5050a151e7c56e718d5c0ba753145f843e 100644 --- a/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.h +++ b/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.h @@ -31,7 +31,7 @@ public: */ static std::map < alphabet::Symbol, size_t > bcs ( const string::String & pattern ); - static std::map < alphabet::Symbol, size_t > bcs ( const string::LinearString & pattern ); + static std::map < alphabet::Symbol, size_t > bcs ( const string::LinearString < > & pattern ); }; diff --git a/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.cpp b/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.cpp index 9e601ca367b569fbd073c619bc6ae33c4f44e9c7..9b00bd4db0eba9f391d31c996eed103b26df9d86 100644 --- a/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.cpp +++ b/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.cpp @@ -21,7 +21,7 @@ std::set < unsigned > ReversedBoyerMooreHorspool::match ( const string::String & return dispatch ( subject.getData ( ), pattern.getData ( ) ); } -std::set < unsigned > ReversedBoyerMooreHorspool::match ( const string::LinearString & string, const string::LinearString & pattern ) { +std::set < unsigned > ReversedBoyerMooreHorspool::match ( const string::LinearString < > & string, const string::LinearString < > & pattern ) { std::set < unsigned > occ; std::map < alphabet::Symbol, size_t > bcs = ReversedBadCharacterShiftTable::bcs ( pattern ); // NOTE: the subjects alphabet must be a subset or equal to the pattern @@ -44,7 +44,7 @@ std::set < unsigned > ReversedBoyerMooreHorspool::match ( const string::LinearSt return occ; } -auto ReversedBoyerMooreHorpoolLinearStringLinearString = ReversedBoyerMooreHorspool::RegistratorWrapper < std::set < unsigned >, string::LinearString, string::LinearString > ( ReversedBoyerMooreHorspool::match ); +auto ReversedBoyerMooreHorpoolLinearStringLinearString = ReversedBoyerMooreHorspool::RegistratorWrapper < std::set < unsigned >, string::LinearString < >, string::LinearString < > > ( ReversedBoyerMooreHorspool::match ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.h b/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.h index 3e06417f4a61424ea200ae24690b8dfd99feea63..e398066892f7e64bb95cae4e33019f39ba30f714 100644 --- a/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.h +++ b/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.h @@ -29,7 +29,7 @@ public: */ static std::set < unsigned > match ( const string::String & subject, const string::String & pattern ); - static std::set < unsigned > match ( const string::LinearString & subject, const string::LinearString & pattern ); + static std::set < unsigned > match ( const string::LinearString < > & subject, const string::LinearString < > & pattern ); }; diff --git a/alib2algo/src/stringology/exact/SuffixAutomaton.cpp b/alib2algo/src/stringology/exact/SuffixAutomaton.cpp index 2b621264538cebf6fa5399de55e063f3b758d1e5..e7e47e426e5583a0a21648ae779e434249793e1f 100644 --- a/alib2algo/src/stringology/exact/SuffixAutomaton.cpp +++ b/alib2algo/src/stringology/exact/SuffixAutomaton.cpp @@ -17,7 +17,7 @@ automaton::Automaton SuffixAutomaton::naiveConstruct ( const string::String & pa return dispatch ( pattern.getData ( ) ); } -automaton::DFA<> SuffixAutomaton::naiveConstruct ( const string::LinearString & pattern ) { +automaton::DFA<> SuffixAutomaton::naiveConstruct ( const string::LinearString < > & pattern ) { automaton::EpsilonNFA < > nfaSuffixAutomaton ( label::labelFrom ( 0 ) ); nfaSuffixAutomaton.setInputAlphabet ( pattern.getAlphabet ( ) ); @@ -52,7 +52,7 @@ automaton::Automaton SuffixAutomaton::construct ( const string::String & pattern return dispatch ( pattern.getData ( ) ); } -automaton::DFA<> SuffixAutomaton::construct ( const string::LinearString & pattern ) { +automaton::DFA<> SuffixAutomaton::construct ( const string::LinearString < > & pattern ) { automaton::DFA<> suffixAutomaton ( label::labelFrom ( 0 ) ); suffixAutomaton.setInputAlphabet ( pattern.getAlphabet ( ) ); @@ -123,7 +123,7 @@ void SuffixAutomaton::suffixAutomatonAddSymbol ( automaton::DFA<> & suffixAutoma lastState = newState; } -auto SuffixAutomatonLinearString = SuffixAutomaton::RegistratorWrapper < automaton::DFA<>, string::LinearString > ( SuffixAutomaton::construct ); +auto SuffixAutomatonLinearString = SuffixAutomaton::RegistratorWrapper < automaton::DFA<>, string::LinearString < > > ( SuffixAutomaton::construct ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/SuffixAutomaton.h b/alib2algo/src/stringology/exact/SuffixAutomaton.h index 1e793cb7d3ecbb9133cdfe456339ad299a6d674f..02a4c2ca9be46eb1e31e53eaeca4caa938f2e0a2 100644 --- a/alib2algo/src/stringology/exact/SuffixAutomaton.h +++ b/alib2algo/src/stringology/exact/SuffixAutomaton.h @@ -27,7 +27,7 @@ public: */ static automaton::Automaton naiveConstruct ( const string::String & pattern ); - static automaton::DFA<> naiveConstruct ( const string::LinearString & pattern ); + static automaton::DFA<> naiveConstruct ( const string::LinearString < > & pattern ); /** * Linear time on-line construction of minimal suffix automaton for given pattern. @@ -35,7 +35,7 @@ public: */ static automaton::Automaton construct ( const string::String & pattern ); - static automaton::DFA<> construct ( const string::LinearString & pattern ); + static automaton::DFA<> construct ( const string::LinearString < > & pattern ); }; diff --git a/alib2algo/src/stringology/indexing/SuffixTrie.cpp b/alib2algo/src/stringology/indexing/SuffixTrie.cpp index dcf497ef2eb1ea1745d835c1ef6a3b238c806189..e2d021b853e71559932ec7d92430929540a88fad 100644 --- a/alib2algo/src/stringology/indexing/SuffixTrie.cpp +++ b/alib2algo/src/stringology/indexing/SuffixTrie.cpp @@ -20,7 +20,7 @@ indexes::SuffixTrieFinalMark SuffixTrie::construct ( const string::String & stri return dispatch ( string.getData ( ) ); } -indexes::SuffixTrieFinalMark SuffixTrie::construct ( const string::LinearString & w ) { +indexes::SuffixTrieFinalMark SuffixTrie::construct ( const string::LinearString < > & w ) { indexes::SuffixTrieFinalMark res ( w.getAlphabet ( ) ); for ( unsigned int i = 0; i < w.getContent ( ).size ( ); i++ ) { @@ -40,7 +40,7 @@ indexes::SuffixTrieFinalMark SuffixTrie::construct ( const string::LinearString return res; } -auto SuffixTrieLinearString = SuffixTrie::RegistratorWrapper < indexes::SuffixTrieFinalMark, string::LinearString > ( SuffixTrie::construct ); +auto SuffixTrieLinearString = SuffixTrie::RegistratorWrapper < indexes::SuffixTrieFinalMark, string::LinearString < > > ( SuffixTrie::construct ); indexes::SuffixTrieTerminatingSymbol SuffixTrie::construct ( const string::LinearStringTerminatingSymbol & w ) { indexes::SuffixTrieTerminatingSymbol res ( w.getAlphabet ( ), w.getTerminatingSymbol ( ) ); diff --git a/alib2algo/src/stringology/indexing/SuffixTrie.h b/alib2algo/src/stringology/indexing/SuffixTrie.h index ca75df33e4d9e2e116ed86a3e5f58782a89feb8d..ce370de9a93c920688a417c3d1393fdfbf223732 100644 --- a/alib2algo/src/stringology/indexing/SuffixTrie.h +++ b/alib2algo/src/stringology/indexing/SuffixTrie.h @@ -34,7 +34,7 @@ public: */ static indexes::SuffixTrieFinalMark construct ( const string::String & string ); - static indexes::SuffixTrieFinalMark construct ( const string::LinearString & string ); + static indexes::SuffixTrieFinalMark construct ( const string::LinearString < > & string ); static indexes::SuffixTrieTerminatingSymbol construct ( const string::LinearStringTerminatingSymbol & string ); }; diff --git a/alib2algo/test-src/grammar/generate/GrammarGenerateUpToLength.cpp b/alib2algo/test-src/grammar/generate/GrammarGenerateUpToLength.cpp index 55189e5ec518186bafe11a76ae5e223502492640..7c1058f32b50b454a46fecb3af2f059a3fc5bba6 100644 --- a/alib2algo/test-src/grammar/generate/GrammarGenerateUpToLength.cpp +++ b/alib2algo/test-src/grammar/generate/GrammarGenerateUpToLength.cpp @@ -33,7 +33,7 @@ void GrammarGenerateUpToLength::testGenerate1() { grammar1.setTerminalAlphabet({a, b}); grammar1.setGeneratesEpsilon(false); - std::set<string::LinearString> strings; + std::set<string::LinearString < >> strings; CPPUNIT_ASSERT(strings == grammar::generate::GenerateUpToLength::generate(grammar1, 5)); } @@ -69,25 +69,25 @@ void GrammarGenerateUpToLength::testGenerate2() { grammar1.addRule({D}, {d}); grammar1.setGeneratesEpsilon(true); - std::set<string::LinearString> strings; - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{c})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{c, c})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{c, c, c})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{d, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{d, d, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{a, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{a, d, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{b, c})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{b, c, c})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{c, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{c, c, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{c, d, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{a, c, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{b, c, d})); - - for(const string::LinearString& str : grammar::generate::GenerateUpToLength::generate(grammar1, 3)) { + std::set<string::LinearString < >> strings; + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{c})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{c, c})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{c, c, c})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{d, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{d, d, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{a, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{a, d, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{b, c})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{b, c, c})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{c, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{c, c, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{c, d, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{a, c, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{b, c, d})); + + for(const string::LinearString < >& str : grammar::generate::GenerateUpToLength::generate(grammar1, 3)) { std::cout << alib::StringDataFactory::toString(string::String(str)) << std::endl; } @@ -123,17 +123,17 @@ void GrammarGenerateUpToLength::testGenerate3() { grammar1.addRule({D}, {d, D}); grammar1.addRule({D}, {d}); - std::set<string::LinearString> strings; - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{d, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{d, d, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{a, d, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{c, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{c, c, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{c, d, d})); - strings.insert(string::LinearString(std::vector<alphabet::Symbol>{b, c, d})); - - for(const string::LinearString& str : grammar::generate::GenerateUpToLength::generate(grammar1, 3)) { + std::set<string::LinearString < >> strings; + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{d, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{d, d, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{a, d, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{c, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{c, c, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{c, d, d})); + strings.insert(string::LinearString < >(std::vector<alphabet::Symbol>{b, c, d})); + + for(const string::LinearString < >& str : grammar::generate::GenerateUpToLength::generate(grammar1, 3)) { std::cout << alib::StringDataFactory::toString(string::String(str)) << std::endl; } diff --git a/alib2algo/test-src/regexp/transform/RegExpDerivationTest.cpp b/alib2algo/test-src/regexp/transform/RegExpDerivationTest.cpp index 9a773011a80345d97d23eda5a95a844b1a238605..520884ec4703d9cb20a111cef83816c598e4f303 100644 --- a/alib2algo/test-src/regexp/transform/RegExpDerivationTest.cpp +++ b/alib2algo/test-src/regexp/transform/RegExpDerivationTest.cpp @@ -33,7 +33,7 @@ void RegExpDerivationTest::testRegExpDerivation() { void RegExpDerivationTest::ExecSingleTest(std::string regexp_str, std::string string_str, std::string result) { regexp::RegExp regexp = alib::StringDataFactory::fromString<regexp::RegExp>(regexp_str); - string::LinearString string = static_cast<const string::LinearString&>(alib::StringDataFactory::fromString<string::String>("\"" + string_str + "\"").getData()); + string::LinearString < > string = static_cast<const string::LinearString < >&>(alib::StringDataFactory::fromString<string::String>("\"" + string_str + "\"").getData()); std::cout << alib::StringDataFactory::toString<regexp::RegExp>(regexp::RegExpDerivation::derivation(regexp, string)) << " == " << std::endl << result << std::endl << std::endl; diff --git a/alib2algo/test-src/regexp/transform/RegExpIntegralTest.cpp b/alib2algo/test-src/regexp/transform/RegExpIntegralTest.cpp index b708f3f82ef2af17ec90ef016951ad5cf99981c7..ea0665f25c29d0fd1adfdda28143c75fe74b6093 100644 --- a/alib2algo/test-src/regexp/transform/RegExpIntegralTest.cpp +++ b/alib2algo/test-src/regexp/transform/RegExpIntegralTest.cpp @@ -25,7 +25,7 @@ void RegExpIntegralTest::testRegExpIntegral() { void RegExpIntegralTest::ExecSingleTest(std::string regexp_str, std::string string_str, std::string result) { regexp::RegExp regexp = alib::StringDataFactory::fromString<regexp::RegExp>(regexp_str); - string::LinearString string = static_cast<const string::LinearString&>(alib::StringDataFactory::fromString<string::String>("\"" + string_str + "\"").getData()); + string::LinearString < > string = static_cast<const string::LinearString < >&>(alib::StringDataFactory::fromString<string::String>("\"" + string_str + "\"").getData()); std::cout << alib::StringDataFactory::toString<regexp::RegExp>(regexp::RegExpIntegral::integral(regexp, string)) << " == " << result << std::endl; diff --git a/alib2algo/test-src/string/compare/compareTest.cpp b/alib2algo/test-src/string/compare/compareTest.cpp index 306f299f49f8cede59bbaeb87fe5dcee805d3edc..18a6924f535c36b42bd5026499f84b188154b80d 100644 --- a/alib2algo/test-src/string/compare/compareTest.cpp +++ b/alib2algo/test-src/string/compare/compareTest.cpp @@ -20,8 +20,8 @@ void compareTest::tearDown() { } void compareTest::testCyclicStringCompareBoolean() { - string::CyclicString str1("alfa"); - string::CyclicString str2("aalf"); + string::CyclicString < > str1("alfa"); + string::CyclicString < > str2("aalf"); str2.extendAlphabet(str1.getAlphabet()); str1.extendAlphabet(str2.getAlphabet()); @@ -29,15 +29,15 @@ void compareTest::testCyclicStringCompareBoolean() { } void compareTest::testCyclicStringCompareInt() { - string::CyclicString str1("alfa"); - string::CyclicString str2("aalf"); + string::CyclicString < > str1("alfa"); + string::CyclicString < > str2("aalf"); str2.extendAlphabet(str1.getAlphabet()); str1.extendAlphabet(str2.getAlphabet()); CPPUNIT_ASSERT(string::naive::ExactCompare::compare(str1, str2) == 0); - string::CyclicString str3("ccbcccb"); - string::CyclicString str4("cbcccbc"); + string::CyclicString < > str3("ccbcccb"); + string::CyclicString < > str4("cbcccbc"); str2.extendAlphabet(str1.getAlphabet()); str1.extendAlphabet(str2.getAlphabet()); @@ -45,16 +45,16 @@ void compareTest::testCyclicStringCompareInt() { } void compareTest::testCompareCyclic() { - string::CyclicString cyclic1({alphabet::symbolFrom(0), alphabet::symbolFrom(1), alphabet::symbolFrom(2)}); - string::CyclicString cyclic2({alphabet::symbolFrom(1), alphabet::symbolFrom(2), alphabet::symbolFrom(0)}); - string::CyclicString cyclic3({alphabet::symbolFrom(2), alphabet::symbolFrom(0), alphabet::symbolFrom(1)}); + string::CyclicString < > cyclic1({alphabet::symbolFrom(0), alphabet::symbolFrom(1), alphabet::symbolFrom(2)}); + string::CyclicString < > cyclic2({alphabet::symbolFrom(1), alphabet::symbolFrom(2), alphabet::symbolFrom(0)}); + string::CyclicString < > cyclic3({alphabet::symbolFrom(2), alphabet::symbolFrom(0), alphabet::symbolFrom(1)}); - string::CyclicString cyclic4({alphabet::symbolFrom(2), alphabet::symbolFrom(1), alphabet::symbolFrom(0)}); + string::CyclicString < > cyclic4({alphabet::symbolFrom(2), alphabet::symbolFrom(1), alphabet::symbolFrom(0)}); - string::CyclicString cyclic1n = string::simplify::NormalizeRotation::normalize(cyclic1); - string::CyclicString cyclic2n = string::simplify::NormalizeRotation::normalize(cyclic2); - string::CyclicString cyclic3n = string::simplify::NormalizeRotation::normalize(cyclic3); - string::CyclicString cyclic4n = string::simplify::NormalizeRotation::normalize(cyclic4); + string::CyclicString < > cyclic1n = string::simplify::NormalizeRotation::normalize(cyclic1); + string::CyclicString < > cyclic2n = string::simplify::NormalizeRotation::normalize(cyclic2); + string::CyclicString < > cyclic3n = string::simplify::NormalizeRotation::normalize(cyclic3); + string::CyclicString < > cyclic4n = string::simplify::NormalizeRotation::normalize(cyclic4); CPPUNIT_ASSERT(cyclic1n == cyclic2n); diff --git a/alib2algo/test-src/stringology/exact/FactorOracleAutomatonTest.cpp b/alib2algo/test-src/stringology/exact/FactorOracleAutomatonTest.cpp index 6ab3780e612f3cc0a9bfe3ab7efd0830cb8b2c8a..3c799c3b505ef040506ed0aba6d00a41786492a7 100644 --- a/alib2algo/test-src/stringology/exact/FactorOracleAutomatonTest.cpp +++ b/alib2algo/test-src/stringology/exact/FactorOracleAutomatonTest.cpp @@ -21,7 +21,7 @@ void FactorOracleAutomatonTest::tearDown ( ) { void FactorOracleAutomatonTest::testFactorOracleConstruction ( ) { - string::LinearString pattern ( "atatac" ); + string::LinearString < > pattern ( "atatac" ); automaton::DFA<> oracle = stringology::exact::FactorOracleAutomaton::construct ( pattern ); diff --git a/alib2algo/test-src/stringology/exact/SuffixAutomatonTest.cpp b/alib2algo/test-src/stringology/exact/SuffixAutomatonTest.cpp index b26ae278c79729c90718038a116b3a12b2857c83..47d90bc1c7445dd994a9ec9e1d4ef77957c15d0e 100644 --- a/alib2algo/test-src/stringology/exact/SuffixAutomatonTest.cpp +++ b/alib2algo/test-src/stringology/exact/SuffixAutomatonTest.cpp @@ -21,7 +21,7 @@ void SuffixAutomatonTest::tearDown ( ) { void SuffixAutomatonTest::testSuffixAutomatonConstruction ( ) { - string::LinearString pattern ( "atatac" ); + string::LinearString < > pattern ( "atatac" ); automaton::DFA<> suffixAutomaton = stringology::exact::SuffixAutomaton::construct ( pattern ); diff --git a/alib2data/src/regexp/RegExp.cpp b/alib2data/src/regexp/RegExp.cpp index 5092fb104496cc9f104b8f4a579c2c07f4e6d249..c56a4684b7c58e9cf2b5a28cc3cfc9ec1f77897d 100644 --- a/alib2data/src/regexp/RegExp.cpp +++ b/alib2data/src/regexp/RegExp.cpp @@ -22,11 +22,11 @@ const std::set < alphabet::Symbol > & RegExp::getAlphabet ( ) const { } regexp::RegExp regexpFrom ( const std::string & string ) { - return regexpFrom ( string::LinearString ( string ) ); + return regexpFrom ( string::LinearString < > ( string ) ); } regexp::RegExp regexpFrom ( const char * string ) { - return regexpFrom ( string::LinearString ( string ) ); + return regexpFrom ( string::LinearString < > ( string ) ); } regexp::RegExp regexpFrom ( std::vector < alphabet::Symbol > string ) { @@ -35,32 +35,24 @@ regexp::RegExp regexpFrom ( std::vector < alphabet::Symbol > string ) { for ( auto & symbol : string ) con.appendElement ( regexp::UnboundedRegExpSymbol ( symbol ) ); - return regexp::RegExp { - regexp::UnboundedRegExp ( std::move ( con ) ) - }; + return regexp::RegExp { regexp::UnboundedRegExp ( std::move ( con ) ) }; } -regexp::RegExp regexpFrom ( string::LinearString string ) { +regexp::RegExp regexpFrom ( string::LinearString < > string ) { regexp::UnboundedRegExpConcatenation con; for ( auto & symbol : string.getContent ( ) ) con.appendElement ( regexp::UnboundedRegExpSymbol ( symbol ) ); - return regexp::RegExp { - regexp::UnboundedRegExp ( std::move ( con ) ) - }; + return regexp::RegExp { regexp::UnboundedRegExp ( std::move ( con ) ) }; } regexp::RegExp regexpFrom ( alphabet::Symbol symbol ) { - return regexp::RegExp { - regexp::UnboundedRegExp ( regexp::UnboundedRegExpSymbol ( std::move ( symbol ) ) ) - }; + return regexp::RegExp { regexp::UnboundedRegExp ( regexp::UnboundedRegExpSymbol ( std::move ( symbol ) ) ) }; } regexp::RegExp regexpFrom ( ) { - return regexp::RegExp { - regexp::UnboundedRegExp ( regexp::UnboundedRegExpEmpty { } ) - }; + return regexp::RegExp { regexp::UnboundedRegExp ( regexp::UnboundedRegExpEmpty { } ) }; } } /* namespace regexp */ diff --git a/alib2data/src/regexp/RegExp.h b/alib2data/src/regexp/RegExp.h index 33f79991f517e542674072e331eb9a8ac1c4f97b..d46a011fcb877164c5b40327807ea4fc4fdf1e4d 100644 --- a/alib2data/src/regexp/RegExp.h +++ b/alib2data/src/regexp/RegExp.h @@ -39,7 +39,7 @@ regexp::RegExp regexpFrom ( const std::string & string ); regexp::RegExp regexpFrom ( const char * string ); -regexp::RegExp regexpFrom ( string::LinearString string ); +regexp::RegExp regexpFrom ( string::LinearString < > string ); regexp::RegExp regexpFrom ( std::vector < alphabet::Symbol > string ); diff --git a/alib2data/src/string/CyclicString.cpp b/alib2data/src/string/CyclicString.cpp index ee48fc2c256d2db49857bca75c1acf4f2f96fa99..3dbbcb0aa9a5deed16437f237b39a7ad2be1845f 100644 --- a/alib2data/src/string/CyclicString.cpp +++ b/alib2data/src/string/CyclicString.cpp @@ -6,117 +6,17 @@ */ #include "CyclicString.h" -#include "Epsilon.h" -#include <exception/CommonException.h> - -#include <sstream> -#include <algorithm> - -#include <sax/FromXMLParserHelper.h> -#include "common/StringFromXMLParser.h" -#include "common/StringToXMLComposer.h" -#include "common/StringAuxiliary.h" #include "String.h" #include <object/Object.h> #include <XmlApi.hpp> #include <cast/CastApi.hpp> -namespace string { - -CyclicString::CyclicString(std::set<alphabet::Symbol> alphabet, std::vector<alphabet::Symbol> data) : std::Components < CyclicString, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ) { - setContent(std::move(data)); -} - -CyclicString::CyclicString() : CyclicString ( std::set < alphabet::Symbol > ( ), std::vector < alphabet::Symbol > ( ) ) { -} - -CyclicString::CyclicString(std::vector<alphabet::Symbol> data) : CyclicString ( std::set < alphabet::Symbol> ( data.begin(), data.end() ), data ) { -} - -CyclicString::CyclicString(const std::string& string) : CyclicString ( StringAuxiliary::toInternal ( string ) ) { -} - -CyclicString::CyclicString(const char* string) : CyclicString((std::string) string) { -} - -CyclicString::CyclicString(const Epsilon < > & epsilon) : CyclicString ( epsilon.getAlphabet( ), std::vector < alphabet::Symbol > ( ) ) { -} - -StringBase* CyclicString::clone() const { - return new CyclicString(*this); -} - -StringBase* CyclicString::plunder() && { - return new CyclicString(std::move(*this)); -} - -const std::vector<alphabet::Symbol>& CyclicString::getContent() const { - return this->m_Data; -} - -//serves as both move and copy content setter -void CyclicString::setContent(std::vector<alphabet::Symbol> data) { - std::set<alphabet::Symbol> minimalAlphabet(data.begin(), data.end()); - std::set<alphabet::Symbol> unknownSymbols; - std::set_difference(minimalAlphabet.begin(), minimalAlphabet.end(), getAlphabet().begin(), getAlphabet().end(), std::inserter(unknownSymbols, unknownSymbols.end())); - - if(unknownSymbols.size() > 0) - throw exception::CommonException("Input symbols not in the alphabet."); - - m_Data = std::move(data); -} - -bool CyclicString::isEmpty() const { - return this->m_Data.size() == 0; -} - -int CyclicString::compare(const CyclicString& other) const { - auto first = std::tie ( m_Data, getAlphabet ( ) ); - auto second = std::tie ( other.m_Data, other.getAlphabet ( ) ); - - std::compare<decltype(first)> comp; - return comp(first, second); -} - -void CyclicString::operator >>(std::ostream& out) const { - out << "(CyclicString "; - for(const alphabet::Symbol& symbol : this->m_Data) - out << symbol; - out << ")"; -} - -CyclicString::operator std::string () const { - std::stringstream ss; - ss << "<"; - for(const alphabet::Symbol& symbol : this->m_Data) - ss << symbol; - ss << ">"; - return std::move(ss).str(); -} - -CyclicString CyclicString::parse(std::deque<sax::Token>::iterator& input) { - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, CyclicString::getXmlTagName()); - std::set<alphabet::Symbol> alphabet = StringFromXMLParser::parseAlphabet < alphabet::Symbol > (input); - std::vector<alphabet::Symbol> content = StringFromXMLParser::parseContent < alphabet::Symbol > (input); - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, CyclicString::getXmlTagName()); - return CyclicString ( std::move ( alphabet ), std::move ( content ) ); -} - -void CyclicString::compose(std::deque<sax::Token>& out) const { - out.emplace_back(CyclicString::getXmlTagName(), sax::Token::TokenType::START_ELEMENT); - StringToXMLComposer::compose(out, getAlphabet()); - StringToXMLComposer::compose(out, m_Data); - out.emplace_back(CyclicString::getXmlTagName(), sax::Token::TokenType::END_ELEMENT); -} - -} /* namespace string */ - namespace alib { -auto cyclicStringParserRegister = xmlApi<string::String>::ParserRegister<string::CyclicString>(); -auto cyclicStringParserRegister2 = xmlApi<alib::Object>::ParserRegister<string::CyclicString>(); +auto cyclicStringParserRegister = xmlApi<string::String>::ParserRegister<string::CyclicString < > >(); +auto cyclicStringParserRegister2 = xmlApi<alib::Object>::ParserRegister<string::CyclicString < > >(); -auto CyclicStringFromEpsilon = castApi::CastRegister<string::CyclicString, string::Epsilon < > >(); -auto CyclicStringCastBinder = castApi::CastPoolStringBinder<string::CyclicString>(string::CyclicString::getXmlTagName()); +auto CyclicStringFromEpsilon = castApi::CastRegister<string::CyclicString < >, string::Epsilon < > >(); +auto CyclicStringCastBinder = castApi::CastPoolStringBinder<string::CyclicString < > >(string::CyclicString < >::getXmlTagName()); } /* namespace alib */ diff --git a/alib2data/src/string/CyclicString.h b/alib2data/src/string/CyclicString.h index cc9810b1350efeaf69dd647963287cbd08582bdd..0afd702dc412cab837058df89a5401de83465894 100644 --- a/alib2data/src/string/CyclicString.h +++ b/alib2data/src/string/CyclicString.h @@ -8,13 +8,22 @@ #ifndef CYCLIC_STRING_H_ #define CYCLIC_STRING_H_ -#include "StringBase.h" #include <set> #include <vector> +#include <sstream> +#include <algorithm> -#include "StringFeatures.h" -#include "../alphabet/Symbol.h" #include <core/components.hpp> +#include <sax/FromXMLParserHelper.h> + +#include "StringBase.h" +#include "StringFeatures.h" +#include "common/StringFromXMLParser.h" +#include "common/StringToXMLComposer.h" +#include "common/StringAuxiliary.h" +#include <exception/CommonException.h> + +#include "Epsilon.h" namespace string { @@ -24,13 +33,14 @@ class GeneralAlphabet; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of CyclicStringElement. */ -class CyclicString : public StringBase, public std::Components < CyclicString, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > { - std::vector < alphabet::Symbol > m_Data; +template < class SymbolType > +class CyclicString : public StringBase, public std::Components < CyclicString < SymbolType >, SymbolType, std::tuple < GeneralAlphabet >, std::tuple < > > { + std::vector < SymbolType > m_Data; public: explicit CyclicString ( ); - explicit CyclicString ( std::set < alphabet::Symbol > alphabet, std::vector < alphabet::Symbol > data ); - explicit CyclicString ( std::vector < alphabet::Symbol > data ); + explicit CyclicString ( std::set < SymbolType > alphabet, std::vector < SymbolType > data ); + explicit CyclicString ( std::vector < SymbolType > data ); explicit CyclicString ( const std::string & string ); explicit CyclicString ( const char * string ); explicit CyclicString ( const Epsilon < > & epsilon ); @@ -38,20 +48,20 @@ public: virtual StringBase * clone ( ) const; virtual StringBase * plunder ( ) &&; - virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const { - return accessComponent < GeneralAlphabet > ( ).get ( ); + virtual const std::set < SymbolType > & getAlphabet ( ) const { + return this->template accessComponent < GeneralAlphabet > ( ).get ( ); } - void extendAlphabet ( const std::set < alphabet::Symbol > & symbols ) { - accessComponent < GeneralAlphabet > ( ).add( symbols ); + void extendAlphabet ( const std::set < SymbolType > & symbols ) { + this->template accessComponent < GeneralAlphabet > ( ).add( symbols ); } /** * @return List of symbols forming string (const version). */ - const std::vector < alphabet::Symbol > & getContent ( ) const; + const std::vector < SymbolType > & getContent ( ) const; - void setContent ( std::vector < alphabet::Symbol > data ); + void setContent ( std::vector < SymbolType > data ); /** * @return true if string is an empty word (vector length is 0) @@ -81,23 +91,125 @@ public: void compose ( std::deque < sax::Token > & out ) const; }; +template < class SymbolType > +CyclicString < SymbolType >::CyclicString(std::set<SymbolType> alphabet, std::vector<SymbolType> data) : std::Components < CyclicString < SymbolType >, SymbolType, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ) { + setContent(std::move(data)); +} + +template < class SymbolType > +CyclicString < SymbolType >::CyclicString() : CyclicString ( std::set < SymbolType > ( ), std::vector < SymbolType > ( ) ) { +} + +template < class SymbolType > +CyclicString < SymbolType >::CyclicString(std::vector<SymbolType> data) : CyclicString ( std::set < SymbolType> ( data.begin(), data.end() ), data ) { +} + +template < class SymbolType > +CyclicString < SymbolType >::CyclicString(const std::string& string) : CyclicString ( StringAuxiliary::toInternal ( string ) ) { +} + +template < class SymbolType > +CyclicString < SymbolType >::CyclicString(const char* string) : CyclicString((std::string) string) { +} + +template < class SymbolType > +CyclicString < SymbolType >::CyclicString(const Epsilon < > & epsilon) : CyclicString ( epsilon.getAlphabet( ), std::vector < SymbolType > ( ) ) { +} + +template < class SymbolType > +StringBase* CyclicString < SymbolType >::clone() const { + return new CyclicString(*this); +} + +template < class SymbolType > +StringBase* CyclicString < SymbolType >::plunder() && { + return new CyclicString(std::move(*this)); +} + +template < class SymbolType > +const std::vector<SymbolType>& CyclicString < SymbolType >::getContent() const { + return this->m_Data; +} + +//serves as both move and copy content setter +template < class SymbolType > +void CyclicString < SymbolType >::setContent(std::vector<SymbolType> data) { + std::set<SymbolType> minimalAlphabet(data.begin(), data.end()); + std::set<SymbolType> unknownSymbols; + std::set_difference(minimalAlphabet.begin(), minimalAlphabet.end(), getAlphabet().begin(), getAlphabet().end(), std::inserter(unknownSymbols, unknownSymbols.end())); + + if(unknownSymbols.size() > 0) + throw exception::CommonException("Input symbols not in the alphabet."); + + m_Data = std::move(data); +} + +template < class SymbolType > +bool CyclicString < SymbolType >::isEmpty() const { + return this->m_Data.size() == 0; +} + +template < class SymbolType > +int CyclicString < SymbolType >::compare(const CyclicString& other) const { + auto first = std::tie ( m_Data, getAlphabet ( ) ); + auto second = std::tie ( other.m_Data, other.getAlphabet ( ) ); + + std::compare<decltype(first)> comp; + return comp(first, second); +} + +template < class SymbolType > +void CyclicString < SymbolType >::operator >>(std::ostream& out) const { + out << "(CyclicString "; + for(const SymbolType& symbol : this->m_Data) + out << symbol; + out << ")"; +} + +template < class SymbolType > +CyclicString < SymbolType >::operator std::string () const { + std::stringstream ss; + ss << "<"; + for(const SymbolType& symbol : this->m_Data) + ss << symbol; + ss << ">"; + return std::move(ss).str(); +} + +template < class SymbolType > +CyclicString < SymbolType > CyclicString < SymbolType >::parse(std::deque<sax::Token>::iterator& input) { + sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, CyclicString < >::getXmlTagName()); + std::set<SymbolType> alphabet = StringFromXMLParser::parseAlphabet < SymbolType > (input); + std::vector<SymbolType> content = StringFromXMLParser::parseContent < SymbolType > (input); + sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, CyclicString < >::getXmlTagName()); + return CyclicString < SymbolType > ( std::move ( alphabet ), std::move ( content ) ); +} + +template < class SymbolType > +void CyclicString < SymbolType >::compose(std::deque<sax::Token>& out) const { + out.emplace_back(CyclicString::getXmlTagName(), sax::Token::TokenType::START_ELEMENT); + StringToXMLComposer::compose(out, getAlphabet()); + StringToXMLComposer::compose(out, m_Data); + out.emplace_back(CyclicString::getXmlTagName(), sax::Token::TokenType::END_ELEMENT); +} + } /* namespace string */ namespace std { -template < > -class ComponentConstraint< ::string::CyclicString, alphabet::Symbol, ::string::GeneralAlphabet > { +template < class SymbolType > +class ComponentConstraint< ::string::CyclicString < SymbolType >, SymbolType, ::string::GeneralAlphabet > { public: - static bool used ( const ::string::CyclicString & string, const alphabet::Symbol & symbol ) { - const std::vector<alphabet::Symbol>& content = string.getContent ( ); + static bool used ( const ::string::CyclicString < SymbolType > & string, const SymbolType & symbol ) { + const std::vector<SymbolType>& content = string.getContent ( ); return std::find(content.begin(), content.end(), symbol) != content.end(); } - static bool available ( const ::string::CyclicString &, const alphabet::Symbol & ) { + static bool available ( const ::string::CyclicString < SymbolType > &, const SymbolType & ) { return true; } - static void valid ( const ::string::CyclicString &, const alphabet::Symbol & ) { + static void valid ( const ::string::CyclicString < SymbolType > &, const SymbolType & ) { } }; diff --git a/alib2data/src/string/LinearString.cpp b/alib2data/src/string/LinearString.cpp index 74e4a39e90ccdb3a066fb55141586d0e3dc32303..2abfe6aaea8d970815708da740e919fe2759676f 100644 --- a/alib2data/src/string/LinearString.cpp +++ b/alib2data/src/string/LinearString.cpp @@ -6,165 +6,25 @@ */ #include "LinearString.h" -#include "Epsilon.h" -#include "../tree/ranked/PrefixRankedTree.h" -#include "../tree/ranked/PrefixRankedPattern.h" -#include "../tree/ranked/PrefixRankedNonlinearPattern.h" -#include "../tree/ranked/PrefixRankedBarTree.h" -#include "../tree/ranked/PrefixRankedBarPattern.h" -#include "../tree/ranked/PrefixRankedBarNonlinearPattern.h" -#include "../tree/unranked/PrefixBarTree.h" -#include "../tree/common/TreeAuxiliary.h" -#include <exception/CommonException.h> -#include <sstream> -#include <algorithm> - -#include <sax/FromXMLParserHelper.h> -#include "common/StringFromXMLParser.h" -#include "common/StringToXMLComposer.h" -#include "common/StringAuxiliary.h" #include "String.h" #include <object/Object.h> #include <XmlApi.hpp> #include <cast/CastApi.hpp> -namespace string { - -LinearString::LinearString(std::set<alphabet::Symbol> alphabet, std::vector<alphabet::Symbol> data) : std::Components < LinearString, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ) { - setContent(std::move(data)); -} - -LinearString::LinearString() : LinearString ( std::set < alphabet::Symbol > ( ), std::vector < alphabet::Symbol > ( ) ) { -} - -LinearString::LinearString(std::vector<alphabet::Symbol> data) : LinearString ( std::set < alphabet::Symbol> ( data.begin(), data.end() ), data ) { -} - -LinearString::LinearString(const std::string& string) : LinearString ( StringAuxiliary::toInternal ( string ) ) { -} - -LinearString::LinearString(const char* string) : LinearString((std::string) string) { -} - -LinearString::LinearString(const Epsilon < > & epsilon) : LinearString ( epsilon.getAlphabet( ), std::vector < alphabet::Symbol > ( ) ) { -} - -LinearString::LinearString ( const tree::PrefixRankedTree & tree ) : LinearString ( StringAuxiliary::wrapSymbols ( tree.getAlphabet ( ) ), StringAuxiliary::wrapSymbols ( tree.getContent ( ) ) ) { -} - -LinearString::LinearString ( const tree::PrefixRankedPattern & tree ) : LinearString ( StringAuxiliary::wrapSymbols ( tree.getAlphabet ( ) ), StringAuxiliary::wrapSymbols ( tree.getContent ( ) ) ) { -} - -LinearString::LinearString ( const tree::PrefixRankedNonlinearPattern & tree ) : LinearString ( StringAuxiliary::wrapSymbols ( tree.getAlphabet ( ) ), StringAuxiliary::wrapSymbols ( tree.getContent ( ) ) ) { -} - -LinearString::LinearString ( const tree::PrefixRankedBarTree & tree ) : LinearString ( StringAuxiliary::wrapSymbols ( tree.getAlphabet ( ) ), StringAuxiliary::wrapSymbols ( tree.getContent ( ) ) ) { -} - -LinearString::LinearString ( const tree::PrefixRankedBarPattern & tree ) : LinearString ( StringAuxiliary::wrapSymbols ( tree.getAlphabet ( ) ), StringAuxiliary::wrapSymbols ( tree.getContent ( ) ) ) { -} - -LinearString::LinearString ( const tree::PrefixRankedBarNonlinearPattern & tree ) : LinearString ( StringAuxiliary::wrapSymbols ( tree.getAlphabet ( ) ), StringAuxiliary::wrapSymbols ( tree.getContent ( ) ) ) { -} - -LinearString::LinearString ( const tree::PrefixBarTree & tree ) : LinearString ( tree.getAlphabet ( ), tree.getContent ( ) ) { -} - -StringBase * LinearString::clone ( ) const { - return new LinearString ( * this ); -} - -StringBase * LinearString::plunder ( ) && { - return new LinearString ( std::move ( * this ) ); -} - -void LinearString::appendSymbol ( alphabet::Symbol symbol ) { - if ( getAlphabet().count ( symbol ) == 0 ) - throw exception::CommonException ( "Input symbol \"" + std::to_string ( symbol ) + "\" not in the alphabet." ); - - m_Data.push_back ( std::move ( symbol ) ); -} - -const std::vector < alphabet::Symbol > & LinearString::getContent ( ) const { - return this->m_Data; -} - -void LinearString::setContent ( std::vector < alphabet::Symbol > data ) { - std::set < alphabet::Symbol > minimalAlphabet ( data.begin ( ), data.end ( ) ); - std::set < alphabet::Symbol > unknownSymbols; - std::set_difference ( minimalAlphabet.begin ( ), minimalAlphabet.end ( ), getAlphabet().begin ( ), getAlphabet().end ( ), std::inserter ( unknownSymbols, unknownSymbols.end ( ) ) ); - - if ( unknownSymbols.size ( ) > 0 ) - throw exception::CommonException ( "Input symbols not in the alphabet." ); - - this->m_Data = std::move ( data ); -} - -bool LinearString::isEmpty ( ) const { - return this->m_Data.size ( ) == 0; -} - -int LinearString::compare ( const LinearString & other ) const { - auto first = std::tie ( m_Data, getAlphabet() ); - auto second = std::tie ( other.m_Data, other.getAlphabet() ); - - std::compare < decltype ( first ) > comp; - - return comp ( first, second ); -} - -void LinearString::operator >>( std::ostream & out ) const { - out << "(LinearString "; - - for ( const alphabet::Symbol & symbol : this->m_Data ) - out << symbol; - - out << ")"; -} - -LinearString::operator std::string ( ) const { - std::stringstream ss; - ss << "\""; - - for ( const alphabet::Symbol & symbol : this->m_Data ) - ss << symbol; - - ss << "\""; - return std::move ( ss ).str ( ); -} - -LinearString LinearString::parse ( std::deque < sax::Token >::iterator & input ) { - sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, LinearString::getXmlTagName() ); - std::set < alphabet::Symbol > alphabet = StringFromXMLParser::parseAlphabet < alphabet::Symbol > ( input ); - std::vector < alphabet::Symbol > content = StringFromXMLParser::parseContent < alphabet::Symbol > ( input ); - sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, LinearString::getXmlTagName() ); - - return LinearString ( alphabet, content ); -} - -void LinearString::compose ( std::deque < sax::Token > & out ) const { - out.emplace_back ( LinearString::getXmlTagName(), sax::Token::TokenType::START_ELEMENT ); - StringToXMLComposer::compose ( out, getAlphabet() ); - StringToXMLComposer::compose ( out, m_Data ); - out.emplace_back ( LinearString::getXmlTagName(), sax::Token::TokenType::END_ELEMENT ); -} - -} /* namespace string */ - namespace alib { -auto linearStringParserRegister = xmlApi < string::String >::ParserRegister < string::LinearString > (); -auto linearStringParserRegister2 = xmlApi < alib::Object >::ParserRegister < string::LinearString > (); - -auto LinearStringFromEpsilon = castApi::CastRegister < string::LinearString, string::Epsilon < > > ( ); -auto LinearStringFromPrefixRankedTree = castApi::CastRegister < string::LinearString, tree::PrefixRankedTree > ( ); -auto LinearStringFromPrefixRankedPattern = castApi::CastRegister < string::LinearString, tree::PrefixRankedPattern > ( ); -auto LinearStringFromPrefixRankedNonlinearPattern = castApi::CastRegister < string::LinearString, tree::PrefixRankedNonlinearPattern > ( ); -auto LinearStringFromPrefixRankedBarTree = castApi::CastRegister < string::LinearString, tree::PrefixRankedBarTree > ( ); -auto LinearStringFromPrefixRankedBarPattern = castApi::CastRegister < string::LinearString, tree::PrefixRankedBarPattern > ( ); -auto LinearStringFromPrefixRankedBarNonlinearPattern = castApi::CastRegister < string::LinearString, tree::PrefixRankedBarNonlinearPattern > ( ); -auto LinearStringFromPrefixBarTree = castApi::CastRegister < string::LinearString, tree::PrefixBarTree > ( ); -auto LinearStringCastBinder = castApi::CastPoolStringBinder < string::LinearString > ( string::LinearString::getXmlTagName() ); +auto linearStringParserRegister = xmlApi < string::String >::ParserRegister < string::LinearString < > > (); +auto linearStringParserRegister2 = xmlApi < alib::Object >::ParserRegister < string::LinearString < > > (); + +auto LinearStringFromEpsilon = castApi::CastRegister < string::LinearString < >, string::Epsilon < > > ( ); +auto LinearStringFromPrefixRankedTree = castApi::CastRegister < string::LinearString < >, tree::PrefixRankedTree > ( ); +auto LinearStringFromPrefixRankedPattern = castApi::CastRegister < string::LinearString < >, tree::PrefixRankedPattern > ( ); +auto LinearStringFromPrefixRankedNonlinearPattern = castApi::CastRegister < string::LinearString < >, tree::PrefixRankedNonlinearPattern > ( ); +auto LinearStringFromPrefixRankedBarTree = castApi::CastRegister < string::LinearString < >, tree::PrefixRankedBarTree > ( ); +auto LinearStringFromPrefixRankedBarPattern = castApi::CastRegister < string::LinearString < >, tree::PrefixRankedBarPattern > ( ); +auto LinearStringFromPrefixRankedBarNonlinearPattern = castApi::CastRegister < string::LinearString < >, tree::PrefixRankedBarNonlinearPattern > ( ); +auto LinearStringFromPrefixBarTree = castApi::CastRegister < string::LinearString < >, tree::PrefixBarTree > ( ); +auto LinearStringCastBinder = castApi::CastPoolStringBinder < string::LinearString < > > ( string::LinearString < >::getXmlTagName() ); } /* namespace alib */ diff --git a/alib2data/src/string/LinearString.h b/alib2data/src/string/LinearString.h index ea89ac8b4520abbb3a3b42d533cd3fc69f5e51d7..98d14ca29843cda990a518f938a20ddad986f8cc 100644 --- a/alib2data/src/string/LinearString.h +++ b/alib2data/src/string/LinearString.h @@ -8,14 +8,31 @@ #ifndef LINEAR_STRING_H_ #define LINEAR_STRING_H_ -#include "StringBase.h" #include <set> #include <vector> +#include <sstream> +#include <algorithm> -#include "StringFeatures.h" -#include "../alphabet/Symbol.h" +#include <sax/FromXMLParserHelper.h> #include <core/components.hpp> +#include "StringBase.h" +#include "StringFeatures.h" +#include "common/StringFromXMLParser.h" +#include "common/StringToXMLComposer.h" +#include "common/StringAuxiliary.h" +#include <exception/CommonException.h> + +#include "Epsilon.h" +#include "../tree/ranked/PrefixRankedTree.h" +#include "../tree/ranked/PrefixRankedPattern.h" +#include "../tree/ranked/PrefixRankedNonlinearPattern.h" +#include "../tree/ranked/PrefixRankedBarTree.h" +#include "../tree/ranked/PrefixRankedBarPattern.h" +#include "../tree/ranked/PrefixRankedBarNonlinearPattern.h" +#include "../tree/unranked/PrefixBarTree.h" +#include "../tree/common/TreeAuxiliary.h" + namespace tree { class PrefixRankedTree; @@ -36,8 +53,9 @@ class GeneralAlphabet; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of LinearStringElement. */ -class LinearString : public StringBase, public std::Components < LinearString, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > { - std::vector < alphabet::Symbol > m_Data; +template < class SymbolType > +class LinearString : public StringBase, public std::Components < LinearString < SymbolType >, SymbolType, std::tuple < GeneralAlphabet >, std::tuple < > > { + std::vector < SymbolType > m_Data; public: explicit LinearString ( ); @@ -48,8 +66,8 @@ public: explicit LinearString ( const tree::PrefixRankedBarPattern & tree ); explicit LinearString ( const tree::PrefixRankedBarNonlinearPattern & tree ); explicit LinearString ( const tree::PrefixBarTree & tree ); - explicit LinearString ( std::set < alphabet::Symbol > alphabet, std::vector < alphabet::Symbol > data ); - explicit LinearString ( std::vector < alphabet::Symbol > data ); + explicit LinearString ( std::set < SymbolType > alphabet, std::vector < SymbolType > data ); + explicit LinearString ( std::vector < SymbolType > data ); explicit LinearString ( const std::string & string ); explicit LinearString ( const char * string ); explicit LinearString ( const Epsilon < > & epsilon ); @@ -57,25 +75,25 @@ public: virtual StringBase * clone ( ) const; virtual StringBase * plunder ( ) &&; - virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const { - return accessComponent < GeneralAlphabet > ( ).get ( ); + virtual const std::set < SymbolType > & getAlphabet ( ) const { + return this->template accessComponent < GeneralAlphabet > ( ).get ( ); } - void extendAlphabet ( const std::set < alphabet::Symbol > & symbols ) { - accessComponent < GeneralAlphabet > ( ).add( symbols ); + void extendAlphabet ( const std::set < SymbolType > & symbols ) { + this->template accessComponent < GeneralAlphabet > ( ).add( symbols ); } /** * @param element to append */ - void appendSymbol ( alphabet::Symbol symbol ); + void appendSymbol ( SymbolType symbol ); /** * @return List of symbols forming string (const version). */ - const std::vector < alphabet::Symbol > & getContent ( ) const; + const std::vector < SymbolType > & getContent ( ) const; - void setContent ( std::vector < alphabet::Symbol > data ); + void setContent ( std::vector < SymbolType > data ); /** * @return true if string is an empty word (vector length is 0) @@ -105,23 +123,166 @@ public: void compose ( std::deque < sax::Token > & out ) const; }; +template < class SymbolType > +LinearString < SymbolType >::LinearString(std::set<SymbolType> alphabet, std::vector<SymbolType> data) : std::Components < LinearString < SymbolType >, SymbolType, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ) { + setContent(std::move(data)); +} + +template < class SymbolType > +LinearString < SymbolType >::LinearString() : LinearString ( std::set < SymbolType > ( ), std::vector < SymbolType > ( ) ) { +} + +template < class SymbolType > +LinearString < SymbolType >::LinearString(std::vector<SymbolType> data) : LinearString ( std::set < SymbolType> ( data.begin(), data.end() ), data ) { +} + +template < class SymbolType > +LinearString < SymbolType >::LinearString(const std::string& string) : LinearString ( StringAuxiliary::toInternal ( string ) ) { +} + +template < class SymbolType > +LinearString < SymbolType >::LinearString(const char* string) : LinearString((std::string) string) { +} + +template < class SymbolType > +LinearString < SymbolType >::LinearString(const Epsilon < > & epsilon) : LinearString ( epsilon.getAlphabet( ), std::vector < SymbolType > ( ) ) { +} + +template < class SymbolType > +LinearString < SymbolType >::LinearString ( const tree::PrefixRankedTree & tree ) : LinearString ( StringAuxiliary::wrapSymbols ( tree.getAlphabet ( ) ), StringAuxiliary::wrapSymbols ( tree.getContent ( ) ) ) { +} + +template < class SymbolType > +LinearString < SymbolType >::LinearString ( const tree::PrefixRankedPattern & tree ) : LinearString ( StringAuxiliary::wrapSymbols ( tree.getAlphabet ( ) ), StringAuxiliary::wrapSymbols ( tree.getContent ( ) ) ) { +} + +template < class SymbolType > +LinearString < SymbolType >::LinearString ( const tree::PrefixRankedNonlinearPattern & tree ) : LinearString ( StringAuxiliary::wrapSymbols ( tree.getAlphabet ( ) ), StringAuxiliary::wrapSymbols ( tree.getContent ( ) ) ) { +} + +template < class SymbolType > +LinearString < SymbolType >::LinearString ( const tree::PrefixRankedBarTree & tree ) : LinearString ( StringAuxiliary::wrapSymbols ( tree.getAlphabet ( ) ), StringAuxiliary::wrapSymbols ( tree.getContent ( ) ) ) { +} + +template < class SymbolType > +LinearString < SymbolType >::LinearString ( const tree::PrefixRankedBarPattern & tree ) : LinearString ( StringAuxiliary::wrapSymbols ( tree.getAlphabet ( ) ), StringAuxiliary::wrapSymbols ( tree.getContent ( ) ) ) { +} + +template < class SymbolType > +LinearString < SymbolType >::LinearString ( const tree::PrefixRankedBarNonlinearPattern & tree ) : LinearString ( StringAuxiliary::wrapSymbols ( tree.getAlphabet ( ) ), StringAuxiliary::wrapSymbols ( tree.getContent ( ) ) ) { +} + +template < class SymbolType > +LinearString < SymbolType >::LinearString ( const tree::PrefixBarTree & tree ) : LinearString ( tree.getAlphabet ( ), tree.getContent ( ) ) { +} + +template < class SymbolType > +StringBase * LinearString < SymbolType >::clone ( ) const { + return new LinearString ( * this ); +} + +template < class SymbolType > +StringBase * LinearString < SymbolType >::plunder ( ) && { + return new LinearString ( std::move ( * this ) ); +} + +template < class SymbolType > +void LinearString < SymbolType >::appendSymbol ( SymbolType symbol ) { + if ( getAlphabet().count ( symbol ) == 0 ) + throw exception::CommonException ( "Input symbol \"" + std::to_string ( symbol ) + "\" not in the alphabet." ); + + m_Data.push_back ( std::move ( symbol ) ); +} + +template < class SymbolType > +const std::vector < SymbolType > & LinearString < SymbolType >::getContent ( ) const { + return this->m_Data; +} + +template < class SymbolType > +void LinearString < SymbolType >::setContent ( std::vector < SymbolType > data ) { + std::set < SymbolType > minimalAlphabet ( data.begin ( ), data.end ( ) ); + std::set < SymbolType > unknownSymbols; + std::set_difference ( minimalAlphabet.begin ( ), minimalAlphabet.end ( ), getAlphabet().begin ( ), getAlphabet().end ( ), std::inserter ( unknownSymbols, unknownSymbols.end ( ) ) ); + + if ( unknownSymbols.size ( ) > 0 ) + throw exception::CommonException ( "Input symbols not in the alphabet." ); + + this->m_Data = std::move ( data ); +} + +template < class SymbolType > +bool LinearString < SymbolType >::isEmpty ( ) const { + return this->m_Data.size ( ) == 0; +} + +template < class SymbolType > +int LinearString < SymbolType >::compare ( const LinearString & other ) const { + auto first = std::tie ( m_Data, getAlphabet() ); + auto second = std::tie ( other.m_Data, other.getAlphabet() ); + + std::compare < decltype ( first ) > comp; + + return comp ( first, second ); +} + +template < class SymbolType > +void LinearString < SymbolType >::operator >>( std::ostream & out ) const { + out << "(LinearString "; + + for ( const SymbolType & symbol : this->m_Data ) + out << symbol; + + out << ")"; +} + +template < class SymbolType > +LinearString < SymbolType >::operator std::string ( ) const { + std::stringstream ss; + ss << "\""; + + for ( const SymbolType & symbol : this->m_Data ) + ss << symbol; + + ss << "\""; + return std::move ( ss ).str ( ); +} + +template < class SymbolType > +LinearString < SymbolType > LinearString < SymbolType >::parse ( std::deque < sax::Token >::iterator & input ) { + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, LinearString::getXmlTagName() ); + std::set < SymbolType > alphabet = StringFromXMLParser::parseAlphabet < SymbolType > ( input ); + std::vector < SymbolType > content = StringFromXMLParser::parseContent < SymbolType > ( input ); + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, LinearString::getXmlTagName() ); + + return LinearString < SymbolType > ( alphabet, content ); +} + +template < class SymbolType > +void LinearString < SymbolType >::compose ( std::deque < sax::Token > & out ) const { + out.emplace_back ( LinearString::getXmlTagName(), sax::Token::TokenType::START_ELEMENT ); + StringToXMLComposer::compose ( out, getAlphabet() ); + StringToXMLComposer::compose ( out, m_Data ); + out.emplace_back ( LinearString::getXmlTagName(), sax::Token::TokenType::END_ELEMENT ); +} + } /* namespace string */ namespace std { -template < > -class ComponentConstraint< ::string::LinearString, alphabet::Symbol, ::string::GeneralAlphabet > { +template < class SymbolType > +class ComponentConstraint< ::string::LinearString < SymbolType >, SymbolType, ::string::GeneralAlphabet > { public: - static bool used ( const ::string::LinearString & string, const alphabet::Symbol & symbol ) { - const std::vector<alphabet::Symbol>& content = string.getContent ( ); + static bool used ( const ::string::LinearString < SymbolType > & string, const SymbolType & symbol ) { + const std::vector<SymbolType>& content = string.getContent ( ); return std::find(content.begin(), content.end(), symbol) != content.end(); } - static bool available ( const ::string::LinearString &, const alphabet::Symbol & ) { + static bool available ( const ::string::LinearString < SymbolType > &, const SymbolType & ) { return true; } - static void valid ( const ::string::LinearString &, const alphabet::Symbol & ) { + static void valid ( const ::string::LinearString < SymbolType > &, const SymbolType & ) { } }; diff --git a/alib2data/src/string/LinearStringTerminatingSymbol.cpp b/alib2data/src/string/LinearStringTerminatingSymbol.cpp index 034992a55a9c4d563587d8c39a7082d441825544..c8b24c956e43d78799bd655e5e1fe5e25c14a456 100644 --- a/alib2data/src/string/LinearStringTerminatingSymbol.cpp +++ b/alib2data/src/string/LinearStringTerminatingSymbol.cpp @@ -32,7 +32,7 @@ LinearStringTerminatingSymbol::LinearStringTerminatingSymbol ( alphabet::Symbol LinearStringTerminatingSymbol::LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol, std::vector < alphabet::Symbol > data ) : LinearStringTerminatingSymbol ( std::set < alphabet::Symbol > ( data.begin ( ), data.end ( ) ) + std::set < alphabet::Symbol > { terminatingSymbol }, terminatingSymbol, data ) { } -LinearStringTerminatingSymbol::LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol, const LinearString & string ) : LinearStringTerminatingSymbol ( string.getAlphabet( ), std::move ( terminatingSymbol ), string.getContent ( ) ) { +LinearStringTerminatingSymbol::LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol, const LinearString < > & string ) : LinearStringTerminatingSymbol ( string.getAlphabet( ), std::move ( terminatingSymbol ), string.getContent ( ) ) { } StringBase * LinearStringTerminatingSymbol::clone ( ) const { diff --git a/alib2data/src/string/LinearStringTerminatingSymbol.h b/alib2data/src/string/LinearStringTerminatingSymbol.h index 99376d97d25684c12aa66a872363c4feaa76957e..b8046979ab28d4a5d6eb3f1d90e71d9f3bac497b 100644 --- a/alib2data/src/string/LinearStringTerminatingSymbol.h +++ b/alib2data/src/string/LinearStringTerminatingSymbol.h @@ -8,17 +8,18 @@ #ifndef LINEAR_STRING_TERMINATING_SYMBOL_H_ #define LINEAR_STRING_TERMINATING_SYMBOL_H_ -#include "StringBase.h" #include <iostream> #include <set> #include <vector> +#include "StringBase.h" +#include "StringFeatures.h" + #include "../alphabet/Symbol.h" #include <core/components.hpp> namespace string { -class LinearString; class GeneralAlphabet; class TerminatingSymbol; @@ -33,7 +34,7 @@ public: explicit LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol ); explicit LinearStringTerminatingSymbol ( std::set < alphabet::Symbol > alphabet, alphabet::Symbol terminatingSymbol, std::vector < alphabet::Symbol > data ); explicit LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol, std::vector < alphabet::Symbol > data ); - explicit LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol, const LinearString & string ); + explicit LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol, const LinearString < > & string ); virtual StringBase * clone ( ) const; virtual StringBase * plunder ( ) &&; diff --git a/alib2data/src/string/String.cpp b/alib2data/src/string/String.cpp index ba842cef759ce8d70f98d13946e998e43188e002..394ca7fc471e88e7c9deab0c99585105ef2d457b 100644 --- a/alib2data/src/string/String.cpp +++ b/alib2data/src/string/String.cpp @@ -22,21 +22,11 @@ void String::extendAlphabet ( const std::set < alphabet::Symbol > & symbols ) { } string::String stringFrom ( const alphabet::Symbol & symbol ) { - return string::String { - string::LinearString { - std::vector < alphabet::Symbol > { - symbol - } - } - }; + return string::String { string::LinearString < > { std::vector < alphabet::Symbol > { symbol } } }; } string::String stringFrom ( const std::string & string ) { - return string::String { - string::LinearString { - string - } - }; + return string::String { string::LinearString < > { string } }; } string::String stringFrom ( const char * string ) { @@ -44,7 +34,7 @@ string::String stringFrom ( const char * string ) { } string::String stringFrom ( const std::vector < alphabet::Symbol > & str ) { - return string::String { string::LinearString { str } }; + return string::String { string::LinearString < > { str } }; } } /* namespace string */ diff --git a/alib2data/src/string/StringFeatures.h b/alib2data/src/string/StringFeatures.h index f73ca684b5ad2734f043297740915c30169bda0e..beb9b48f3e1f17a206d3058438b83b130ef2f994 100644 --- a/alib2data/src/string/StringFeatures.h +++ b/alib2data/src/string/StringFeatures.h @@ -23,8 +23,11 @@ class StringBase; template < class SymbolType = alphabet::Symbol > class Epsilon; +template < class SymbolType = alphabet::Symbol > class LinearString; +template < class SymbolType = alphabet::Symbol > class CyclicString; +class LinearStringTerminatingSymbol; } /* namespace string */ diff --git a/alib2data/test-src/string/StringTest.cpp b/alib2data/test-src/string/StringTest.cpp index 5e237fb113775b8a3f918df4b90fee950e56ef7c..0a637a882c1101206b71b98a522b37faae81061b 100644 --- a/alib2data/test-src/string/StringTest.cpp +++ b/alib2data/test-src/string/StringTest.cpp @@ -28,7 +28,7 @@ void StringTest::tearDown ( ) { } void StringTest::testCopyConstruct ( ) { - string::LinearString linearString; + string::LinearString < > linearString; linearString.accessComponent < string::GeneralAlphabet > ( ).set( { alphabet::symbolFrom ( "1" ), alphabet::symbolFrom ( "2" ), alphabet::symbolFrom ( "3" ) } ); linearString.setContent ( { alphabet::symbolFrom ( "1" ), alphabet::symbolFrom ( "2" ), alphabet::symbolFrom ( "1" ) } ); @@ -44,7 +44,7 @@ void StringTest::testCopyConstruct ( ) { void StringTest::testXMLParser ( ) { - string::LinearString linearString; + string::LinearString < > linearString; linearString.accessComponent < string::GeneralAlphabet > ( ).set( { alphabet::symbolFrom ( "1" ), alphabet::symbolFrom ( "2" ), alphabet::symbolFrom ( "3" ) } ); linearString.setContent ( { alphabet::symbolFrom ( "1" ), alphabet::symbolFrom ( "2" ), alphabet::symbolFrom ( "1" ) } ); diff --git a/alib2raw/src/string/StringFromRawParser.cpp b/alib2raw/src/string/StringFromRawParser.cpp index f036065b70fca9180a2c51e8ce09b90f6f06b968..8796f84b24a9f581e75a527bf64a57d8132de8db 100644 --- a/alib2raw/src/string/StringFromRawParser.cpp +++ b/alib2raw/src/string/StringFromRawParser.cpp @@ -23,7 +23,7 @@ String StringFromRawParser::parseString(std::istream_iterator<char>& input, cons for(;input != std::istream_iterator<char>(); input++) { data.push_back(alphabet::symbolFrom(*input)); } - LinearString string { data }; + LinearString < > string { data }; if(features.count(FEATURES::LINEAR)) return String{string}; diff --git a/alib2raw/src/string/StringToRawComposer.cpp b/alib2raw/src/string/StringToRawComposer.cpp index 2e4df53d5500c9837fce24e7512d52c5fbf839cf..b563d931ed767e144ac59ff5db228f6d9505f64a 100644 --- a/alib2raw/src/string/StringToRawComposer.cpp +++ b/alib2raw/src/string/StringToRawComposer.cpp @@ -14,13 +14,13 @@ void StringToRawComposer::compose(std::ostream& out, const String& string) { dispatch(out, string.getData()); } -void StringToRawComposer::compose(std::ostream& out, const LinearString& string) { +void StringToRawComposer::compose(std::ostream& out, const LinearString < > & string) { for(const alphabet::Symbol& symbol : string.getContent()) { out << (std::string) symbol; } } -StringToRawComposer::RegistratorWrapper<void, LinearString> StringToRawComposerLinearString = StringToRawComposer::RegistratorWrapper<void, LinearString>(StringToRawComposer::compose); +StringToRawComposer::RegistratorWrapper<void, LinearString < > > StringToRawComposerLinearString = StringToRawComposer::RegistratorWrapper<void, LinearString < > >(StringToRawComposer::compose); } /* namespace automaton */ diff --git a/alib2raw/src/string/StringToRawComposer.h b/alib2raw/src/string/StringToRawComposer.h index 5c27786f514eb2641b7a448d5914df960547cd63..5c3067b3250a751963bcf831a894a46b8ad654c0 100644 --- a/alib2raw/src/string/StringToRawComposer.h +++ b/alib2raw/src/string/StringToRawComposer.h @@ -24,7 +24,7 @@ class StringToRawComposer : public std::SingleDispatchFirstStaticParam<StringToR public: static void compose(std::ostream& out, const String& string); - static void compose(std::ostream& out, const LinearString& string); + static void compose(std::ostream& out, const LinearString < > & string); }; diff --git a/alib2str/src/string/StringFromStringParser.cpp b/alib2str/src/string/StringFromStringParser.cpp index b79cf85b8b609ee86804f874418138ae8aadc041..72333d93d13f9c0bf9aaac68bd44d60a40dc7e38 100644 --- a/alib2str/src/string/StringFromStringParser.cpp +++ b/alib2str/src/string/StringFromStringParser.cpp @@ -28,7 +28,7 @@ String StringFromStringParser::parseString(std::istream& input, const std::set<F std::vector<alphabet::Symbol> data = parseContent(input); token = m_StringLexer.next(input); if(token.type == StringFromStringLexer::TokenType::GREATER) { - return String(CyclicString(data)); + return String(CyclicString < > (data)); } else { throw exception::CommonException("Invalid cyclic string terminating character"); } @@ -37,7 +37,7 @@ String StringFromStringParser::parseString(std::istream& input, const std::set<F std::vector<alphabet::Symbol> data = parseContent(input); token = m_StringLexer.next(input); if(token.type == StringFromStringLexer::TokenType::QUOTE) { - return String(LinearString(data)); + return String(LinearString < >(data)); } else { throw exception::CommonException("Invalid linear string terminating character"); } diff --git a/alib2str/src/string/StringToStringComposer.cpp b/alib2str/src/string/StringToStringComposer.cpp index 4e2c07470cf8584f36c8685657e4a4cf728950d1..f49bd621662a3715315104ac7f0898ec7f74e534 100644 --- a/alib2str/src/string/StringToStringComposer.cpp +++ b/alib2str/src/string/StringToStringComposer.cpp @@ -14,7 +14,7 @@ namespace string { -void StringToStringComposer::compose ( std::ostream & out, const CyclicString & string ) { +void StringToStringComposer::compose ( std::ostream & out, const CyclicString < > & string ) { out << "<"; for ( const auto & symbol : string.getContent ( ) ) @@ -23,9 +23,9 @@ void StringToStringComposer::compose ( std::ostream & out, const CyclicString & out << ">"; } -StringToStringComposer::RegistratorWrapper < void, CyclicString > StringToStringComposerCyclicString = StringToStringComposer::RegistratorWrapper < void, CyclicString > ( StringToStringComposer::compose ); +StringToStringComposer::RegistratorWrapper < void, CyclicString < > > StringToStringComposerCyclicString = StringToStringComposer::RegistratorWrapper < void, CyclicString < > > ( StringToStringComposer::compose ); -void StringToStringComposer::compose ( std::ostream & out, const LinearString & string ) { +void StringToStringComposer::compose ( std::ostream & out, const LinearString < > & string ) { out << "\""; for ( const auto & symbol : string.getContent ( ) ) @@ -34,7 +34,7 @@ void StringToStringComposer::compose ( std::ostream & out, const LinearString & out << "\""; } -StringToStringComposer::RegistratorWrapper < void, LinearString > StringToStringComposerLinearString = StringToStringComposer::RegistratorWrapper < void, LinearString > ( StringToStringComposer::compose ); +StringToStringComposer::RegistratorWrapper < void, LinearString < > > StringToStringComposerLinearString = StringToStringComposer::RegistratorWrapper < void, LinearString < > > ( StringToStringComposer::compose ); void StringToStringComposer::compose ( std::ostream & out, const Epsilon < > & ) { out << "#E"; diff --git a/alib2str/src/string/StringToStringComposer.h b/alib2str/src/string/StringToStringComposer.h index 4283fc2db6d6be12932be8b85d4cd5176a7a60a2..7085942d8dd84d25b1becebc9be1651c3cfbbe13 100644 --- a/alib2str/src/string/StringToStringComposer.h +++ b/alib2str/src/string/StringToStringComposer.h @@ -20,8 +20,8 @@ namespace string { */ class StringToStringComposer: public std::SingleDispatchFirstStaticParam<StringToStringComposer, void, std::ostream&, StringBase> { public: - static void compose(std::ostream&, const LinearString& string); - static void compose(std::ostream&, const CyclicString& string); + static void compose(std::ostream&, const LinearString < > & string); + static void compose(std::ostream&, const CyclicString < > & string); static void compose(std::ostream&, const Epsilon < > & string); /** diff --git a/arand2/src/arand.cpp b/arand2/src/arand.cpp index 18152e84d5969d00f7d28c6582287acf1383e925..b7e349b9de958a913251bd163ea6a1bd966545a3 100644 --- a/arand2/src/arand.cpp +++ b/arand2/src/arand.cpp @@ -137,7 +137,7 @@ int main ( int argc, char * argv[] ) { } else if ( type.getValue ( ) == "ST" ) { measurements::start ( "Algorithm", measurements::Type::MAIN ); - string::LinearString res = string::generate::RandomStringFactory::generateLinearString ( length.getValue ( ), alphabetSize.getValue ( ), randomizedAlphabet.getValue ( ), integerSymbols.getValue ( ) ); + string::LinearString < > res = string::generate::RandomStringFactory::generateLinearString ( length.getValue ( ), alphabetSize.getValue ( ), randomizedAlphabet.getValue ( ), integerSymbols.getValue ( ) ); measurements::end ( ); measurements::start ( "Output write", measurements::Type::AUXILIARY ); diff --git a/arun2/src/arun.cpp b/arun2/src/arun.cpp index f0109fe6ea8df82df9cc4ab2689102bd87cc15b1..46a1ded8cc820c45db7756378613eb0aeb1d2d5b 100644 --- a/arun2/src/arun.cpp +++ b/arun2/src/arun.cpp @@ -104,7 +104,7 @@ int main(int argc, char* argv[]) { alib::XmlDataFactory::toStdout( res ); } else if( type.getValue() == "translate") { - std::set < string::LinearString > res = automaton::run::Translate::translate(automatonData, inputData); + std::set < string::LinearString < > > res = automaton::run::Translate::translate(automatonData, inputData); measurements::end(); measurements::start("Output write", measurements::Type::AUXILIARY);