diff --git a/aarbology2/src/aarbology.cpp b/aarbology2/src/aarbology.cpp index fc4183bc025ccdf9ff184c0a9f050d5da75c17df..58db9c350de0cdc2eaeac576e414ff16be37cfec 100644 --- a/aarbology2/src/aarbology.cpp +++ b/aarbology2/src/aarbology.cpp @@ -297,7 +297,7 @@ int main ( int argc, char * argv[] ) { measurements::end ( ); measurements::start ( "Algorithm", measurements::Type::MAIN ); - indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > compressedBitParallelIndex = arbology::indexing::CompressedBitParallelIndexConstruction::construct ( subject ); + indexes::arbology::CompressedBitParallelTreeIndex < > compressedBitParallelIndex = arbology::indexing::CompressedBitParallelIndexConstruction::construct ( subject ); measurements::end ( ); measurements::start ( "Output write", measurements::Type::AUXILIARY ); @@ -309,7 +309,7 @@ int main ( int argc, char * argv[] ) { measurements::end ( ); measurements::start ( "Algorithm", measurements::Type::MAIN ); - indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > nonlinearCompressedBitParallelIndex = arbology::indexing::NonlinearCompressedBitParallelIndexConstruction::construct ( subject ); + indexes::arbology::NonlinearCompressedBitParallelTreeIndex < > nonlinearCompressedBitParallelIndex = arbology::indexing::NonlinearCompressedBitParallelIndexConstruction::construct ( subject ); measurements::end ( ); measurements::start ( "Output write", measurements::Type::AUXILIARY ); @@ -321,7 +321,7 @@ int main ( int argc, char * argv[] ) { measurements::end ( ); measurements::start ( "Algorithm", measurements::Type::MAIN ); - indexes::arbology::FullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > fullAndLinearIndex = arbology::indexing::FullAndLinearIndexConstruction::construct ( subject ); + indexes::arbology::FullAndLinearIndex < > fullAndLinearIndex = arbology::indexing::FullAndLinearIndexConstruction::construct ( subject ); measurements::end ( ); measurements::start ( "Output write", measurements::Type::AUXILIARY ); @@ -333,7 +333,7 @@ int main ( int argc, char * argv[] ) { measurements::end ( ); measurements::start ( "Algorithm", measurements::Type::MAIN ); - indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > nonlinearFullAndLinearIndex = arbology::indexing::NonlinearFullAndLinearIndexConstruction::construct ( subject ); + indexes::arbology::NonlinearFullAndLinearIndex < > nonlinearFullAndLinearIndex = arbology::indexing::NonlinearFullAndLinearIndexConstruction::construct ( subject ); measurements::end ( ); measurements::start ( "Output write", measurements::Type::AUXILIARY ); diff --git a/alib2algo/src/arbology/indexing/CompressedBitParallelIndexConstruction.cpp b/alib2algo/src/arbology/indexing/CompressedBitParallelIndexConstruction.cpp index 171aade0853d69def1b9b4b947d7ed09bc11c019..25b52da868508362fe6fd8e1a2a575529da952cd 100644 --- a/alib2algo/src/arbology/indexing/CompressedBitParallelIndexConstruction.cpp +++ b/alib2algo/src/arbology/indexing/CompressedBitParallelIndexConstruction.cpp @@ -12,13 +12,13 @@ namespace arbology { namespace indexing { -indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > CompressedBitParallelIndexConstruction::construct ( const tree::RankedTreeWrapper & tree ) { +indexes::arbology::CompressedBitParallelTreeIndex < > CompressedBitParallelIndexConstruction::construct ( const tree::RankedTreeWrapper & tree ) { return dispatch ( tree.getData ( ) ); } -auto compressedBitParallelIndexConstructionPrefixRankedTree = registration::OverloadRegister < CompressedBitParallelIndexConstruction, indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > >, tree::PrefixRankedTree < > > ( CompressedBitParallelIndexConstruction::construct ); +auto compressedBitParallelIndexConstructionPrefixRankedTree = registration::OverloadRegister < CompressedBitParallelIndexConstruction, indexes::arbology::CompressedBitParallelTreeIndex < >, tree::PrefixRankedTree < > > ( CompressedBitParallelIndexConstruction::construct ); -auto compressedBitParallelIndexConstructionPrefixRankedBarTree = registration::OverloadRegister < CompressedBitParallelIndexConstruction, indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > >, tree::PrefixRankedBarTree < > > ( CompressedBitParallelIndexConstruction::construct ); +auto compressedBitParallelIndexConstructionPrefixRankedBarTree = registration::OverloadRegister < CompressedBitParallelIndexConstruction, indexes::arbology::CompressedBitParallelTreeIndex < >, tree::PrefixRankedBarTree < > > ( CompressedBitParallelIndexConstruction::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/arbology/indexing/CompressedBitParallelIndexConstruction.h b/alib2algo/src/arbology/indexing/CompressedBitParallelIndexConstruction.h index ef63836be934784679d2787dc388d34ae4d5c42b..89ec56906a6089512a708db21b740250fe12434b 100644 --- a/alib2algo/src/arbology/indexing/CompressedBitParallelIndexConstruction.h +++ b/alib2algo/src/arbology/indexing/CompressedBitParallelIndexConstruction.h @@ -25,24 +25,24 @@ namespace indexing { * */ -class CompressedBitParallelIndexConstruction : public alib::SingleDispatch < CompressedBitParallelIndexConstruction, indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > >, const tree::RankedTreeBase & > { +class CompressedBitParallelIndexConstruction : public alib::SingleDispatch < CompressedBitParallelIndexConstruction, indexes::arbology::CompressedBitParallelTreeIndex < >, const tree::RankedTreeBase & > { public: /** * Creates compressed bit parallel index for trees * @param tree tree to construct the index for * @return the index */ - static indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > construct ( const tree::RankedTreeWrapper & tree ); + static indexes::arbology::CompressedBitParallelTreeIndex < > construct ( const tree::RankedTreeWrapper & tree ); template < class SymbolType, class RankType > - static indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > construct ( const tree::PrefixRankedTree < SymbolType, RankType > & tree ); + static indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > construct ( const tree::PrefixRankedTree < SymbolType, RankType > & tree ); template < class SymbolType, class RankType > - static indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree ); + static indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree ); }; template < class SymbolType, class RankType > -indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > CompressedBitParallelIndexConstruction::construct ( const tree::PrefixRankedTree < SymbolType, RankType > & w ) { +indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > CompressedBitParallelIndexConstruction::construct ( const tree::PrefixRankedTree < SymbolType, RankType > & w ) { ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > res; for ( const common::ranked_symbol < SymbolType, RankType > & symbol : w.getAlphabet ( ) ) @@ -51,11 +51,11 @@ indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < Symb for ( unsigned i = 0; i < w.getContent ( ).size ( ); ++i ) res [ w.getContent ( ) [ i ] ] [ i ] = true; - return indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > ( w.getAlphabet ( ), res, tree::properties::SubtreeJumpTable::compute ( w ) ); + return indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > ( w.getAlphabet ( ), res, tree::properties::SubtreeJumpTable::compute ( w ) ); } template < class SymbolType, class RankType > -indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > CompressedBitParallelIndexConstruction::construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & w ) { +indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > CompressedBitParallelIndexConstruction::construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & w ) { ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > res; for ( const common::ranked_symbol < SymbolType, RankType > & symbol : w.getAlphabet ( ) ) @@ -64,7 +64,7 @@ indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < Symb for ( unsigned i = 0; i < w.getContent ( ).size ( ); ++i ) res [ w.getContent ( ) [ i ] ] [ i ] = true; - return indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > ( w.getAlphabet ( ), res, tree::properties::SubtreeJumpTable::compute ( w ) ); + return indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > ( w.getAlphabet ( ), res, tree::properties::SubtreeJumpTable::compute ( w ) ); } } /* namespace indexing */ diff --git a/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.cpp b/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.cpp index a5e5c7989cca3fb20d58e03891b6ea10246e70b5..d0692f3af3c7ea056c55d2d97a65673f0ff0b3be 100644 --- a/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.cpp +++ b/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.cpp @@ -12,12 +12,12 @@ namespace arbology { namespace indexing { -indexes::arbology::FullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > FullAndLinearIndexConstruction::construct ( const tree::RankedTreeWrapper & tree ) { +indexes::arbology::FullAndLinearIndex < > FullAndLinearIndexConstruction::construct ( const tree::RankedTreeWrapper & tree ) { return dispatch ( tree.getData ( ) ); } -auto fullAndLinearIndexConstructionPrefixRankedTree = registration::OverloadRegister < FullAndLinearIndexConstruction, indexes::arbology::FullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > >, tree::PrefixRankedTree < > > ( FullAndLinearIndexConstruction::construct ); -auto fullAndLinearIndexConstructionPrefixRankedBarTree = registration::OverloadRegister < FullAndLinearIndexConstruction, indexes::arbology::FullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > >, tree::PrefixRankedBarTree < > > ( FullAndLinearIndexConstruction::construct ); +auto fullAndLinearIndexConstructionPrefixRankedTree = registration::OverloadRegister < FullAndLinearIndexConstruction, indexes::arbology::FullAndLinearIndex < >, tree::PrefixRankedTree < > > ( FullAndLinearIndexConstruction::construct ); +auto fullAndLinearIndexConstructionPrefixRankedBarTree = registration::OverloadRegister < FullAndLinearIndexConstruction, indexes::arbology::FullAndLinearIndex < >, tree::PrefixRankedBarTree < > > ( FullAndLinearIndexConstruction::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.h b/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.h index 945b19cc4f96ba835a8258de38ff810b16763aab..8131ce10612f85267c6307a41f118cb8e5abc351 100644 --- a/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.h +++ b/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.h @@ -25,30 +25,30 @@ namespace indexing { * */ -class FullAndLinearIndexConstruction : public alib::SingleDispatch < FullAndLinearIndexConstruction, indexes::arbology::FullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > >, const tree::RankedTreeBase & > { +class FullAndLinearIndexConstruction : public alib::SingleDispatch < FullAndLinearIndexConstruction, indexes::arbology::FullAndLinearIndex < >, const tree::RankedTreeBase & > { public: /** * Creates compressed bit parallel index for trees * @param tree tree to construct the index for * @return the index */ - static indexes::arbology::FullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > construct ( const tree::RankedTreeWrapper & tree ); + static indexes::arbology::FullAndLinearIndex < > construct ( const tree::RankedTreeWrapper & tree ); template < class SymbolType, class RankType > - static indexes::arbology::FullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > construct ( const tree::PrefixRankedTree < SymbolType, RankType > & tree ); + static indexes::arbology::FullAndLinearIndex < SymbolType, RankType > construct ( const tree::PrefixRankedTree < SymbolType, RankType > & tree ); template < class SymbolType, class RankType > - static indexes::arbology::FullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree ); + static indexes::arbology::FullAndLinearIndex < SymbolType, RankType > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree ); }; template < class SymbolType, class RankType > -indexes::arbology::FullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > FullAndLinearIndexConstruction::construct ( const tree::PrefixRankedTree < SymbolType, RankType > & w ) { - return indexes::arbology::FullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > ( stringology::indexing::PositionHeapNaive::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) ); +indexes::arbology::FullAndLinearIndex < SymbolType, RankType > FullAndLinearIndexConstruction::construct ( const tree::PrefixRankedTree < SymbolType, RankType > & w ) { + return indexes::arbology::FullAndLinearIndex < SymbolType, RankType > ( stringology::indexing::PositionHeapNaive::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) ); } template < class SymbolType, class RankType > -indexes::arbology::FullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > FullAndLinearIndexConstruction::construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & w ) { - return indexes::arbology::FullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > ( stringology::indexing::PositionHeapNaive::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) ); +indexes::arbology::FullAndLinearIndex < SymbolType, RankType > FullAndLinearIndexConstruction::construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & w ) { + return indexes::arbology::FullAndLinearIndex < SymbolType, RankType > ( stringology::indexing::PositionHeapNaive::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) ); } } /* namespace indexing */ diff --git a/alib2algo/src/arbology/indexing/NonlinearCompressedBitParallelIndexConstruction.cpp b/alib2algo/src/arbology/indexing/NonlinearCompressedBitParallelIndexConstruction.cpp index 1af36e16087d09478955cfd5777af2cb73d25e02..3f99b22543577d00b1159e75bc55799ac6ce3681 100644 --- a/alib2algo/src/arbology/indexing/NonlinearCompressedBitParallelIndexConstruction.cpp +++ b/alib2algo/src/arbology/indexing/NonlinearCompressedBitParallelIndexConstruction.cpp @@ -12,11 +12,11 @@ namespace arbology { namespace indexing { -indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > NonlinearCompressedBitParallelIndexConstruction::construct ( const tree::RankedTreeWrapper & tree ) { +indexes::arbology::NonlinearCompressedBitParallelTreeIndex < > NonlinearCompressedBitParallelIndexConstruction::construct ( const tree::RankedTreeWrapper & tree ) { return dispatch ( tree.getData ( ) ); } -auto nonlinearcompressedBitParallelIndexConstructionPrefixRankedBarTree = registration::OverloadRegister < NonlinearCompressedBitParallelIndexConstruction, indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > >, tree::PrefixRankedBarTree < > > ( NonlinearCompressedBitParallelIndexConstruction::construct ); +auto nonlinearcompressedBitParallelIndexConstructionPrefixRankedBarTree = registration::OverloadRegister < NonlinearCompressedBitParallelIndexConstruction, indexes::arbology::NonlinearCompressedBitParallelTreeIndex < >, tree::PrefixRankedBarTree < > > ( NonlinearCompressedBitParallelIndexConstruction::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/arbology/indexing/NonlinearCompressedBitParallelIndexConstruction.h b/alib2algo/src/arbology/indexing/NonlinearCompressedBitParallelIndexConstruction.h index 5de3233204445c8730b48a278e943e07bc4263eb..555aecfdd806997c35b9525b3e9a395073c063b9 100644 --- a/alib2algo/src/arbology/indexing/NonlinearCompressedBitParallelIndexConstruction.h +++ b/alib2algo/src/arbology/indexing/NonlinearCompressedBitParallelIndexConstruction.h @@ -25,21 +25,21 @@ namespace indexing { * */ -class NonlinearCompressedBitParallelIndexConstruction : public alib::SingleDispatch < NonlinearCompressedBitParallelIndexConstruction, indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > >, const tree::RankedTreeBase & > { +class NonlinearCompressedBitParallelIndexConstruction : public alib::SingleDispatch < NonlinearCompressedBitParallelIndexConstruction, indexes::arbology::NonlinearCompressedBitParallelTreeIndex < >, const tree::RankedTreeBase & > { public: /** * Creates nonlinear compressed bit parallel index for trees * @param tree tree to construct the index for * @return the index */ - static indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > construct ( const tree::RankedTreeWrapper & tree ); + static indexes::arbology::NonlinearCompressedBitParallelTreeIndex < > construct ( const tree::RankedTreeWrapper & tree ); template < class SymbolType, class RankType > - static indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree ); + static indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree ); }; template < class SymbolType, class RankType > -indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > NonlinearCompressedBitParallelIndexConstruction::construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & w ) { +indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > NonlinearCompressedBitParallelIndexConstruction::construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & w ) { ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > res; for ( const common::ranked_symbol < SymbolType, RankType > & symbol : w.getAlphabet ( ) ) @@ -54,7 +54,7 @@ indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symb for ( const common::ranked_symbol < unsigned, RankType > & symbol : content ) repeats.push_back ( symbol.getSymbol ( ) ); - return indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > ( w.getAlphabet ( ), res, tree::properties::SubtreeJumpTable::compute ( w ), repeats ); + return indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > ( w.getAlphabet ( ), res, tree::properties::SubtreeJumpTable::compute ( w ), repeats ); } } /* namespace indexing */ diff --git a/alib2algo/src/arbology/indexing/NonlinearFullAndLinearIndexConstruction.cpp b/alib2algo/src/arbology/indexing/NonlinearFullAndLinearIndexConstruction.cpp index 7fb5bad7925fd96ef2b7ff06b36d66e14981d0c9..d0004c92566f0f34eca8baebba88f45bdf07044f 100644 --- a/alib2algo/src/arbology/indexing/NonlinearFullAndLinearIndexConstruction.cpp +++ b/alib2algo/src/arbology/indexing/NonlinearFullAndLinearIndexConstruction.cpp @@ -12,12 +12,12 @@ namespace arbology { namespace indexing { -indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > NonlinearFullAndLinearIndexConstruction::construct ( const tree::RankedTreeWrapper & tree ) { +indexes::arbology::NonlinearFullAndLinearIndex < > NonlinearFullAndLinearIndexConstruction::construct ( const tree::RankedTreeWrapper & tree ) { return dispatch ( tree.getData ( ) ); } -auto nonlinearFullAndLinearIndexConstructionPrefixRankedTree = registration::OverloadRegister < NonlinearFullAndLinearIndexConstruction, indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > >, tree::PrefixRankedTree < > > ( NonlinearFullAndLinearIndexConstruction::construct ); -auto nonlinearFullAndLinearIndexConstructionPrefixRankedBarTree = registration::OverloadRegister < NonlinearFullAndLinearIndexConstruction, indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > >, tree::PrefixRankedBarTree < > > ( NonlinearFullAndLinearIndexConstruction::construct ); +auto nonlinearFullAndLinearIndexConstructionPrefixRankedTree = registration::OverloadRegister < NonlinearFullAndLinearIndexConstruction, indexes::arbology::NonlinearFullAndLinearIndex < >, tree::PrefixRankedTree < > > ( NonlinearFullAndLinearIndexConstruction::construct ); +auto nonlinearFullAndLinearIndexConstructionPrefixRankedBarTree = registration::OverloadRegister < NonlinearFullAndLinearIndexConstruction, indexes::arbology::NonlinearFullAndLinearIndex < >, tree::PrefixRankedBarTree < > > ( NonlinearFullAndLinearIndexConstruction::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/arbology/indexing/NonlinearFullAndLinearIndexConstruction.h b/alib2algo/src/arbology/indexing/NonlinearFullAndLinearIndexConstruction.h index 5ccd2476138f703cc5bb777b32ffa6b0d7103d91..efad54cf49860d215f39f386dbec2c2d6b19568e 100644 --- a/alib2algo/src/arbology/indexing/NonlinearFullAndLinearIndexConstruction.h +++ b/alib2algo/src/arbology/indexing/NonlinearFullAndLinearIndexConstruction.h @@ -25,42 +25,42 @@ namespace indexing { * */ -class NonlinearFullAndLinearIndexConstruction : public alib::SingleDispatch < NonlinearFullAndLinearIndexConstruction, indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > >, const tree::RankedTreeBase & > { +class NonlinearFullAndLinearIndexConstruction : public alib::SingleDispatch < NonlinearFullAndLinearIndexConstruction, indexes::arbology::NonlinearFullAndLinearIndex < >, const tree::RankedTreeBase & > { public: /** * Creates compressed bit parallel index for trees * @param tree tree to construct the index for * @return the index */ - static indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > construct ( const tree::RankedTreeWrapper & tree ); + static indexes::arbology::NonlinearFullAndLinearIndex < > construct ( const tree::RankedTreeWrapper & tree ); template < class SymbolType, class RankType > - static indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > construct ( const tree::PrefixRankedTree < SymbolType, RankType > & tree ); + static indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > construct ( const tree::PrefixRankedTree < SymbolType, RankType > & tree ); template < class SymbolType, class RankType > - static indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree ); + static indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree ); }; template < class SymbolType, class RankType > -indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > NonlinearFullAndLinearIndexConstruction::construct ( const tree::PrefixRankedTree < SymbolType, RankType > & w ) { +indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > NonlinearFullAndLinearIndexConstruction::construct ( const tree::PrefixRankedTree < SymbolType, RankType > & w ) { ext::vector < common::ranked_symbol < unsigned, RankType > > content = tree::properties::ExactSubtreeRepeatsNaive::repeats ( w ).getContent ( ); ext::vector < unsigned > repeats; for ( const common::ranked_symbol < unsigned, RankType > & symbol : content ) repeats.push_back ( symbol.getSymbol ( ) ); - return indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > ( stringology::indexing::PositionHeapNaive::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ), repeats ); + return indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > ( stringology::indexing::PositionHeapNaive::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ), repeats ); } template < class SymbolType, class RankType > -indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > NonlinearFullAndLinearIndexConstruction::construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & w ) { +indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > NonlinearFullAndLinearIndexConstruction::construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & w ) { ext::vector < common::ranked_symbol < unsigned, RankType > > content = tree::properties::ExactSubtreeRepeatsNaive::repeats ( w ).getContent ( ); ext::vector < unsigned > repeats; for ( const common::ranked_symbol < unsigned, RankType > & symbol : content ) repeats.push_back ( symbol.getSymbol ( ) ); - return indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > ( stringology::indexing::PositionHeapNaive::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ), repeats ); + return indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > ( stringology::indexing::PositionHeapNaive::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ), repeats ); } } /* namespace indexing */ diff --git a/alib2algo/src/arbology/query/CompressedBitParallelismPatterns.cpp b/alib2algo/src/arbology/query/CompressedBitParallelismPatterns.cpp index 5dd0f2e7b4a0b68915436df928a28d766ba5edc8..0cc3588656688ed13cf491966c9d8d9d47d3d537 100644 --- a/alib2algo/src/arbology/query/CompressedBitParallelismPatterns.cpp +++ b/alib2algo/src/arbology/query/CompressedBitParallelismPatterns.cpp @@ -14,7 +14,7 @@ namespace arbology { namespace query { -ext::set < unsigned > CompressedBitParallelismPatterns::query ( const indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > & compressedBitParallelIndex, const tree::RankedTreeWrapper & tree ) { +ext::set < unsigned > CompressedBitParallelismPatterns::query ( const indexes::arbology::CompressedBitParallelTreeIndex < > & compressedBitParallelIndex, const tree::RankedTreeWrapper & tree ) { return dispatch ( compressedBitParallelIndex, tree.getData ( ) ); } diff --git a/alib2algo/src/arbology/query/CompressedBitParallelismPatterns.h b/alib2algo/src/arbology/query/CompressedBitParallelismPatterns.h index 1b7fc496122f466b9d4cd694567430bad69cdee3..faca2ce27ec77fc8eeb67fdd9fbefcbb9c71aad4 100644 --- a/alib2algo/src/arbology/query/CompressedBitParallelismPatterns.h +++ b/alib2algo/src/arbology/query/CompressedBitParallelismPatterns.h @@ -24,7 +24,7 @@ namespace query { * */ -class CompressedBitParallelismPatterns : public alib::SingleDispatchFirstStaticParam < CompressedBitParallelismPatterns, ext::set < unsigned >, const indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > &, const tree::RankedTreeBase & > { +class CompressedBitParallelismPatterns : public alib::SingleDispatchFirstStaticParam < CompressedBitParallelismPatterns, ext::set < unsigned >, const indexes::arbology::CompressedBitParallelTreeIndex < > &, const tree::RankedTreeBase & > { public: /** @@ -33,17 +33,17 @@ public: * @param tree tree to query by * @return occurences of factors */ - static ext::set < unsigned > query ( const indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > & compressedBitParallelIndex, const tree::RankedTreeWrapper & pattern ); + static ext::set < unsigned > query ( const indexes::arbology::CompressedBitParallelTreeIndex < > & compressedBitParallelIndex, const tree::RankedTreeWrapper & pattern ); template < class SymbolType, class RankType > - static ext::set < unsigned > query ( const indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > & compressedBitParallelTreeIndex, const tree::PrefixRankedPattern < SymbolType, RankType > & pattern ); + static ext::set < unsigned > query ( const indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > & compressedBitParallelTreeIndex, const tree::PrefixRankedPattern < SymbolType, RankType > & pattern ); template < class SymbolType, class RankType > - static ext::set < unsigned > query ( const indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > & compressedBitParallelTreeIndex, const tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern ); + static ext::set < unsigned > query ( const indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > & compressedBitParallelTreeIndex, const tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern ); }; template < class SymbolType, class RankType > -ext::set < unsigned > CompressedBitParallelismPatterns::query ( const indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > & compressedBitParallelIndex, const tree::PrefixRankedPattern < SymbolType, RankType > & pattern ) { +ext::set < unsigned > CompressedBitParallelismPatterns::query ( const indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > & compressedBitParallelIndex, const tree::PrefixRankedPattern < SymbolType, RankType > & pattern ) { auto symbolIter = pattern.getContent ( ).begin ( ); typename ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector >::const_iterator symbolVectorIter = compressedBitParallelIndex.getData ( ).find ( * symbolIter ); @@ -81,7 +81,7 @@ ext::set < unsigned > CompressedBitParallelismPatterns::query ( const indexes::a } template < class SymbolType, class RankType > -ext::set < unsigned > CompressedBitParallelismPatterns::query ( const indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > & compressedBitParallelIndex, const tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern ) { +ext::set < unsigned > CompressedBitParallelismPatterns::query ( const indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > & compressedBitParallelIndex, const tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern ) { auto symbolIter = pattern.getContent ( ).begin ( ); typename ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector >::const_iterator symbolVectorIter = compressedBitParallelIndex.getData ( ).find ( * symbolIter ); diff --git a/alib2algo/src/arbology/query/FullAndLinearIndexPatterns.cpp b/alib2algo/src/arbology/query/FullAndLinearIndexPatterns.cpp index a93b6ee1fc223a47be9aea5e6207ed31fe3fe0d9..d52f4b315a8618825bb22947b4670a3c029763b6 100644 --- a/alib2algo/src/arbology/query/FullAndLinearIndexPatterns.cpp +++ b/alib2algo/src/arbology/query/FullAndLinearIndexPatterns.cpp @@ -14,7 +14,7 @@ namespace arbology { namespace query { -ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbology::FullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > & fullAndLinearIndex, const tree::RankedTreeWrapper & tree ) { +ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbology::FullAndLinearIndex < > & fullAndLinearIndex, const tree::RankedTreeWrapper & tree ) { return dispatch ( fullAndLinearIndex, tree.getData ( ) ); } diff --git a/alib2algo/src/arbology/query/FullAndLinearIndexPatterns.h b/alib2algo/src/arbology/query/FullAndLinearIndexPatterns.h index df706e0fd27cf59f88ac19194227c11396ec00a9..25ceb45059887de35b1791144414ad4784842ee4 100644 --- a/alib2algo/src/arbology/query/FullAndLinearIndexPatterns.h +++ b/alib2algo/src/arbology/query/FullAndLinearIndexPatterns.h @@ -26,7 +26,7 @@ namespace query { * */ -class FullAndLinearIndexPatterns : public alib::SingleDispatchFirstStaticParam < FullAndLinearIndexPatterns, ext::set < unsigned >, const indexes::arbology::FullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > &, const tree::RankedTreeBase & > { +class FullAndLinearIndexPatterns : public alib::SingleDispatchFirstStaticParam < FullAndLinearIndexPatterns, ext::set < unsigned >, const indexes::arbology::FullAndLinearIndex < > &, const tree::RankedTreeBase & > { template < class SymbolType, class RankType > static ext::vector < std::pair < unsigned, unsigned > > FindOccurrences ( const indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > & stringIndex, const ext::vector < common::ranked_symbol < SymbolType, RankType > > & string ) { ext::vector < std::pair < unsigned, unsigned > > res; @@ -61,17 +61,17 @@ public: * @param tree tree to query by * @return occurences of factors */ - static ext::set < unsigned > query ( const indexes::arbology::FullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > & fullAndLinearIndex, const tree::RankedTreeWrapper & pattern ); + static ext::set < unsigned > query ( const indexes::arbology::FullAndLinearIndex < > & fullAndLinearIndex, const tree::RankedTreeWrapper & pattern ); template < class SymbolType, class RankType > - static ext::set < unsigned > query ( const indexes::arbology::FullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > & compressedBitParallelTreeIndex, const tree::PrefixRankedPattern < SymbolType, RankType > & pattern ); + static ext::set < unsigned > query ( const indexes::arbology::FullAndLinearIndex < SymbolType, RankType > & compressedBitParallelTreeIndex, const tree::PrefixRankedPattern < SymbolType, RankType > & pattern ); template < class SymbolType, class RankType > - static ext::set < unsigned > query ( const indexes::arbology::FullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > & compressedBitParallelTreeIndex, const tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern ); + static ext::set < unsigned > query ( const indexes::arbology::FullAndLinearIndex < SymbolType, RankType > & compressedBitParallelTreeIndex, const tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern ); }; template < class SymbolType, class RankType > -ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbology::FullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > & fullAndLinearIndex, const tree::PrefixRankedPattern < SymbolType, RankType > & pattern ) { +ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbology::FullAndLinearIndex < SymbolType, RankType > & fullAndLinearIndex, const tree::PrefixRankedPattern < SymbolType, RankType > & pattern ) { ext::vector < unsigned > rev ( fullAndLinearIndex.getString ( ).size ( ), ( unsigned ) -1 ); ext::vector < ext::vector < common::ranked_symbol < SymbolType, RankType > > > treePatternParts; @@ -103,7 +103,7 @@ ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbolog } template < class SymbolType, class RankType > -ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbology::FullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > & fullAndLinearIndex, const tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern ) { +ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbology::FullAndLinearIndex < SymbolType, RankType > & fullAndLinearIndex, const tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern ) { ext::vector < unsigned > rev ( fullAndLinearIndex.getString ( ).size ( ), ( unsigned ) -1 ); ext::vector < ext::vector < common::ranked_symbol < SymbolType, RankType > > > treePatternParts; diff --git a/alib2algo/src/arbology/query/NonlinearCompressedBitParallelismPatterns.cpp b/alib2algo/src/arbology/query/NonlinearCompressedBitParallelismPatterns.cpp index 22ffc4d6b47df2d48f01b3f3112cde5e345c1b0a..96cdfe379aba70f23ec4757172d1019a58478182 100644 --- a/alib2algo/src/arbology/query/NonlinearCompressedBitParallelismPatterns.cpp +++ b/alib2algo/src/arbology/query/NonlinearCompressedBitParallelismPatterns.cpp @@ -14,7 +14,7 @@ namespace arbology { namespace query { -ext::set < unsigned > NonlinearCompressedBitParallelismPatterns::query ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > & nonlinearCompressedBitParallelIndex, const tree::RankedTreeWrapper & tree ) { +ext::set < unsigned > NonlinearCompressedBitParallelismPatterns::query ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < > & nonlinearCompressedBitParallelIndex, const tree::RankedTreeWrapper & tree ) { return dispatch ( nonlinearCompressedBitParallelIndex, tree.getData ( ) ); } diff --git a/alib2algo/src/arbology/query/NonlinearCompressedBitParallelismPatterns.h b/alib2algo/src/arbology/query/NonlinearCompressedBitParallelismPatterns.h index d4bda33f390b632fe7dd5d4d497991d63b0a4da7..2e47e1b001987140e5b1a75b464cd2933fd28bf6 100644 --- a/alib2algo/src/arbology/query/NonlinearCompressedBitParallelismPatterns.h +++ b/alib2algo/src/arbology/query/NonlinearCompressedBitParallelismPatterns.h @@ -23,7 +23,7 @@ namespace query { * */ -class NonlinearCompressedBitParallelismPatterns : public alib::SingleDispatchFirstStaticParam < NonlinearCompressedBitParallelismPatterns, ext::set < unsigned >, const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > &, const tree::RankedTreeBase & > { +class NonlinearCompressedBitParallelismPatterns : public alib::SingleDispatchFirstStaticParam < NonlinearCompressedBitParallelismPatterns, ext::set < unsigned >, const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < > &, const tree::RankedTreeBase & > { public: /** @@ -32,10 +32,10 @@ public: * @param tree tree to query by * @return occurences of factors */ - static ext::set < unsigned > query ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > & nonlinearCompressedBitParallelIndex, const tree::RankedTreeWrapper & pattern ); + static ext::set < unsigned > query ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < > & nonlinearCompressedBitParallelIndex, const tree::RankedTreeWrapper & pattern ); template < class SymbolType, class RankType > - static ext::set < unsigned > query ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > & nonlinearCompressedBitParallelTreeIndex, const tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern ); + static ext::set < unsigned > query ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > & nonlinearCompressedBitParallelTreeIndex, const tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern ); }; template < class SymbolType, class RankType > @@ -74,7 +74,7 @@ bool include ( unsigned i, const ext::vector < unsigned > & repeats, const ext:: } template < class SymbolType, class RankType > -ext::set < unsigned > NonlinearCompressedBitParallelismPatterns::query ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > & nonlinearCompressedBitParallelIndex, const tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern ) { +ext::set < unsigned > NonlinearCompressedBitParallelismPatterns::query ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > & nonlinearCompressedBitParallelIndex, const tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern ) { auto symbolIter = pattern.getContent ( ).begin ( ); typename ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector >::const_iterator symbolVectorIter = nonlinearCompressedBitParallelIndex.getData ( ).find ( * symbolIter ); diff --git a/alib2algo/src/arbology/query/NonlinearFullAndLinearIndexPatterns.cpp b/alib2algo/src/arbology/query/NonlinearFullAndLinearIndexPatterns.cpp index 8d3f878fbbc27b5d60ed8ff59b19e7808a30d967..287c4093664f34aa8ae132976789dc61ea888002 100644 --- a/alib2algo/src/arbology/query/NonlinearFullAndLinearIndexPatterns.cpp +++ b/alib2algo/src/arbology/query/NonlinearFullAndLinearIndexPatterns.cpp @@ -14,7 +14,7 @@ namespace arbology { namespace query { -ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > & nonlinearFullAndLinearIndex, const tree::RankedTreeWrapper & tree ) { +ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes::arbology::NonlinearFullAndLinearIndex < > & nonlinearFullAndLinearIndex, const tree::RankedTreeWrapper & tree ) { return dispatch ( nonlinearFullAndLinearIndex, tree.getData ( ) ); } diff --git a/alib2algo/src/arbology/query/NonlinearFullAndLinearIndexPatterns.h b/alib2algo/src/arbology/query/NonlinearFullAndLinearIndexPatterns.h index d6b5aeb02608c0d25ee72e8a7ad8c05ccfe9c70d..01b2991aa4ba7ccae6e523c3627fb76efab2358c 100644 --- a/alib2algo/src/arbology/query/NonlinearFullAndLinearIndexPatterns.h +++ b/alib2algo/src/arbology/query/NonlinearFullAndLinearIndexPatterns.h @@ -26,7 +26,7 @@ namespace query { * */ -class NonlinearFullAndLinearIndexPatterns : public alib::SingleDispatchFirstStaticParam < NonlinearFullAndLinearIndexPatterns, ext::set < unsigned >, const indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > &, const tree::RankedTreeBase & > { +class NonlinearFullAndLinearIndexPatterns : public alib::SingleDispatchFirstStaticParam < NonlinearFullAndLinearIndexPatterns, ext::set < unsigned >, const indexes::arbology::NonlinearFullAndLinearIndex < > &, const tree::RankedTreeBase & > { template < class SymbolType, class RankType > static ext::vector < std::pair < unsigned, unsigned > > FindOccurrences ( const indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > & stringIndex, const ext::vector < common::ranked_symbol < SymbolType, RankType > > & string ) { ext::vector < std::pair < unsigned, unsigned > > res; @@ -61,17 +61,17 @@ public: * @param tree tree to query by * @return occurences of factors */ - static ext::set < unsigned > query ( const indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > & fullAndLinearIndex, const tree::RankedTreeWrapper & pattern ); + static ext::set < unsigned > query ( const indexes::arbology::NonlinearFullAndLinearIndex < > & fullAndLinearIndex, const tree::RankedTreeWrapper & pattern ); template < class SymbolType, class RankType > - static ext::set < unsigned > query ( const indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > & compressedBitParallelTreeIndex, const tree::PrefixRankedNonlinearPattern < SymbolType, RankType > & pattern ); + static ext::set < unsigned > query ( const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > & compressedBitParallelTreeIndex, const tree::PrefixRankedNonlinearPattern < SymbolType, RankType > & pattern ); template < class SymbolType, class RankType > - static ext::set < unsigned > query ( const indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > & compressedBitParallelTreeIndex, const tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern ); + static ext::set < unsigned > query ( const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > & compressedBitParallelTreeIndex, const tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern ); }; template < class SymbolType, class RankType > -ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > & fullAndLinearIndex, const tree::PrefixRankedNonlinearPattern < SymbolType, RankType > & pattern ) { +ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > & fullAndLinearIndex, const tree::PrefixRankedNonlinearPattern < SymbolType, RankType > & pattern ) { ext::map < std::pair < unsigned, common::ranked_symbol < SymbolType, RankType > >, unsigned > nonlinearVariablesMap; ext::vector < unsigned > rev ( fullAndLinearIndex.getString ( ).size ( ), ( unsigned ) -1 ); @@ -117,7 +117,7 @@ ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes } template < class SymbolType, class RankType > -ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < SymbolType, RankType > > & fullAndLinearIndex, const tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern ) { +ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > & fullAndLinearIndex, const tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern ) { ext::map < std::pair < unsigned, common::ranked_symbol < SymbolType, RankType > >, unsigned > nonlinearVariablesMap; ext::vector < unsigned > rev ( fullAndLinearIndex.getString ( ).size ( ), ( unsigned ) -1 ); diff --git a/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h b/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h index 6f4e12c5774d1123172f3d205a2ac268079075d3..f7f6fb6e0c7327aaadcd28a6b15e96d8e37ef31c 100644 --- a/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h +++ b/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h @@ -9,10 +9,10 @@ #define ARBOLOGY_COMPRESSED_BIT_PARALLEL_INDEX_H_ #include <string> -#include <iostream> #include <sstream> #include <common/DefaultSymbolType.h> +#include <alphabet/RankedSymbol.h> #include <core/components.hpp> #include <exception/CommonException.h> @@ -41,10 +41,10 @@ class GeneralAlphabet; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of RegExpElement. */ -template < class SymbolType = DefaultSymbolType > -class CompressedBitParallelTreeIndex final : public alib::ObjectBase, public alib::Components < CompressedBitParallelTreeIndex < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType > +class CompressedBitParallelTreeIndex final : public alib::ObjectBase, public alib::Components < CompressedBitParallelTreeIndex < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > { protected: - ext::map < SymbolType, common::SparseBoolVector > m_vectors; + ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > m_vectors; ext::vector < int > m_jumpTable; public: @@ -58,21 +58,21 @@ public: */ virtual ObjectBase * plunder ( ) &&; - explicit CompressedBitParallelTreeIndex ( ext::set < SymbolType > alphabet, ext::map < SymbolType, common::SparseBoolVector > vectors, ext::vector < int > jumpTable ); + explicit CompressedBitParallelTreeIndex ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > vectors, ext::vector < int > jumpTable ); /** * @return Root node of the trie */ - const ext::map < SymbolType, common::SparseBoolVector > & getData ( ) const; + const ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & getData ( ) const; /** * @return subtree jump table */ const ext::vector < int > & getJumps ( ) const; - ext::vector < SymbolType > getString ( ) const; + ext::vector < common::ranked_symbol < SymbolType, RankType > > getString ( ) const; - const ext::set < SymbolType > & getAlphabet ( ) const { + const ext::set < common::ranked_symbol < SymbolType, RankType > > & getAlphabet ( ) const { return this->template accessComponent < GeneralAlphabet > ( ).get ( ); } @@ -80,13 +80,13 @@ public: * Sets the compressedBit vector for given symbol * @param tree root node to set */ - void setCompressedBitVectorForSymbol ( SymbolType symbol, common::SparseBoolVector data ); + void setCompressedBitVectorForSymbol ( common::ranked_symbol < SymbolType, RankType > symbol, common::SparseBoolVector data ); /** * Removes symbol from the alphabet of symbol available in the regular expression * @param symbol removed symbol from the alphabet */ - bool removeSymbolFromAlphabet ( const SymbolType & symbol ) { + bool removeSymbolFromAlphabet ( const common::ranked_symbol < SymbolType, RankType > & symbol ) { return this->template accessComponent < GeneralAlphabet > ( ).remove ( symbol ); } @@ -122,13 +122,13 @@ public: typedef CompressedBitParallelTreeIndex < > normalized_type; virtual ObjectBase * normalize ( ) && { - if ( typeid ( CompressedBitParallelTreeIndex < > ) == typeid ( CompressedBitParallelTreeIndex < SymbolType > ) ) + if ( typeid ( CompressedBitParallelTreeIndex < > ) == typeid ( CompressedBitParallelTreeIndex < SymbolType, RankType > ) ) return this; - ext::set < DefaultSymbolType > alphabet = alphabet::SymbolNormalize::normalizeAlphabet ( std::move ( this->template accessComponent < GeneralAlphabet > ( ).get ( ) ) ); - ext::map < DefaultSymbolType, common::SparseBoolVector > vectors; - for ( std::pair < SymbolType, common::SparseBoolVector > && vector : ext::make_moveable_map ( m_vectors ) ) - vectors.insert ( std::make_pair ( alphabet::SymbolNormalize::normalizeSymbol ( std::move ( vector.first ) ), std::move ( vector.second ) ) ); + ext::set < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > alphabet = alphabet::SymbolNormalize::normalizeRankedAlphabet ( std::move ( this->template accessComponent < GeneralAlphabet > ( ).get ( ) ) ); + ext::map < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, common::SparseBoolVector > vectors; + for ( std::pair < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > && vector : ext::make_moveable_map ( m_vectors ) ) + vectors.insert ( std::make_pair ( alphabet::SymbolNormalize::normalizeRankedSymbol ( std::move ( vector.first ) ), std::move ( vector.second ) ) ); return new CompressedBitParallelTreeIndex < > ( std::move ( alphabet ), std::move ( vectors ), std::move ( m_jumpTable ) ); } @@ -142,38 +142,38 @@ namespace indexes { namespace arbology { -template < class SymbolType > -CompressedBitParallelTreeIndex < SymbolType >::CompressedBitParallelTreeIndex ( ext::set < SymbolType > alphabet, ext::map < SymbolType, common::SparseBoolVector > vectors, ext::vector < int > jumpTable ) : alib::Components < CompressedBitParallelTreeIndex, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_vectors ( std::move ( vectors ) ), m_jumpTable ( std::move ( jumpTable ) ) { +template < class SymbolType, class RankType > +CompressedBitParallelTreeIndex < SymbolType, RankType >::CompressedBitParallelTreeIndex ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > vectors, ext::vector < int > jumpTable ) : alib::Components < CompressedBitParallelTreeIndex, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_vectors ( std::move ( vectors ) ), m_jumpTable ( std::move ( jumpTable ) ) { } -template < class SymbolType > -alib::ObjectBase * CompressedBitParallelTreeIndex < SymbolType >::clone ( ) const { +template < class SymbolType, class RankType > +alib::ObjectBase * CompressedBitParallelTreeIndex < SymbolType, RankType >::clone ( ) const { return new CompressedBitParallelTreeIndex ( * this ); } -template < class SymbolType > -alib::ObjectBase * CompressedBitParallelTreeIndex < SymbolType >::plunder ( ) && { +template < class SymbolType, class RankType > +alib::ObjectBase * CompressedBitParallelTreeIndex < SymbolType, RankType >::plunder ( ) && { return new CompressedBitParallelTreeIndex ( std::move ( * this ) ); } -template < class SymbolType > -const ext::map < SymbolType, common::SparseBoolVector > & CompressedBitParallelTreeIndex < SymbolType >::getData ( ) const { +template < class SymbolType, class RankType > +const ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & CompressedBitParallelTreeIndex < SymbolType, RankType >::getData ( ) const { return m_vectors; } -template < class SymbolType > -const ext::vector < int > & CompressedBitParallelTreeIndex < SymbolType >::getJumps ( ) const { +template < class SymbolType, class RankType > +const ext::vector < int > & CompressedBitParallelTreeIndex < SymbolType, RankType >::getJumps ( ) const { return m_jumpTable; } -template < class SymbolType > -ext::vector < SymbolType > CompressedBitParallelTreeIndex < SymbolType >::getString ( ) const { - ext::vector < SymbolType > res; +template < class SymbolType, class RankType > +ext::vector < common::ranked_symbol < SymbolType, RankType > > CompressedBitParallelTreeIndex < SymbolType, RankType >::getString ( ) const { + ext::vector < SymbolType, RankType > res; unsigned index = 0; do { - for ( const std::pair < const SymbolType, common::SparseBoolVector > & compressedBitVector : m_vectors ) + for ( const std::pair < const common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & compressedBitVector : m_vectors ) if ( compressedBitVector.second.size ( ) > index && compressedBitVector.second [ index ] ) { res.push_back ( compressedBitVector.first ); continue; @@ -184,18 +184,18 @@ ext::vector < SymbolType > CompressedBitParallelTreeIndex < SymbolType >::getStr return res; } -template < class SymbolType > -void CompressedBitParallelTreeIndex < SymbolType >::setCompressedBitVectorForSymbol ( SymbolType symbol, common::SparseBoolVector data ) { +template < class SymbolType, class RankType > +void CompressedBitParallelTreeIndex < SymbolType, RankType >::setCompressedBitVectorForSymbol ( common::ranked_symbol < SymbolType, RankType > symbol, common::SparseBoolVector data ) { this->m_vectors [ symbol ] = std::move ( data ); } -template < class SymbolType > -void CompressedBitParallelTreeIndex < SymbolType >::operator >>( std::ostream & out ) const { +template < class SymbolType, class RankType > +void CompressedBitParallelTreeIndex < SymbolType, RankType >::operator >>( std::ostream & out ) const { out << "(CompressedBitParallelTreeIndex " << this->m_vectors << ", " << m_jumpTable << ")"; } -template < class SymbolType > -int CompressedBitParallelTreeIndex < SymbolType >::compare ( const CompressedBitParallelTreeIndex & other ) const { +template < class SymbolType, class RankType > +int CompressedBitParallelTreeIndex < SymbolType, RankType >::compare ( const CompressedBitParallelTreeIndex & other ) const { auto first = ext::tie ( getData ( ), getAlphabet ( ), getJumps ( ) ); auto second = ext::tie ( other.getData ( ), other.getAlphabet ( ), other.getJumps ( ) ); @@ -204,37 +204,37 @@ int CompressedBitParallelTreeIndex < SymbolType >::compare ( const CompressedBit return comp ( first, second ); } -template < class SymbolType > -CompressedBitParallelTreeIndex < SymbolType >::operator std::string ( ) const { +template < class SymbolType, class RankType > +CompressedBitParallelTreeIndex < SymbolType, RankType >::operator std::string ( ) const { std::stringstream ss; ss << * this; return ss.str ( ); } -template < class SymbolType > -CompressedBitParallelTreeIndex < SymbolType > CompressedBitParallelTreeIndex < SymbolType >::parse ( ext::deque < sax::Token >::iterator & input ) { +template < class SymbolType, class RankType > +CompressedBitParallelTreeIndex < SymbolType, RankType > CompressedBitParallelTreeIndex < SymbolType, RankType >::parse ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, CompressedBitParallelTreeIndex::getXmlTagName ( ) ); - ext::set < SymbolType > alphabet = alib::xmlApi < ext::set < SymbolType > >::parse ( input ); - ext::map < SymbolType, common::SparseBoolVector > data = alib::xmlApi < ext::map < SymbolType, common::SparseBoolVector > >::parse ( input ); + ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet = alib::xmlApi < ext::set < common::ranked_symbol < SymbolType, RankType > > >::parse ( input ); + ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > data = alib::xmlApi < ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > >::parse ( input ); ext::vector < int > jumps = alib::xmlApi < ext::vector < int > >::parse ( input ); - CompressedBitParallelTreeIndex < SymbolType > res ( std::move ( alphabet ), std::move ( data ), std::move ( jumps ) ); + CompressedBitParallelTreeIndex < SymbolType, RankType > res ( std::move ( alphabet ), std::move ( data ), std::move ( jumps ) ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, CompressedBitParallelTreeIndex::getXmlTagName ( ) ); return res; } -template < class SymbolType > -void CompressedBitParallelTreeIndex < SymbolType >::compose ( ext::deque < sax::Token > & out ) const { +template < class SymbolType, class RankType > +void CompressedBitParallelTreeIndex < SymbolType, RankType >::compose ( ext::deque < sax::Token > & out ) const { out.emplace_back ( CompressedBitParallelTreeIndex::getXmlTagName ( ), sax::Token::TokenType::START_ELEMENT ); - alib::xmlApi < ext::set < SymbolType > >::compose ( out, getAlphabet ( ) ); - alib::xmlApi < ext::map < SymbolType, common::SparseBoolVector > >::compose ( out, getData ( ) ); + alib::xmlApi < ext::set < common::ranked_symbol < SymbolType, RankType > > >::compose ( out, getAlphabet ( ) ); + alib::xmlApi < ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > >::compose ( out, getData ( ) ); alib::xmlApi < ext::vector < int > >::compose ( out, getJumps ( ) ); out.emplace_back ( CompressedBitParallelTreeIndex::getXmlTagName ( ), sax::Token::TokenType::END_ELEMENT ); } -template < class SymbolType > -alib::ObjectBase * CompressedBitParallelTreeIndex < SymbolType >::inc ( ) && { +template < class SymbolType, class RankType > +alib::ObjectBase * CompressedBitParallelTreeIndex < SymbolType, RankType >::inc ( ) && { return new alib::UniqueObject ( alib::Object ( std::move ( * this ) ), primitive::Integer ( 0 ) ); } @@ -244,20 +244,20 @@ alib::ObjectBase * CompressedBitParallelTreeIndex < SymbolType >::inc ( ) && { namespace alib { -template < class SymbolType > -class ComponentConstraint < indexes::arbology::CompressedBitParallelTreeIndex < SymbolType >, SymbolType, indexes::arbology::GeneralAlphabet > { +template < class SymbolType, class RankType > +class ComponentConstraint < indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, indexes::arbology::GeneralAlphabet > { public: - static bool used ( const indexes::arbology::CompressedBitParallelTreeIndex < SymbolType > & index, const SymbolType & symbol ) { - const ext::map < SymbolType, common::SparseBoolVector > & content = index.getData ( ); + static bool used ( const indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > & index, const common::ranked_symbol < SymbolType, RankType > & symbol ) { + const ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & content = index.getData ( ); return content.find ( symbol ) != content.end ( ); } - static bool available ( const indexes::arbology::CompressedBitParallelTreeIndex < SymbolType > &, const SymbolType & ) { + static bool available ( const indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) { return true; } - static void valid ( const indexes::arbology::CompressedBitParallelTreeIndex < SymbolType > &, const SymbolType & ) { + static void valid ( const indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) { } }; diff --git a/alib2data/src/indexes/arbology/FullAndLinearIndex.h b/alib2data/src/indexes/arbology/FullAndLinearIndex.h index a70facae8b305f93eba30effbbdb6a633c0a99f3..9a5660961b09b8a45b439bb9a9eaa82717eeea0c 100644 --- a/alib2data/src/indexes/arbology/FullAndLinearIndex.h +++ b/alib2data/src/indexes/arbology/FullAndLinearIndex.h @@ -9,10 +9,9 @@ #define ARBOLOGY_FULL_AND_LINEAR_INDEX_H_ #include <string> -#include <iostream> #include <sstream> -#include <common/DefaultSymbolType.h> +#include <alphabet/RankedSymbol.h> #include <object/UniqueObject.h> #include <object/ObjectBase.h> @@ -36,10 +35,10 @@ class GeneralAlphabet; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of RegExpElement. */ -template < class SymbolType = DefaultSymbolType > +template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType > class FullAndLinearIndex final : public alib::ObjectBase { protected: - indexes::stringology::PositionHeap < SymbolType > m_StringIndex; + indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > m_StringIndex; ext::vector < int > m_JumpTable; public: @@ -53,21 +52,21 @@ public: */ virtual ObjectBase * plunder ( ) &&; - explicit FullAndLinearIndex ( indexes::stringology::PositionHeap < SymbolType > stringIndex, ext::vector < int > jumpTable ); + explicit FullAndLinearIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable ); /** * @return Root node of the trie */ - const indexes::stringology::PositionHeap < SymbolType > & getStringIndex ( ) const; + const indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > & getStringIndex ( ) const; /** * @return subtree jump table */ const ext::vector < int > & getJumps ( ) const; - const ext::vector < SymbolType > & getString ( ) const; + const ext::vector < common::ranked_symbol < SymbolType, RankType > > & getString ( ) const; - const ext::set < SymbolType > & getAlphabet ( ) const { + const ext::set < common::ranked_symbol < SymbolType, RankType > > & getAlphabet ( ) const { return m_StringIndex.getAlphabet ( ); } @@ -75,13 +74,13 @@ public: * Sets the compressedBit vector for given symbol * @param tree root node to set */ - void setStringIndex ( indexes::stringology::PositionHeap < SymbolType > stringIndex ); + void setStringIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex ); /** * Removes symbol from the alphabet of symbol available in the regular expression * @param symbol removed symbol from the alphabet */ - bool removeSymbolFromAlphabet ( const SymbolType & symbol ) { + bool removeSymbolFromAlphabet ( const common::ranked_symbol < SymbolType, RankType > & symbol ) { return m_StringIndex.removeSymbolFromAlphabet ( symbol ); } @@ -117,10 +116,10 @@ public: typedef FullAndLinearIndex < > normalized_type; virtual ObjectBase * normalize ( ) && { - if ( typeid ( FullAndLinearIndex < > ) == typeid ( FullAndLinearIndex < SymbolType > ) ) + if ( typeid ( FullAndLinearIndex < > ) == typeid ( FullAndLinearIndex < SymbolType, RankType > ) ) return this; - indexes::stringology::PositionHeap < DefaultSymbolType > stringIndex = std::move ( m_StringIndex ).normalizeRaw ( ); + indexes::stringology::PositionHeap < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > stringIndex = std::move ( m_StringIndex ).normalizeRankedRaw ( ); return new FullAndLinearIndex < > ( std::move ( stringIndex ), std::move ( m_JumpTable ) ); } @@ -134,47 +133,47 @@ namespace indexes { namespace arbology { -template < class SymbolType > -FullAndLinearIndex < SymbolType >::FullAndLinearIndex ( indexes::stringology::PositionHeap < SymbolType > stringIndex, ext::vector < int > jumpTable ) : m_StringIndex ( std::move ( stringIndex ) ), m_JumpTable ( std::move ( jumpTable ) ) { +template < class SymbolType, class RankType > +FullAndLinearIndex < SymbolType, RankType >::FullAndLinearIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable ) : m_StringIndex ( std::move ( stringIndex ) ), m_JumpTable ( std::move ( jumpTable ) ) { } -template < class SymbolType > -alib::ObjectBase * FullAndLinearIndex < SymbolType >::clone ( ) const { +template < class SymbolType, class RankType > +alib::ObjectBase * FullAndLinearIndex < SymbolType, RankType >::clone ( ) const { return new FullAndLinearIndex ( * this ); } -template < class SymbolType > -alib::ObjectBase * FullAndLinearIndex < SymbolType >::plunder ( ) && { +template < class SymbolType, class RankType > +alib::ObjectBase * FullAndLinearIndex < SymbolType, RankType >::plunder ( ) && { return new FullAndLinearIndex ( std::move ( * this ) ); } -template < class SymbolType > -const indexes::stringology::PositionHeap < SymbolType > & FullAndLinearIndex < SymbolType >::getStringIndex ( ) const { +template < class SymbolType, class RankType > +const indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > & FullAndLinearIndex < SymbolType, RankType >::getStringIndex ( ) const { return m_StringIndex; } -template < class SymbolType > -const ext::vector < int > & FullAndLinearIndex < SymbolType >::getJumps ( ) const { +template < class SymbolType, class RankType > +const ext::vector < int > & FullAndLinearIndex < SymbolType, RankType >::getJumps ( ) const { return m_JumpTable; } -template < class SymbolType > -const ext::vector < SymbolType > & FullAndLinearIndex < SymbolType >::getString ( ) const { +template < class SymbolType, class RankType > +const ext::vector < common::ranked_symbol < SymbolType, RankType > > & FullAndLinearIndex < SymbolType, RankType >::getString ( ) const { return m_StringIndex.getString ( ); } -template < class SymbolType > -void FullAndLinearIndex < SymbolType >::setStringIndex ( indexes::stringology::PositionHeap < SymbolType > stringIndex ) { +template < class SymbolType, class RankType > +void FullAndLinearIndex < SymbolType, RankType >::setStringIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex ) { this->m_StringIndex = std::move ( stringIndex ); } -template < class SymbolType > -void FullAndLinearIndex < SymbolType >::operator >>( std::ostream & out ) const { +template < class SymbolType, class RankType > +void FullAndLinearIndex < SymbolType, RankType >::operator >>( std::ostream & out ) const { out << "(FullAndLinearIndex " << this->m_StringIndex << ", " << m_JumpTable << ")"; } -template < class SymbolType > -int FullAndLinearIndex < SymbolType >::compare ( const FullAndLinearIndex & other ) const { +template < class SymbolType, class RankType > +int FullAndLinearIndex < SymbolType, RankType >::compare ( const FullAndLinearIndex & other ) const { auto first = ext::tie ( getStringIndex ( ), getJumps ( ) ); auto second = ext::tie ( other.getStringIndex ( ), other.getJumps ( ) ); @@ -183,35 +182,35 @@ int FullAndLinearIndex < SymbolType >::compare ( const FullAndLinearIndex & othe return comp ( first, second ); } -template < class SymbolType > -FullAndLinearIndex < SymbolType >::operator std::string ( ) const { +template < class SymbolType, class RankType > +FullAndLinearIndex < SymbolType, RankType >::operator std::string ( ) const { std::stringstream ss; ss << * this; return ss.str ( ); } -template < class SymbolType > -FullAndLinearIndex < SymbolType > FullAndLinearIndex < SymbolType >::parse ( ext::deque < sax::Token >::iterator & input ) { +template < class SymbolType, class RankType > +FullAndLinearIndex < SymbolType, RankType > FullAndLinearIndex < SymbolType, RankType >::parse ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, FullAndLinearIndex::getXmlTagName ( ) ); - indexes::stringology::PositionHeap < SymbolType > stringIndex = alib::xmlApi < indexes::stringology::PositionHeap < SymbolType > >::parse ( input ); + indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex = alib::xmlApi < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::parse ( input ); ext::vector < int > jumps = alib::xmlApi < ext::vector < int > >::parse ( input ); - FullAndLinearIndex < SymbolType > res ( std::move ( stringIndex ), std::move ( jumps ) ); + FullAndLinearIndex < SymbolType, RankType > res ( std::move ( stringIndex ), std::move ( jumps ) ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, FullAndLinearIndex::getXmlTagName ( ) ); return res; } -template < class SymbolType > -void FullAndLinearIndex < SymbolType >::compose ( ext::deque < sax::Token > & out ) const { +template < class SymbolType, class RankType > +void FullAndLinearIndex < SymbolType, RankType >::compose ( ext::deque < sax::Token > & out ) const { out.emplace_back ( FullAndLinearIndex::getXmlTagName ( ), sax::Token::TokenType::START_ELEMENT ); - alib::xmlApi < indexes::stringology::PositionHeap < SymbolType > >::compose ( out, getStringIndex ( ) ); + alib::xmlApi < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::compose ( out, getStringIndex ( ) ); alib::xmlApi < ext::vector < int > >::compose ( out, getJumps ( ) ); out.emplace_back ( FullAndLinearIndex::getXmlTagName ( ), sax::Token::TokenType::END_ELEMENT ); } -template < class SymbolType > -alib::ObjectBase * FullAndLinearIndex < SymbolType >::inc ( ) && { +template < class SymbolType, class RankType > +alib::ObjectBase * FullAndLinearIndex < SymbolType, RankType >::inc ( ) && { return new alib::UniqueObject ( alib::Object ( std::move ( * this ) ), primitive::Integer ( 0 ) ); } diff --git a/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h b/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h index c05066f07199bfc25f1656839780111a88475573..7b09773c1fb40bd310d4241150bbb2081915c233 100644 --- a/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h +++ b/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h @@ -9,10 +9,9 @@ #define ARBOLOGY_NONLINEAR_COMPRESSED_BIT_PARALLEL_INDEX_H_ #include <string> -#include <iostream> #include <sstream> -#include <common/DefaultSymbolType.h> +#include <alphabet/RankedSymbol.h> #include <core/components.hpp> #include <exception/CommonException.h> @@ -41,10 +40,10 @@ class GeneralAlphabet; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of RegExpElement. */ -template < class SymbolType = DefaultSymbolType > -class NonlinearCompressedBitParallelTreeIndex final : public alib::ObjectBase, public alib::Components < NonlinearCompressedBitParallelTreeIndex < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType > +class NonlinearCompressedBitParallelTreeIndex final : public alib::ObjectBase, public alib::Components < NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > { protected: - ext::map < SymbolType, common::SparseBoolVector > m_vectors; + ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > m_vectors; ext::vector < int > m_jumpTable; ext::vector < unsigned > m_repeats; @@ -59,12 +58,12 @@ public: */ virtual ObjectBase * plunder ( ) &&; - explicit NonlinearCompressedBitParallelTreeIndex ( ext::set < SymbolType > alphabet, ext::map < SymbolType, common::SparseBoolVector > vectors, ext::vector < int > jumpTable, ext::vector < unsigned > repeats ); + explicit NonlinearCompressedBitParallelTreeIndex ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > vectors, ext::vector < int > jumpTable, ext::vector < unsigned > repeats ); /** * @return Root node of the trie */ - const ext::map < SymbolType, common::SparseBoolVector > & getData ( ) const; + const ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & getData ( ) const; /** * @return subtree jump table @@ -73,9 +72,9 @@ public: const ext::vector < unsigned > & getRepeats ( ) const; - ext::vector < SymbolType > getString ( ) const; + ext::vector < common::ranked_symbol < SymbolType, RankType > > getString ( ) const; - const ext::set < SymbolType > & getAlphabet ( ) const { + const ext::set < common::ranked_symbol < SymbolType, RankType > > & getAlphabet ( ) const { return this->template accessComponent < GeneralAlphabet > ( ).get ( ); } @@ -83,13 +82,13 @@ public: * Sets the nonlinearcompressedBit vector for given symbol * @param tree root node to set */ - void setNonlinearCompressedBitVectorForSymbol ( SymbolType symbol, common::SparseBoolVector data ); + void setNonlinearCompressedBitVectorForSymbol ( common::ranked_symbol < SymbolType, RankType > symbol, common::SparseBoolVector data ); /** * Removes symbol from the alphabet of symbol available in the regular expression * @param symbol removed symbol from the alphabet */ - bool removeSymbolFromAlphabet ( const SymbolType & symbol ) { + bool removeSymbolFromAlphabet ( const common::ranked_symbol < SymbolType, RankType > & symbol ) { return this->template accessComponent < GeneralAlphabet > ( ).remove ( symbol ); } @@ -125,13 +124,13 @@ public: typedef NonlinearCompressedBitParallelTreeIndex < > normalized_type; virtual ObjectBase * normalize ( ) && { - if ( typeid ( NonlinearCompressedBitParallelTreeIndex < > ) == typeid ( NonlinearCompressedBitParallelTreeIndex < SymbolType > ) ) + if ( typeid ( NonlinearCompressedBitParallelTreeIndex < > ) == typeid ( NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > ) ) return this; - ext::set < DefaultSymbolType > alphabet = alphabet::SymbolNormalize::normalizeAlphabet ( std::move ( this->template accessComponent < GeneralAlphabet > ( ).get ( ) ) ); - ext::map < DefaultSymbolType, common::SparseBoolVector > vectors; - for ( std::pair < SymbolType, common::SparseBoolVector > && vector : ext::make_moveable_map ( m_vectors ) ) - vectors.insert ( std::make_pair ( alphabet::SymbolNormalize::normalizeSymbol ( std::move ( vector.first ) ), std::move ( vector.second ) ) ); + ext::set < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > alphabet = alphabet::SymbolNormalize::normalizeRankedAlphabet ( std::move ( this->template accessComponent < GeneralAlphabet > ( ).get ( ) ) ); + ext::map < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, common::SparseBoolVector > vectors; + for ( std::pair < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > && vector : ext::make_moveable_map ( m_vectors ) ) + vectors.insert ( std::make_pair ( alphabet::SymbolNormalize::normalizeRankedSymbol ( std::move ( vector.first ) ), std::move ( vector.second ) ) ); return new NonlinearCompressedBitParallelTreeIndex < > ( std::move ( alphabet ), std::move ( vectors ), std::move ( m_jumpTable ), std::move ( m_repeats ) ); } @@ -145,43 +144,43 @@ namespace indexes { namespace arbology { -template < class SymbolType > -NonlinearCompressedBitParallelTreeIndex < SymbolType >::NonlinearCompressedBitParallelTreeIndex ( ext::set < SymbolType > alphabet, ext::map < SymbolType, common::SparseBoolVector > vectors, ext::vector < int > jumpTable, ext::vector < unsigned > repeats ) : alib::Components < NonlinearCompressedBitParallelTreeIndex, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_vectors ( std::move ( vectors ) ), m_jumpTable ( std::move ( jumpTable ) ), m_repeats ( std::move ( repeats ) ) { +template < class SymbolType, class RankType > +NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::NonlinearCompressedBitParallelTreeIndex ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > vectors, ext::vector < int > jumpTable, ext::vector < unsigned > repeats ) : alib::Components < NonlinearCompressedBitParallelTreeIndex, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_vectors ( std::move ( vectors ) ), m_jumpTable ( std::move ( jumpTable ) ), m_repeats ( std::move ( repeats ) ) { } -template < class SymbolType > -alib::ObjectBase * NonlinearCompressedBitParallelTreeIndex < SymbolType >::clone ( ) const { +template < class SymbolType, class RankType > +alib::ObjectBase * NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::clone ( ) const { return new NonlinearCompressedBitParallelTreeIndex ( * this ); } -template < class SymbolType > -alib::ObjectBase * NonlinearCompressedBitParallelTreeIndex < SymbolType >::plunder ( ) && { +template < class SymbolType, class RankType > +alib::ObjectBase * NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::plunder ( ) && { return new NonlinearCompressedBitParallelTreeIndex ( std::move ( * this ) ); } -template < class SymbolType > -const ext::map < SymbolType, common::SparseBoolVector > & NonlinearCompressedBitParallelTreeIndex < SymbolType >::getData ( ) const { +template < class SymbolType, class RankType > +const ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::getData ( ) const { return m_vectors; } -template < class SymbolType > -const ext::vector < int > & NonlinearCompressedBitParallelTreeIndex < SymbolType >::getJumps ( ) const { +template < class SymbolType, class RankType > +const ext::vector < int > & NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::getJumps ( ) const { return m_jumpTable; } -template < class SymbolType > -const ext::vector < unsigned > & NonlinearCompressedBitParallelTreeIndex < SymbolType >::getRepeats ( ) const { +template < class SymbolType, class RankType > +const ext::vector < unsigned > & NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::getRepeats ( ) const { return m_repeats; } -template < class SymbolType > -ext::vector < SymbolType > NonlinearCompressedBitParallelTreeIndex < SymbolType >::getString ( ) const { - ext::vector < SymbolType > res; +template < class SymbolType, class RankType > +ext::vector < common::ranked_symbol < SymbolType, RankType > > NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::getString ( ) const { + ext::vector < common::ranked_symbol < SymbolType, RankType > > res; unsigned index = 0; do { - for ( const std::pair < const SymbolType, common::SparseBoolVector > & nonlinearcompressedBitVector : m_vectors ) + for ( const std::pair < const common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & nonlinearcompressedBitVector : m_vectors ) if ( nonlinearcompressedBitVector.second.size ( ) > index && nonlinearcompressedBitVector.second [ index ] ) { res.push_back ( nonlinearcompressedBitVector.first ); continue; @@ -192,18 +191,18 @@ ext::vector < SymbolType > NonlinearCompressedBitParallelTreeIndex < SymbolType return res; } -template < class SymbolType > -void NonlinearCompressedBitParallelTreeIndex < SymbolType >::setNonlinearCompressedBitVectorForSymbol ( SymbolType symbol, common::SparseBoolVector data ) { +template < class SymbolType, class RankType > +void NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::setNonlinearCompressedBitVectorForSymbol ( common::ranked_symbol < SymbolType, RankType > symbol, common::SparseBoolVector data ) { this->m_vectors [ symbol ] = std::move ( data ); } -template < class SymbolType > -void NonlinearCompressedBitParallelTreeIndex < SymbolType >::operator >>( std::ostream & out ) const { +template < class SymbolType, class RankType > +void NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::operator >>( std::ostream & out ) const { out << "(NonlinearCompressedBitParallelTreeIndex " << this->m_vectors << ", " << m_jumpTable << ")"; } -template < class SymbolType > -int NonlinearCompressedBitParallelTreeIndex < SymbolType >::compare ( const NonlinearCompressedBitParallelTreeIndex & other ) const { +template < class SymbolType, class RankType > +int NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::compare ( const NonlinearCompressedBitParallelTreeIndex & other ) const { auto first = ext::tie ( getData ( ), getAlphabet ( ), getJumps ( ), getRepeats ( ) ); auto second = ext::tie ( other.getData ( ), other.getAlphabet ( ), other.getJumps ( ), getRepeats ( ) ); @@ -212,39 +211,39 @@ int NonlinearCompressedBitParallelTreeIndex < SymbolType >::compare ( const Nonl return comp ( first, second ); } -template < class SymbolType > -NonlinearCompressedBitParallelTreeIndex < SymbolType >::operator std::string ( ) const { +template < class SymbolType, class RankType > +NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::operator std::string ( ) const { std::stringstream ss; ss << * this; return ss.str ( ); } -template < class SymbolType > -NonlinearCompressedBitParallelTreeIndex < SymbolType > NonlinearCompressedBitParallelTreeIndex < SymbolType >::parse ( ext::deque < sax::Token >::iterator & input ) { +template < class SymbolType, class RankType > +NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::parse ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, NonlinearCompressedBitParallelTreeIndex::getXmlTagName ( ) ); - ext::set < SymbolType > alphabet = alib::xmlApi < ext::set < SymbolType > >::parse ( input ); - ext::map < SymbolType, common::SparseBoolVector > data = alib::xmlApi < ext::map < SymbolType, common::SparseBoolVector > >::parse ( input ); + ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet = alib::xmlApi < ext::set < common::ranked_symbol < SymbolType, RankType > > >::parse ( input ); + ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > data = alib::xmlApi < ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > >::parse ( input ); ext::vector < int > jumps = alib::xmlApi < ext::vector < int > >::parse ( input ); ext::vector < unsigned > repeats = alib::xmlApi < ext::vector < unsigned > >::parse ( input ); - NonlinearCompressedBitParallelTreeIndex < SymbolType > res ( std::move ( alphabet ), std::move ( data ), std::move ( jumps ), std::move ( repeats ) ); + NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > res ( std::move ( alphabet ), std::move ( data ), std::move ( jumps ), std::move ( repeats ) ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, NonlinearCompressedBitParallelTreeIndex::getXmlTagName ( ) ); return res; } -template < class SymbolType > -void NonlinearCompressedBitParallelTreeIndex < SymbolType >::compose ( ext::deque < sax::Token > & out ) const { +template < class SymbolType, class RankType > +void NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::compose ( ext::deque < sax::Token > & out ) const { out.emplace_back ( NonlinearCompressedBitParallelTreeIndex::getXmlTagName ( ), sax::Token::TokenType::START_ELEMENT ); - alib::xmlApi < ext::set < SymbolType > >::compose ( out, getAlphabet ( ) ); - alib::xmlApi < ext::map < SymbolType, common::SparseBoolVector > >::compose ( out, getData ( ) ); + alib::xmlApi < ext::set < common::ranked_symbol < SymbolType, RankType > > >::compose ( out, getAlphabet ( ) ); + alib::xmlApi < ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > >::compose ( out, getData ( ) ); alib::xmlApi < ext::vector < int > >::compose ( out, getJumps ( ) ); alib::xmlApi < ext::vector < unsigned > >::compose ( out, getRepeats ( ) ); out.emplace_back ( NonlinearCompressedBitParallelTreeIndex::getXmlTagName ( ), sax::Token::TokenType::END_ELEMENT ); } -template < class SymbolType > -alib::ObjectBase * NonlinearCompressedBitParallelTreeIndex < SymbolType >::inc ( ) && { +template < class SymbolType, class RankType > +alib::ObjectBase * NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::inc ( ) && { return new alib::UniqueObject ( alib::Object ( std::move ( * this ) ), primitive::Integer ( 0 ) ); } @@ -254,20 +253,20 @@ alib::ObjectBase * NonlinearCompressedBitParallelTreeIndex < SymbolType >::inc ( namespace alib { -template < class SymbolType > -class ComponentConstraint < indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType >, SymbolType, indexes::arbology::GeneralAlphabet > { +template < class SymbolType, class RankType > +class ComponentConstraint < indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, indexes::arbology::GeneralAlphabet > { public: - static bool used ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType > & index, const SymbolType & symbol ) { - const ext::map < SymbolType, common::SparseBoolVector > & content = index.getData ( ); + static bool used ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > & index, const common::ranked_symbol < SymbolType, RankType > & symbol ) { + const ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & content = index.getData ( ); return content.find ( symbol ) != content.end ( ); } - static bool available ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType > &, const SymbolType & ) { + static bool available ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) { return true; } - static void valid ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType > &, const SymbolType & ) { + static void valid ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) { } }; diff --git a/alib2data/src/indexes/arbology/NonlinearFullAndLinearIndex.h b/alib2data/src/indexes/arbology/NonlinearFullAndLinearIndex.h index cc184a4a6b415c20e2105013c1c1225662dbd13c..aa2f74b320b7864338769e19b698faee4c55158d 100644 --- a/alib2data/src/indexes/arbology/NonlinearFullAndLinearIndex.h +++ b/alib2data/src/indexes/arbology/NonlinearFullAndLinearIndex.h @@ -9,10 +9,9 @@ #define ARBOLOGY_NONLINEAR_FULL_AND_LINEAR_INDEX_H_ #include <string> -#include <iostream> #include <sstream> -#include <common/DefaultSymbolType.h> +#include <alphabet/RankedSymbol.h> #include <object/UniqueObject.h> #include <object/ObjectBase.h> @@ -36,10 +35,10 @@ class GeneralAlphabet; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of RegExpElement. */ -template < class SymbolType = DefaultSymbolType > +template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType > class NonlinearFullAndLinearIndex final : public alib::ObjectBase { protected: - indexes::stringology::PositionHeap < SymbolType > m_StringIndex; + indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > m_StringIndex; ext::vector < int > m_JumpTable; ext::vector < unsigned > m_Repeats; @@ -54,12 +53,12 @@ public: */ virtual ObjectBase * plunder ( ) &&; - explicit NonlinearFullAndLinearIndex ( indexes::stringology::PositionHeap < SymbolType > stringIndex, ext::vector < int > jumpTable, ext::vector < unsigned > repeats ); + explicit NonlinearFullAndLinearIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable, ext::vector < unsigned > repeats ); /** * @return Root node of the trie */ - const indexes::stringology::PositionHeap < SymbolType > & getStringIndex ( ) const; + const indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > & getStringIndex ( ) const; /** * @return subtree jump table @@ -71,9 +70,9 @@ public: */ const ext::vector < unsigned > & getRepeats ( ) const; - const ext::vector < SymbolType > & getString ( ) const; + const ext::vector < common::ranked_symbol < SymbolType, RankType > > & getString ( ) const; - const ext::set < SymbolType > & getAlphabet ( ) const { + const ext::set < common::ranked_symbol < SymbolType, RankType > > & getAlphabet ( ) const { return m_StringIndex.getAlphabet ( ); } @@ -81,13 +80,13 @@ public: * Sets the compressedBit vector for given symbol * @param tree root node to set */ - void setStringIndex ( indexes::stringology::PositionHeap < SymbolType > stringIndex ); + void setStringIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex ); /** * Removes symbol from the alphabet of symbol available in the regular expression * @param symbol removed symbol from the alphabet */ - bool removeSymbolFromAlphabet ( const SymbolType & symbol ) { + bool removeSymbolFromAlphabet ( const common::ranked_symbol < SymbolType, RankType > & symbol ) { return m_StringIndex.removeSymbolFromAlphabet ( symbol ); } @@ -123,10 +122,10 @@ public: typedef NonlinearFullAndLinearIndex < > normalized_type; virtual ObjectBase * normalize ( ) && { - if ( typeid ( NonlinearFullAndLinearIndex < > ) == typeid ( NonlinearFullAndLinearIndex < SymbolType > ) ) + if ( typeid ( NonlinearFullAndLinearIndex < > ) == typeid ( NonlinearFullAndLinearIndex < SymbolType, RankType > ) ) return this; - indexes::stringology::PositionHeap < DefaultSymbolType > stringIndex = std::move ( m_StringIndex ).normalizeRaw ( ); + indexes::stringology::PositionHeap < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > stringIndex = std::move ( m_StringIndex ).normalizeRankedRaw ( ); return new NonlinearFullAndLinearIndex < > ( std::move ( stringIndex ), std::move ( m_JumpTable ), std::move ( m_Repeats ) ); } @@ -140,52 +139,52 @@ namespace indexes { namespace arbology { -template < class SymbolType > -NonlinearFullAndLinearIndex < SymbolType >::NonlinearFullAndLinearIndex ( indexes::stringology::PositionHeap < SymbolType > stringIndex, ext::vector < int > jumpTable, ext::vector < unsigned > repeats ) : m_StringIndex ( std::move ( stringIndex ) ), m_JumpTable ( std::move ( jumpTable ) ), m_Repeats ( std::move ( repeats ) ) { +template < class SymbolType, class RankType > +NonlinearFullAndLinearIndex < SymbolType, RankType >::NonlinearFullAndLinearIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable, ext::vector < unsigned > repeats ) : m_StringIndex ( std::move ( stringIndex ) ), m_JumpTable ( std::move ( jumpTable ) ), m_Repeats ( std::move ( repeats ) ) { } -template < class SymbolType > -alib::ObjectBase * NonlinearFullAndLinearIndex < SymbolType >::clone ( ) const { +template < class SymbolType, class RankType > +alib::ObjectBase * NonlinearFullAndLinearIndex < SymbolType, RankType >::clone ( ) const { return new NonlinearFullAndLinearIndex ( * this ); } -template < class SymbolType > -alib::ObjectBase * NonlinearFullAndLinearIndex < SymbolType >::plunder ( ) && { +template < class SymbolType, class RankType > +alib::ObjectBase * NonlinearFullAndLinearIndex < SymbolType, RankType >::plunder ( ) && { return new NonlinearFullAndLinearIndex ( std::move ( * this ) ); } -template < class SymbolType > -const indexes::stringology::PositionHeap < SymbolType > & NonlinearFullAndLinearIndex < SymbolType >::getStringIndex ( ) const { +template < class SymbolType, class RankType > +const indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > & NonlinearFullAndLinearIndex < SymbolType, RankType >::getStringIndex ( ) const { return m_StringIndex; } -template < class SymbolType > -const ext::vector < int > & NonlinearFullAndLinearIndex < SymbolType >::getJumps ( ) const { +template < class SymbolType, class RankType > +const ext::vector < int > & NonlinearFullAndLinearIndex < SymbolType, RankType >::getJumps ( ) const { return m_JumpTable; } -template < class SymbolType > -const ext::vector < unsigned > & NonlinearFullAndLinearIndex < SymbolType >::getRepeats ( ) const { +template < class SymbolType, class RankType > +const ext::vector < unsigned > & NonlinearFullAndLinearIndex < SymbolType, RankType >::getRepeats ( ) const { return m_Repeats; } -template < class SymbolType > -const ext::vector < SymbolType > & NonlinearFullAndLinearIndex < SymbolType >::getString ( ) const { +template < class SymbolType, class RankType > +const ext::vector < common::ranked_symbol < SymbolType, RankType > > & NonlinearFullAndLinearIndex < SymbolType, RankType >::getString ( ) const { return m_StringIndex.getString ( ); } -template < class SymbolType > -void NonlinearFullAndLinearIndex < SymbolType >::setStringIndex ( indexes::stringology::PositionHeap < SymbolType > stringIndex ) { +template < class SymbolType, class RankType > +void NonlinearFullAndLinearIndex < SymbolType, RankType >::setStringIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex ) { this->m_StringIndex = std::move ( stringIndex ); } -template < class SymbolType > -void NonlinearFullAndLinearIndex < SymbolType >::operator >>( std::ostream & out ) const { +template < class SymbolType, class RankType > +void NonlinearFullAndLinearIndex < SymbolType, RankType >::operator >>( std::ostream & out ) const { out << "(NonlinearFullAndLinearIndex " << this->m_StringIndex << ", " << m_JumpTable << ")"; } -template < class SymbolType > -int NonlinearFullAndLinearIndex < SymbolType >::compare ( const NonlinearFullAndLinearIndex & other ) const { +template < class SymbolType, class RankType > +int NonlinearFullAndLinearIndex < SymbolType, RankType >::compare ( const NonlinearFullAndLinearIndex & other ) const { auto first = ext::tie ( getStringIndex ( ), getJumps ( ), getRepeats ( ) ); auto second = ext::tie ( other.getStringIndex ( ), other.getJumps ( ), other.getRepeats ( ) ); @@ -194,37 +193,37 @@ int NonlinearFullAndLinearIndex < SymbolType >::compare ( const NonlinearFullAnd return comp ( first, second ); } -template < class SymbolType > -NonlinearFullAndLinearIndex < SymbolType >::operator std::string ( ) const { +template < class SymbolType, class RankType > +NonlinearFullAndLinearIndex < SymbolType, RankType >::operator std::string ( ) const { std::stringstream ss; ss << * this; return ss.str ( ); } -template < class SymbolType > -NonlinearFullAndLinearIndex < SymbolType > NonlinearFullAndLinearIndex < SymbolType >::parse ( ext::deque < sax::Token >::iterator & input ) { +template < class SymbolType, class RankType > +NonlinearFullAndLinearIndex < SymbolType, RankType > NonlinearFullAndLinearIndex < SymbolType, RankType >::parse ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, NonlinearFullAndLinearIndex::getXmlTagName ( ) ); - indexes::stringology::PositionHeap < SymbolType > stringIndex = alib::xmlApi < indexes::stringology::PositionHeap < SymbolType > >::parse ( input ); + indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex = alib::xmlApi < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::parse ( input ); ext::vector < int > jumps = alib::xmlApi < ext::vector < int > >::parse ( input ); ext::vector < unsigned > repeats = alib::xmlApi < ext::vector < unsigned > >::parse ( input ); - NonlinearFullAndLinearIndex < SymbolType > res ( std::move ( stringIndex ), std::move ( jumps ), std::move ( repeats ) ); + NonlinearFullAndLinearIndex < SymbolType, RankType > res ( std::move ( stringIndex ), std::move ( jumps ), std::move ( repeats ) ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, NonlinearFullAndLinearIndex::getXmlTagName ( ) ); return res; } -template < class SymbolType > -void NonlinearFullAndLinearIndex < SymbolType >::compose ( ext::deque < sax::Token > & out ) const { +template < class SymbolType, class RankType > +void NonlinearFullAndLinearIndex < SymbolType, RankType >::compose ( ext::deque < sax::Token > & out ) const { out.emplace_back ( NonlinearFullAndLinearIndex::getXmlTagName ( ), sax::Token::TokenType::START_ELEMENT ); - alib::xmlApi < indexes::stringology::PositionHeap < SymbolType > >::compose ( out, getStringIndex ( ) ); + alib::xmlApi < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::compose ( out, getStringIndex ( ) ); alib::xmlApi < ext::vector < int > >::compose ( out, getJumps ( ) ); alib::xmlApi < ext::vector < unsigned > >::compose ( out, getRepeats ( ) ); out.emplace_back ( NonlinearFullAndLinearIndex::getXmlTagName ( ), sax::Token::TokenType::END_ELEMENT ); } -template < class SymbolType > -alib::ObjectBase * NonlinearFullAndLinearIndex < SymbolType >::inc ( ) && { +template < class SymbolType, class RankType > +alib::ObjectBase * NonlinearFullAndLinearIndex < SymbolType, RankType >::inc ( ) && { return new alib::UniqueObject ( alib::Object ( std::move ( * this ) ), primitive::Integer ( 0 ) ); } diff --git a/alib2data/src/indexes/common/IndexesNormalize.h b/alib2data/src/indexes/common/IndexesNormalize.h index 2891d0dbb0a79d418b35b410d96a091f30e87c87..0f442278d5d4acb18cc40fc8d6b8d65789db3ca2 100644 --- a/alib2data/src/indexes/common/IndexesNormalize.h +++ b/alib2data/src/indexes/common/IndexesNormalize.h @@ -33,12 +33,30 @@ class IndexesNormalize { return ext::trie < DefaultSymbolType, ValueType > ( std::move ( node.getData ( ) ), std::move ( children ) ); } + template < class SymbolType, class RankType, class ValueType > + static ext::trie < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, ValueType > normalizeRankedTrieInner ( ext::trie < common::ranked_symbol < SymbolType, RankType >, ValueType > && node ) { + ext::map < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, ext::trie < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, ValueType > > children; + + for ( std::pair < common::ranked_symbol < SymbolType, RankType >, ext::trie < common::ranked_symbol < SymbolType, RankType >, ValueType > > && child : ext::make_moveable_map ( node.getChildren ( ) ) ) { + children.insert ( std::make_pair ( alphabet::SymbolNormalize::normalizeRankedSymbol ( std::move ( child.first ) ), normalizeRankedTrieInner ( std::move ( child.second ) ) ) ); + } + + return ext::trie < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, ValueType > ( std::move ( node.getData ( ) ), std::move ( children ) ); + } + public: template < class SymbolType > static ext::trie < DefaultSymbolType, unsigned > normalizeTrie ( ext::trie < SymbolType, unsigned > && trie ); template < class SymbolType > static ext::trie < DefaultSymbolType, ext::variant < void, unsigned > > normalizeTrie ( ext::trie < SymbolType, ext::variant < void, unsigned > > && trie ); + + template < class SymbolType, class RankType > + static ext::trie < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, unsigned > normalizeRankedTrie ( ext::trie < common::ranked_symbol < SymbolType, RankType >, unsigned > && trie ); + + template < class SymbolType, class RankType > + static ext::trie < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, ext::variant < void, unsigned > > normalizeRankedTrie ( ext::trie < common::ranked_symbol < SymbolType, RankType >, ext::variant < void, unsigned > > && trie ); + }; template < class SymbolType > @@ -51,6 +69,16 @@ ext::trie < DefaultSymbolType, ext::variant < void, unsigned > > IndexesNormaliz return normalizeTrieInner ( std::move ( trie ) ) ; } +template < class SymbolType, class RankType > +ext::trie < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, unsigned > IndexesNormalize::normalizeRankedTrie ( ext::trie < common::ranked_symbol < SymbolType, RankType >, unsigned > && trie ) { + return normalizeRankedTrieInner ( std::move ( trie ) ) ; +} + +template < class SymbolType, class RankType > +ext::trie < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, ext::variant < void, unsigned > > IndexesNormalize::normalizeRankedTrie ( ext::trie < common::ranked_symbol < SymbolType, RankType >, ext::variant < void, unsigned > > && trie ) { + return normalizeRankedTrieInner ( std::move ( trie ) ) ; +} + } /* namespace indexes */ #endif /* INDEXES_NORMALIZE_H_ */ diff --git a/alib2data/src/indexes/stringology/PositionHeap.h b/alib2data/src/indexes/stringology/PositionHeap.h index 7cea95e7b42e6e3780f6af405f402656eda7ab3b..267897925e9c379f9e77cbb49667402fc71a3c93 100644 --- a/alib2data/src/indexes/stringology/PositionHeap.h +++ b/alib2data/src/indexes/stringology/PositionHeap.h @@ -124,6 +124,14 @@ public: typedef PositionHeap < > normalized_type; + PositionHeap < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > normalizeRankedRaw ( ) && { + ext::set < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > alphabet = alphabet::SymbolNormalize::normalizeRankedAlphabet ( std::move ( this->template accessComponent < GeneralAlphabet > ( ).get ( ) ) ); + ext::trie < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, unsigned > trie = IndexesNormalize::normalizeRankedTrie ( std::move ( m_trie ) ); + ext::vector < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > string = alphabet::SymbolNormalize::normalizeRankedSymbols ( std::move ( m_string ) ); + + return PositionHeap < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > ( std::move ( alphabet ), std::move ( trie ), std::move ( string ) ); + } + PositionHeap < > normalizeRaw ( ) && { ext::set < DefaultSymbolType > alphabet = alphabet::SymbolNormalize::normalizeAlphabet ( std::move ( this->template accessComponent < GeneralAlphabet > ( ).get ( ) ) ); ext::trie < DefaultSymbolType, unsigned > trie = IndexesNormalize::normalizeTrie ( std::move ( m_trie ) ); diff --git a/aquery2/src/aquery.cpp b/aquery2/src/aquery.cpp index b95b2a1e1858611d8ebc975fafeaefc6fa13d53f..c8a9de3692868bf095549d9daeeae477751d1ee9 100644 --- a/aquery2/src/aquery.cpp +++ b/aquery2/src/aquery.cpp @@ -135,7 +135,7 @@ int main ( int argc, char * argv[] ) { alib::XmlDataFactory::toStdout ( res ); } else if ( query.getValue ( ) == "compressedBitParallelismPatterns" ) { - indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > compressedBitParallelTreeIndex = alib::XmlDataFactory::fromTokens ( sax::FromXMLParserHelper::parseInput ( indexInput ) ); + indexes::arbology::CompressedBitParallelTreeIndex < > compressedBitParallelTreeIndex = alib::XmlDataFactory::fromTokens ( sax::FromXMLParserHelper::parseInput ( indexInput ) ); tree::RankedTreeWrapper pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); measurements::end ( ); @@ -148,7 +148,7 @@ int main ( int argc, char * argv[] ) { alib::XmlDataFactory::toStdout ( res ); } else if ( query.getValue ( ) == "nonlinearCompressedBitParallelismPatterns" ) { - indexes::arbology::NonlinearCompressedBitParallelTreeIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > nonlinearCompressedBitParallelTreeIndex = alib::XmlDataFactory::fromTokens ( sax::FromXMLParserHelper::parseInput ( indexInput ) ); + indexes::arbology::NonlinearCompressedBitParallelTreeIndex < > nonlinearCompressedBitParallelTreeIndex = alib::XmlDataFactory::fromTokens ( sax::FromXMLParserHelper::parseInput ( indexInput ) ); tree::RankedTreeWrapper pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); measurements::end ( ); @@ -161,7 +161,7 @@ int main ( int argc, char * argv[] ) { alib::XmlDataFactory::toStdout ( res ); } else if ( query.getValue ( ) == "fullAndLinearIndexPatterns" ) { - indexes::arbology::FullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > fullAndLinearIndex = alib::XmlDataFactory::fromTokens ( sax::FromXMLParserHelper::parseInput ( indexInput ) ); + indexes::arbology::FullAndLinearIndex < > fullAndLinearIndex = alib::XmlDataFactory::fromTokens ( sax::FromXMLParserHelper::parseInput ( indexInput ) ); tree::RankedTreeWrapper pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); measurements::end ( ); @@ -174,7 +174,7 @@ int main ( int argc, char * argv[] ) { alib::XmlDataFactory::toStdout ( res ); } else if ( query.getValue ( ) == "nonlinearFullAndLinearIndexPatterns" ) { - indexes::arbology::NonlinearFullAndLinearIndex < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > nonlinearFullAndLinearIndex = alib::XmlDataFactory::fromTokens ( sax::FromXMLParserHelper::parseInput ( indexInput ) ); + indexes::arbology::NonlinearFullAndLinearIndex < > nonlinearFullAndLinearIndex = alib::XmlDataFactory::fromTokens ( sax::FromXMLParserHelper::parseInput ( indexInput ) ); tree::RankedTreeWrapper pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); measurements::end ( );