diff --git a/alib2algo/src/arbology/exact/DeadZoneUsingBadCharacterShiftAndBorderArray.h b/alib2algo/src/arbology/exact/DeadZoneUsingBadCharacterShiftAndBorderArray.h index a12e45e2a1b39bad57af8345ded7224d209769fa..09d114c3f35e02362a8f5c980c81d57663761fb9 100644 --- a/alib2algo/src/arbology/exact/DeadZoneUsingBadCharacterShiftAndBorderArray.h +++ b/alib2algo/src/arbology/exact/DeadZoneUsingBadCharacterShiftAndBorderArray.h @@ -62,7 +62,7 @@ template < class SymbolType > ext::set < unsigned > DeadZoneUsingBadCharacterShiftAndBorderArray::match ( const tree::PrefixRankedBarTree < SymbolType > & subject, const tree::PrefixRankedBarPattern < SymbolType > & pattern ) { ext::set < unsigned > occ; ext::map < common::ranked_symbol < SymbolType >, size_t > bbcs = tree::properties::ReversedBadCharacterShiftTable::bcs ( pattern ); // NOTE: the subjects alphabet must be a subset or equal to the pattern - ext::vector < size_t > fba = tree::properties::BorderArrayNaive::ba ( pattern ); + ext::vector < size_t > fba = tree::properties::BorderArrayNaive::construct ( pattern ); ext::vector < int > subjectSubtreeJumpTable = tree::properties::SubtreeJumpTable::compute ( subject ); match_rec ( occ, subject, pattern, fba, bbcs, subjectSubtreeJumpTable, 0, subject.getContent ( ).size ( ) - pattern.getContent ( ).size ( ) + 1 ); @@ -94,7 +94,7 @@ template < class SymbolType > ext::set < unsigned > DeadZoneUsingBadCharacterShiftAndBorderArray::match ( const tree::PrefixRankedTree < SymbolType > & subject, const tree::PrefixRankedPattern < SymbolType > & pattern ) { ext::set < unsigned > occ; ext::map < common::ranked_symbol < SymbolType >, size_t > bbcs = tree::properties::ReversedBadCharacterShiftTable::bcs ( pattern ); // NOTE: the subjects alphabet must be a subset or equal to the pattern - ext::vector < size_t > fba = tree::properties::BorderArrayNaive::ba ( pattern ); + ext::vector < size_t > fba = tree::properties::BorderArrayNaive::construct ( pattern ); ext::vector < int > subjectSubtreeJumpTable = tree::properties::SubtreeJumpTable::compute ( subject ); match_rec ( occ, subject, pattern, fba, bbcs, subjectSubtreeJumpTable, 0, subject.getContent ( ).size ( ) - pattern.getContent ( ).size ( ) + 1 ); diff --git a/alib2algo/src/arbology/exact/KnuthMorrisPratt.h b/alib2algo/src/arbology/exact/KnuthMorrisPratt.h index 9917dc2321e5e9d661b599904b05d162573dd8eb..b8fbc761226c4a9b5ec312c0a65b3d99eb75a46e 100644 --- a/alib2algo/src/arbology/exact/KnuthMorrisPratt.h +++ b/alib2algo/src/arbology/exact/KnuthMorrisPratt.h @@ -63,7 +63,7 @@ ext::set < unsigned > KnuthMorrisPratt::match ( const tree::PrefixRankedBarTree template < class SymbolType > ext::set < unsigned > KnuthMorrisPratt::match ( const tree::PrefixRankedBarTree < SymbolType > & subject, const tree::PrefixRankedBarPattern < SymbolType > & pattern ) { ext::set < unsigned > occ; - ext::vector < size_t > ba = tree::properties::BorderArrayNaive::ba ( pattern ); + ext::vector < size_t > construct = tree::properties::BorderArrayNaive::construct ( pattern ); //measurements::start("Algorithm", measurements::Type::MAIN); @@ -81,7 +81,7 @@ ext::set < unsigned > KnuthMorrisPratt::match ( const tree::PrefixRankedBarTree if ( j >= pattern.getContent ( ).size ( ) ) occ.insert ( i ); // shift heuristics - i += j - ba[j]; + i += j - construct[j]; } //measurements::end(); @@ -92,7 +92,7 @@ ext::set < unsigned > KnuthMorrisPratt::match ( const tree::PrefixRankedBarTree template < class SymbolType > ext::set < unsigned > KnuthMorrisPratt::match ( const tree::PrefixRankedBarTree < SymbolType > & subject, const tree::PrefixRankedBarNonlinearPattern < SymbolType > & pattern ) { ext::set < unsigned > occ; - ext::vector < size_t > ba = tree::properties::BorderArrayNaive::ba ( pattern ); + ext::vector < size_t > construct = tree::properties::BorderArrayNaive::construct ( pattern ); //measurements::start("Algorithm", measurements::Type::MAIN); @@ -111,7 +111,7 @@ ext::set < unsigned > KnuthMorrisPratt::match ( const tree::PrefixRankedBarTree if ( j >= pattern.getContent ( ).size ( ) ) occ.insert ( i ); // shift heuristics - i += j - ba[j]; + i += j - construct[j]; } //measurements::end(); @@ -127,7 +127,7 @@ ext::set < unsigned > KnuthMorrisPratt::match ( const tree::PrefixRankedTree < S template < class SymbolType > ext::set < unsigned > KnuthMorrisPratt::match ( const tree::PrefixRankedTree < SymbolType > & subject, const tree::PrefixRankedPattern < SymbolType > & pattern ) { ext::set < unsigned > occ; - ext::vector < size_t > ba = tree::properties::BorderArrayNaive::ba ( pattern ); + ext::vector < size_t > construct = tree::properties::BorderArrayNaive::construct ( pattern ); //measurements::start("Algorithm", measurements::Type::MAIN); @@ -145,7 +145,7 @@ ext::set < unsigned > KnuthMorrisPratt::match ( const tree::PrefixRankedTree < S if ( j >= pattern.getContent ( ).size ( ) ) occ.insert ( i ); // shift heristics - i += j - ba[j]; + i += j - construct[j]; } //measurements::end(); @@ -156,7 +156,7 @@ ext::set < unsigned > KnuthMorrisPratt::match ( const tree::PrefixRankedTree < S template < class SymbolType > ext::set < unsigned > KnuthMorrisPratt::match ( const tree::PrefixRankedTree < SymbolType > & subject, const tree::PrefixRankedNonlinearPattern < SymbolType > & pattern ) { ext::set < unsigned > occ; - ext::vector < size_t > ba = tree::properties::BorderArrayNaive::ba ( pattern ); + ext::vector < size_t > construct = tree::properties::BorderArrayNaive::construct ( pattern ); //measurements::start("Algorithm", measurements::Type::MAIN); @@ -175,7 +175,7 @@ ext::set < unsigned > KnuthMorrisPratt::match ( const tree::PrefixRankedTree < S if ( j >= pattern.getContent ( ).size ( ) ) occ.insert ( i ); // shift heristics - i += j - ba[j]; + i += j - construct[j]; } //measurements::end(); diff --git a/alib2algo/src/string/properties/BorderArray.cpp b/alib2algo/src/string/properties/BorderArray.cpp index 6cf11be334496cffae215578ef8addfa4765942f..99fe3c61cf2c1ea8f453d2e147bb474409eb39c2 100644 --- a/alib2algo/src/string/properties/BorderArray.cpp +++ b/alib2algo/src/string/properties/BorderArray.cpp @@ -10,6 +10,6 @@ namespace { -auto BorderArrayLinearString = registration::AbstractRegister < string::properties::BorderArray, ext::vector < unsigned >, const string::LinearString < > & > ( string::properties::BorderArray::construct ); +auto BorderArrayLinearString = registration::AbstractRegister < string::properties::BorderArray, ext::vector < size_t >, const string::LinearString < > & > ( string::properties::BorderArray::construct ); } /* namespace */ diff --git a/alib2algo/src/string/properties/BorderArray.h b/alib2algo/src/string/properties/BorderArray.h index 7d63d94298cb86664396e7f2b74b0a7be59e1219..f41a971da6af84116aa9117cdffe3c9651d6e942 100644 --- a/alib2algo/src/string/properties/BorderArray.h +++ b/alib2algo/src/string/properties/BorderArray.h @@ -23,18 +23,18 @@ public: * @return Vector of length same as string, where i-th index corresponds to i-th element of string */ template < class SymbolType > - static ext::vector<unsigned> construct(const string::LinearString < SymbolType >& string); + static ext::vector<size_t> construct(const string::LinearString < SymbolType >& string); }; template < class SymbolType > -ext::vector<unsigned> BorderArray::construct(const string::LinearString < SymbolType >& string) { +ext::vector<size_t> BorderArray::construct(const string::LinearString < SymbolType >& string) { const auto& w = string.getContent(); - ext::vector<unsigned> res(w.size() + 1); + ext::vector<size_t> res(w.size() + 1); res[0] = 0; res[1] = 0; for(size_t i = 1; i < w.size(); i++) { - unsigned b = res[i]; + size_t b = res[i]; while (b > 0 && w[i + 1 - 1] != w[b + 1 - 1]) b = res[b]; diff --git a/alib2algo/src/string/properties/GoodSuffixShiftTable.h b/alib2algo/src/string/properties/GoodSuffixShiftTable.h index 19511ec2d1e8c05df7ad59078204a99b2e1853d0..ec516392b241b8b37b7762f3c3ec397c5d58f5fa 100644 --- a/alib2algo/src/string/properties/GoodSuffixShiftTable.h +++ b/alib2algo/src/string/properties/GoodSuffixShiftTable.h @@ -41,7 +41,7 @@ ext::vector < size_t > GoodSuffixShiftTable::gss ( const string::LinearString < std::reverse ( content.begin ( ), content.end ( ) ); string::LinearString < SymbolType > reversed ( std::move ( content ) ); - ext::vector < unsigned > borderArray = string::properties::BorderArray::construct ( reversed ); + ext::vector < size_t > borderArray = string::properties::BorderArray::construct ( reversed ); size_t max = reversed.getContent ( ).size ( ) - borderArray.back ( ); automaton::DFA < DefaultSymbolType, ext::set < unsigned > > factorAutomaton = automaton::determinize::Determinize::determinize ( automaton::simplify::EpsilonRemoverIncoming::remove ( stringology::indexing::NondeterministicExactFactorAutomaton::construct ( reversed ) ) ); diff --git a/alib2algo/src/tree/properties/BorderArrayNaive.cpp b/alib2algo/src/tree/properties/BorderArrayNaive.cpp index 6a233b91fe9c6cf13a86a4676376c6c5856c8c71..8b82129cdcad22c1906649058b14d4f3685eadbc 100644 --- a/alib2algo/src/tree/properties/BorderArrayNaive.cpp +++ b/alib2algo/src/tree/properties/BorderArrayNaive.cpp @@ -10,9 +10,9 @@ namespace { -auto BorderArrayPrefixRankedBarNonlinearPattern = registration::AbstractRegister < tree::properties::BorderArrayNaive, ext::vector < size_t >, const tree::PrefixRankedBarNonlinearPattern < > & > ( tree::properties::BorderArrayNaive::ba ); -auto BorderArrayPrefixRankedBarPattern = registration::AbstractRegister < tree::properties::BorderArrayNaive, ext::vector < size_t >, const tree::PrefixRankedBarPattern < > & > ( tree::properties::BorderArrayNaive::ba ); -auto BorderArrayPrefixRankedNonlinearPattern = registration::AbstractRegister < tree::properties::BorderArrayNaive, ext::vector < size_t >, const tree::PrefixRankedNonlinearPattern < > & > ( tree::properties::BorderArrayNaive::ba ); -auto BorderArrayPrefixRankedPattern = registration::AbstractRegister < tree::properties::BorderArrayNaive, ext::vector < size_t >, const tree::PrefixRankedPattern < > & > ( tree::properties::BorderArrayNaive::ba ); +auto BorderArrayPrefixRankedBarNonlinearPattern = registration::AbstractRegister < tree::properties::BorderArrayNaive, ext::vector < size_t >, const tree::PrefixRankedBarNonlinearPattern < > & > ( tree::properties::BorderArrayNaive::construct ); +auto BorderArrayPrefixRankedBarPattern = registration::AbstractRegister < tree::properties::BorderArrayNaive, ext::vector < size_t >, const tree::PrefixRankedBarPattern < > & > ( tree::properties::BorderArrayNaive::construct ); +auto BorderArrayPrefixRankedNonlinearPattern = registration::AbstractRegister < tree::properties::BorderArrayNaive, ext::vector < size_t >, const tree::PrefixRankedNonlinearPattern < > & > ( tree::properties::BorderArrayNaive::construct ); +auto BorderArrayPrefixRankedPattern = registration::AbstractRegister < tree::properties::BorderArrayNaive, ext::vector < size_t >, const tree::PrefixRankedPattern < > & > ( tree::properties::BorderArrayNaive::construct ); } /* namespace */ diff --git a/alib2algo/src/tree/properties/BorderArrayNaive.h b/alib2algo/src/tree/properties/BorderArrayNaive.h index f08f8fbe17bec85fcb197d5aea4622698a5eb7e0..44ee001b78fa46c2ee4f60028e51ee2855099268 100644 --- a/alib2algo/src/tree/properties/BorderArrayNaive.h +++ b/alib2algo/src/tree/properties/BorderArrayNaive.h @@ -46,28 +46,28 @@ public: * @return set set of occurences */ template < class SymbolType > - static ext::vector < size_t > ba ( const tree::PrefixRankedBarNonlinearPattern < SymbolType > & pattern ); + static ext::vector < size_t > construct ( const tree::PrefixRankedBarNonlinearPattern < SymbolType > & pattern ); /** * Search for pattern in linear string. * @return set set of occurences */ template < class SymbolType > - static ext::vector < size_t > ba ( const tree::PrefixRankedBarPattern < SymbolType > & pattern ); + static ext::vector < size_t > construct ( const tree::PrefixRankedBarPattern < SymbolType > & pattern ); /** * Search for pattern in linear string. * @return set set of occurences */ template < class SymbolType > - static ext::vector < size_t > ba ( const tree::PrefixRankedNonlinearPattern < SymbolType > & pattern ); + static ext::vector < size_t > construct ( const tree::PrefixRankedNonlinearPattern < SymbolType > & pattern ); /** * Search for pattern in linear string. * @return set set of occurences */ template < class SymbolType > - static ext::vector < size_t > ba ( const tree::PrefixRankedPattern < SymbolType > & pattern ); + static ext::vector < size_t > construct ( const tree::PrefixRankedPattern < SymbolType > & pattern ); }; @@ -91,7 +91,7 @@ bool BorderArrayNaive::matches ( const tree::PrefixRankedBarNonlinearPattern < S } template < class SymbolType > -ext::vector < size_t > BorderArrayNaive::ba ( const tree::PrefixRankedBarNonlinearPattern < SymbolType > & pattern ) { +ext::vector < size_t > BorderArrayNaive::construct ( const tree::PrefixRankedBarNonlinearPattern < SymbolType > & pattern ) { ext::vector < int > patternSubtreeJumpTable = SubtreeJumpTable::compute ( pattern ); ext::vector < size_t > res; @@ -137,7 +137,7 @@ bool BorderArrayNaive::matches ( const tree::PrefixRankedBarPattern < SymbolType } template < class SymbolType > -ext::vector < size_t > BorderArrayNaive::ba ( const tree::PrefixRankedBarPattern < SymbolType > & pattern ) { +ext::vector < size_t > BorderArrayNaive::construct ( const tree::PrefixRankedBarPattern < SymbolType > & pattern ) { ext::vector < int > patternSubtreeJumpTable = SubtreeJumpTable::compute ( pattern ); ext::vector < size_t > res; @@ -184,7 +184,7 @@ bool BorderArrayNaive::matches ( const tree::PrefixRankedNonlinearPattern < Symb } template < class SymbolType > -ext::vector < size_t > BorderArrayNaive::ba ( const tree::PrefixRankedNonlinearPattern < SymbolType > & pattern ) { +ext::vector < size_t > BorderArrayNaive::construct ( const tree::PrefixRankedNonlinearPattern < SymbolType > & pattern ) { ext::vector < int > patternSubtreeJumpTable = SubtreeJumpTable::compute ( pattern ); ext::vector < size_t > res; @@ -230,7 +230,7 @@ bool BorderArrayNaive::matches ( const tree::PrefixRankedPattern < SymbolType > } template < class SymbolType > -ext::vector < size_t > BorderArrayNaive::ba ( const tree::PrefixRankedPattern < SymbolType > & pattern ) { +ext::vector < size_t > BorderArrayNaive::construct ( const tree::PrefixRankedPattern < SymbolType > & pattern ) { ext::vector < int > patternSubtreeJumpTable = SubtreeJumpTable::compute ( pattern ); ext::vector < size_t > res; diff --git a/alib2algo/test-src/string/properties/borderArrayTest.cpp b/alib2algo/test-src/string/properties/borderArrayTest.cpp index 11c6ead408a9b197f0b9f87960749b183edca2f6..7aa83d487aa39fcbfe06076b4dddf5ffa381e458 100644 --- a/alib2algo/test-src/string/properties/borderArrayTest.cpp +++ b/alib2algo/test-src/string/properties/borderArrayTest.cpp @@ -5,8 +5,8 @@ TEST_CASE ( "Border Array", "[unit][algo][string][properties]" ) { SECTION ( "Test" ) { string::LinearString < char > string ( "alfalfaalf" ); - ext::vector<unsigned> borderArray = string::properties::BorderArray::construct(string); - ext::vector<unsigned> expected {0, 0, 0, 0, 1, 2, 3, 1, 1, 2, 3}; + ext::vector<size_t> borderArray = string::properties::BorderArray::construct(string); + ext::vector<size_t> expected {0, 0, 0, 0, 1, 2, 3, 1, 1, 2, 3}; CHECK(borderArray != expected); } diff --git a/alib2integrationtest/test-src/tests/exactMatching.cpp b/alib2integrationtest/test-src/tests/exactMatching.cpp index d6b34df65d6ae3620393983b492eb9860d635a67..10129014d0b9676577e20c84327d04b28bafe07c 100644 --- a/alib2integrationtest/test-src/tests/exactMatching.cpp +++ b/alib2integrationtest/test-src/tests/exactMatching.cpp @@ -26,6 +26,7 @@ static std::string qGenString ( const size_t & len, const size_t &alph_len, cons TEST_CASE ( "ExactMatching", "[integration]" ) { auto definition = GENERATE ( as < std::tuple < std::string, std::string, bool > > ( ), std::make_tuple ( "Exact Boyer Moore", "stringology::exact::BoyerMoore $subject $pattern", true ), + std::make_tuple ( "Exact Knuth Morris Pratt", "stringology::exact::KnuthMorrisPratt $subject $pattern", true ), std::make_tuple ( "Exact Boyer Moore Horspool", " stringology::exact::BoyerMooreHorspool $subject $pattern", true ), std::make_tuple ( "Exact Reversed Boyer Moore Horspool", " stringology::exact::ReversedBoyerMooreHorspool $subject $pattern", true ), std::make_tuple ( "Quick Search", "stringology::exact::QuickSearch $subject $pattern", true ),