diff --git a/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.h b/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.h index 46d376ea5babd086f767501f3d8408fe5fb76572..b5d1ca778881bd66a10cee4f33e889fa938d75db 100644 --- a/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.h +++ b/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.h @@ -30,21 +30,21 @@ public: * @param tree tree to construct the index for * @return the index */ - template < class SymbolType, class RankType > + template < class SymbolType, class RankType, template < typename > class StringIndex = indexes::stringology::PositionHeap, class StringIndexConstructionAlgo = stringology::indexing::PositionHeapNaive > static indexes::arbology::FullAndLinearIndex < SymbolType, RankType > construct ( const tree::PrefixRankedTree < SymbolType, RankType > & tree ); - template < class SymbolType, class RankType > + template < class SymbolType, class RankType, template < typename > class StringIndex = indexes::stringology::PositionHeap, class StringIndexConstructionAlgo = stringology::indexing::PositionHeapNaive > static indexes::arbology::FullAndLinearIndex < SymbolType, RankType > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree ); }; -template < class SymbolType, class RankType > +template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexConstructionAlgo > 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 ) ); + return indexes::arbology::FullAndLinearIndex < SymbolType, RankType > ( StringIndexConstructionAlgo::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) ); } -template < class SymbolType, class RankType > +template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexConstructionAlgo > 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 ) ); + return indexes::arbology::FullAndLinearIndex < SymbolType, RankType > ( StringIndexConstructionAlgo::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) ); } } /* namespace indexing */ diff --git a/alib2algo/src/arbology/indexing/NonlinearFullAndLinearIndexConstruction.h b/alib2algo/src/arbology/indexing/NonlinearFullAndLinearIndexConstruction.h index f5e68d9e113f5465cb3208dede2abcbc7d26ddff..34cc2bd245667fd21a1f7561036f24f68d5b5886 100644 --- a/alib2algo/src/arbology/indexing/NonlinearFullAndLinearIndexConstruction.h +++ b/alib2algo/src/arbology/indexing/NonlinearFullAndLinearIndexConstruction.h @@ -30,33 +30,33 @@ public: * @param tree tree to construct the index for * @return the index */ - template < class SymbolType, class RankType > - static indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > construct ( const tree::PrefixRankedTree < SymbolType, RankType > & tree ); + template < class SymbolType, class RankType, template < typename > class StringIndex = indexes::stringology::PositionHeap, class StringIndexConstructionAlgo = stringology::indexing::PositionHeapNaive > + static indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > construct ( const tree::PrefixRankedTree < SymbolType, RankType > & tree ); - template < class SymbolType, class RankType > - static indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree ); + template < class SymbolType, class RankType, template < typename > class StringIndex = indexes::stringology::PositionHeap, class StringIndexConstructionAlgo = stringology::indexing::PositionHeapNaive > + static indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree ); }; -template < class SymbolType, class RankType > -indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > NonlinearFullAndLinearIndexConstruction::construct ( const tree::PrefixRankedTree < SymbolType, RankType > & w ) { +template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexConstructionAlgo > +indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > 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 < 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, StringIndex > ( StringIndexConstructionAlgo::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ), repeats ); } -template < class SymbolType, class RankType > -indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > NonlinearFullAndLinearIndexConstruction::construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & w ) { +template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexConstructionAlgo > +indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > 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 < SymbolType, RankType > ( stringology::indexing::PositionHeapNaive::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ), std::move ( repeats ) ); + return indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > ( StringIndexConstructionAlgo::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ), std::move ( repeats ) ); } } /* namespace indexing */ diff --git a/alib2algo/src/arbology/query/FullAndLinearIndexPatterns.h b/alib2algo/src/arbology/query/FullAndLinearIndexPatterns.h index 365ed27511d2e00c03a012095afbe13fa646e341..eea3475d48dfaebe5eacc8d874d21e92159f8d0a 100644 --- a/alib2algo/src/arbology/query/FullAndLinearIndexPatterns.h +++ b/alib2algo/src/arbology/query/FullAndLinearIndexPatterns.h @@ -25,10 +25,10 @@ namespace query { */ class FullAndLinearIndexPatterns { - 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 ) { + template < class StringIndexQueryAlgo, class SymbolType, class RankType, template < typename > class StringIndex > + static ext::vector < std::pair < unsigned, unsigned > > FindOccurrences ( const StringIndex < common::ranked_symbol < SymbolType, RankType > > & stringIndex, const ext::vector < common::ranked_symbol < SymbolType, RankType > > & string ) { ext::vector < std::pair < unsigned, unsigned > > res; - for ( unsigned occurrence : stringology::query::PositionHeapFactors::query ( stringIndex, string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( string ) ) ) { + for ( unsigned occurrence : StringIndexQueryAlgo::query ( stringIndex, string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( string ) ) ) { res.push_back ( std::make_pair ( occurrence, occurrence + string.size ( ) ) ); } return res; @@ -59,15 +59,15 @@ public: * @param tree tree to query by * @return occurences of factors */ - template < class SymbolType, class RankType > - static ext::set < unsigned > query ( const indexes::arbology::FullAndLinearIndex < SymbolType, RankType > & compressedBitParallelTreeIndex, const tree::PrefixRankedPattern < SymbolType, RankType > & pattern ); + template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexQueryAlgo = stringology::query::PositionHeapFactors > + static ext::set < unsigned > query ( const indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > & compressedBitParallelTreeIndex, const tree::PrefixRankedPattern < SymbolType, RankType > & pattern ); - template < class SymbolType, class RankType > - static ext::set < unsigned > query ( const indexes::arbology::FullAndLinearIndex < SymbolType, RankType > & compressedBitParallelTreeIndex, const tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern ); + template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexQueryAlgo = stringology::query::PositionHeapFactors > + static ext::set < unsigned > query ( const indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > & compressedBitParallelTreeIndex, const tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern ); }; -template < class SymbolType, class RankType > -ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbology::FullAndLinearIndex < SymbolType, RankType > & fullAndLinearIndex, const tree::PrefixRankedPattern < SymbolType, RankType > & pattern ) { +template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexQueryAlgo > +ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > & 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; @@ -80,14 +80,14 @@ ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbolog } } - ext::vector < std::pair < unsigned, unsigned > > prevOcc = FindOccurrences ( fullAndLinearIndex.getStringIndex ( ) , treePatternParts [ 0 ] ); + ext::vector < std::pair < unsigned, unsigned > > prevOcc = FindOccurrences < StringIndexQueryAlgo > ( fullAndLinearIndex.getStringIndex ( ) , treePatternParts [ 0 ] ); for ( unsigned i = 1; i < treePatternParts.size ( ); ++ i ) { for ( std::pair < unsigned, unsigned > & occurrence : prevOcc ) occurrence.second = fullAndLinearIndex.getJumps ( ) [ occurrence.second ]; if ( ! treePatternParts [ i ].empty ( ) ) - prevOcc = MergeOccurrences ( prevOcc, FindOccurrences ( fullAndLinearIndex.getStringIndex ( ), treePatternParts [ i ] ), rev ); + prevOcc = MergeOccurrences ( prevOcc, FindOccurrences < StringIndexQueryAlgo > ( fullAndLinearIndex.getStringIndex ( ), treePatternParts [ i ] ), rev ); } ext::set < unsigned > res; @@ -98,8 +98,8 @@ ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbolog return res; } -template < class SymbolType, class RankType > -ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbology::FullAndLinearIndex < SymbolType, RankType > & fullAndLinearIndex, const tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern ) { +template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexQueryAlgo > +ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > & 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; @@ -113,14 +113,14 @@ ext::set < unsigned > FullAndLinearIndexPatterns::query ( const indexes::arbolog } } - ext::vector < std::pair < unsigned, unsigned > > prevOcc = FindOccurrences ( fullAndLinearIndex.getStringIndex ( ) , treePatternParts [ 0 ] ); + ext::vector < std::pair < unsigned, unsigned > > prevOcc = FindOccurrences < StringIndexQueryAlgo > ( fullAndLinearIndex.getStringIndex ( ), treePatternParts [ 0 ] ); for ( unsigned i = 1; i < treePatternParts.size ( ); ++ i ) { for ( std::pair < unsigned, unsigned > & occurrence : prevOcc ) occurrence.second = fullAndLinearIndex.getJumps ( ) [ occurrence.second ]; if ( ! treePatternParts [ i ].empty ( ) ) - prevOcc = MergeOccurrences ( prevOcc, FindOccurrences ( fullAndLinearIndex.getStringIndex ( ), treePatternParts [ i ] ), rev ); + prevOcc = MergeOccurrences ( prevOcc, FindOccurrences < StringIndexQueryAlgo > ( fullAndLinearIndex.getStringIndex ( ), treePatternParts [ i ] ), rev ); } ext::set < unsigned > res; diff --git a/alib2algo/src/arbology/query/NonlinearFullAndLinearIndexPatterns.h b/alib2algo/src/arbology/query/NonlinearFullAndLinearIndexPatterns.h index 798392eeee957dd81a01966188f1444963ef2af6..1f1c3bc5318f8ac56cfbc8f44787e837b6456896 100644 --- a/alib2algo/src/arbology/query/NonlinearFullAndLinearIndexPatterns.h +++ b/alib2algo/src/arbology/query/NonlinearFullAndLinearIndexPatterns.h @@ -25,10 +25,10 @@ namespace query { */ class NonlinearFullAndLinearIndexPatterns { - 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 ) { + template < class StringIndexQueryAlgo, class SymbolType, class RankType, template < typename > class StringIndex > + static ext::vector < std::pair < unsigned, unsigned > > FindOccurrences ( const StringIndex < common::ranked_symbol < SymbolType, RankType > > & stringIndex, const ext::vector < common::ranked_symbol < SymbolType, RankType > > & string ) { ext::vector < std::pair < unsigned, unsigned > > res; - for ( unsigned occurrence : stringology::query::PositionHeapFactors::query ( stringIndex, string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( string ) ) ) { + for ( unsigned occurrence : StringIndexQueryAlgo::query ( stringIndex, string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( string ) ) ) { res.push_back ( std::make_pair ( occurrence, occurrence + string.size ( ) ) ); } return res; @@ -59,15 +59,15 @@ public: * @param tree tree to query by * @return occurences of factors */ - template < class SymbolType, class RankType > - static ext::set < unsigned > query ( const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > & compressedBitParallelTreeIndex, const tree::PrefixRankedNonlinearPattern < SymbolType, RankType > & pattern ); + template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexQueryAlgo = stringology::query::PositionHeapFactors > + static ext::set < unsigned > query ( const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > & compressedBitParallelTreeIndex, const tree::PrefixRankedNonlinearPattern < SymbolType, RankType > & pattern ); - template < class SymbolType, class RankType > - static ext::set < unsigned > query ( const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > & compressedBitParallelTreeIndex, const tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern ); + template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexQueryAlgo = stringology::query::PositionHeapFactors > + static ext::set < unsigned > query ( const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > & compressedBitParallelTreeIndex, const tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern ); }; -template < class SymbolType, class RankType > -ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > & fullAndLinearIndex, const tree::PrefixRankedNonlinearPattern < SymbolType, RankType > & pattern ) { +template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexQueryAlgo > +ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > & 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 ); @@ -83,7 +83,7 @@ ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes } } - ext::vector < std::pair < unsigned, unsigned > > prevOcc = FindOccurrences ( fullAndLinearIndex.getStringIndex ( ) , treePatternParts [ 0 ] ); + ext::vector < std::pair < unsigned, unsigned > > prevOcc = FindOccurrences < StringIndexQueryAlgo > ( fullAndLinearIndex.getStringIndex ( ), treePatternParts [ 0 ] ); for ( unsigned i = 1; i < treePatternParts.size ( ); ++ i ) { for ( std::pair < unsigned, unsigned > & occurrence : prevOcc ) { @@ -100,7 +100,7 @@ ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes ++ i; if ( ! treePatternParts [ i ].empty ( ) ) - prevOcc = MergeOccurrences ( prevOcc, FindOccurrences ( fullAndLinearIndex.getStringIndex ( ), treePatternParts [ i ] ), rev ); + prevOcc = MergeOccurrences ( prevOcc, FindOccurrences < StringIndexQueryAlgo > ( fullAndLinearIndex.getStringIndex ( ), treePatternParts [ i ] ), rev ); } ext::set < unsigned > res; @@ -112,8 +112,8 @@ ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes return res; } -template < class SymbolType, class RankType > -ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > & fullAndLinearIndex, const tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern ) { +template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexQueryAlgo > +ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > & 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 ); @@ -132,7 +132,7 @@ ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes } } - ext::vector < std::pair < unsigned, unsigned > > prevOcc = FindOccurrences ( fullAndLinearIndex.getStringIndex ( ) , treePatternParts [ 0 ] ); + ext::vector < std::pair < unsigned, unsigned > > prevOcc = FindOccurrences < StringIndexQueryAlgo > ( fullAndLinearIndex.getStringIndex ( ) , treePatternParts [ 0 ] ); for ( unsigned i = 1; i < treePatternParts.size ( ); ++ i ) { for ( std::pair < unsigned, unsigned > & occurrence : prevOcc ) { @@ -149,7 +149,7 @@ ext::set < unsigned > NonlinearFullAndLinearIndexPatterns::query ( const indexes ++ i; if ( ! treePatternParts [ i ].empty ( ) ) - prevOcc = MergeOccurrences ( prevOcc, FindOccurrences ( fullAndLinearIndex.getStringIndex ( ), treePatternParts [ i ] ), rev ); + prevOcc = MergeOccurrences ( prevOcc, FindOccurrences < StringIndexQueryAlgo > ( fullAndLinearIndex.getStringIndex ( ), treePatternParts [ i ] ), rev ); } ext::set < unsigned > res; diff --git a/alib2data/src/indexes/arbology/FullAndLinearIndex.h b/alib2data/src/indexes/arbology/FullAndLinearIndex.h index 304c9feaa6306b202d676eb4cb45d8a17bf93e81..5cdc99cf1e9556dcc4ad8e79048c488ed95d9e8f 100644 --- a/alib2data/src/indexes/arbology/FullAndLinearIndex.h +++ b/alib2data/src/indexes/arbology/FullAndLinearIndex.h @@ -39,7 +39,7 @@ class GeneralAlphabet; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of RegExpElement. */ -template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType > +template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType, template < typename > class StringIndex = indexes::stringology::PositionHeap > class FullAndLinearIndex final : public alib::ObjectBase { protected: indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > m_StringIndex; @@ -128,62 +128,62 @@ namespace indexes { namespace arbology { -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, class RankType, template < typename > class StringIndex > +FullAndLinearIndex < SymbolType, RankType, StringIndex >::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, class RankType > -alib::ObjectBase * FullAndLinearIndex < SymbolType, RankType >::clone ( ) const { +template < class SymbolType, class RankType, template < typename > class StringIndex > +alib::ObjectBase * FullAndLinearIndex < SymbolType, RankType, StringIndex >::clone ( ) const { return new FullAndLinearIndex ( * this ); } -template < class SymbolType, class RankType > -alib::ObjectBase * FullAndLinearIndex < SymbolType, RankType >::plunder ( ) && { +template < class SymbolType, class RankType, template < typename > class StringIndex > +alib::ObjectBase * FullAndLinearIndex < SymbolType, RankType, StringIndex >::plunder ( ) && { return new FullAndLinearIndex ( std::move ( * this ) ); } -template < class SymbolType, class RankType > -const indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > & FullAndLinearIndex < SymbolType, RankType >::getStringIndex ( ) const & { +template < class SymbolType, class RankType, template < typename > class StringIndex > +const indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > & FullAndLinearIndex < SymbolType, RankType, StringIndex >::getStringIndex ( ) const & { return m_StringIndex; } -template < class SymbolType, class RankType > -indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > && FullAndLinearIndex < SymbolType, RankType >::getStringIndex ( ) && { +template < class SymbolType, class RankType, template < typename > class StringIndex > +indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > && FullAndLinearIndex < SymbolType, RankType, StringIndex >::getStringIndex ( ) && { return std::move ( m_StringIndex ); } -template < class SymbolType, class RankType > -const ext::vector < int > & FullAndLinearIndex < SymbolType, RankType >::getJumps ( ) const & { +template < class SymbolType, class RankType, template < typename > class StringIndex > +const ext::vector < int > & FullAndLinearIndex < SymbolType, RankType, StringIndex >::getJumps ( ) const & { return m_JumpTable; } -template < class SymbolType, class RankType > -ext::vector < int > && FullAndLinearIndex < SymbolType, RankType >::getJumps ( ) && { +template < class SymbolType, class RankType, template < typename > class StringIndex > +ext::vector < int > && FullAndLinearIndex < SymbolType, RankType, StringIndex >::getJumps ( ) && { return std::move ( m_JumpTable ); } -template < class SymbolType, class RankType > -const ext::vector < common::ranked_symbol < SymbolType, RankType > > & FullAndLinearIndex < SymbolType, RankType >::getString ( ) const & { +template < class SymbolType, class RankType, template < typename > class StringIndex > +const ext::vector < common::ranked_symbol < SymbolType, RankType > > & FullAndLinearIndex < SymbolType, RankType, StringIndex >::getString ( ) const & { return m_StringIndex.getString ( ); } -template < class SymbolType, class RankType > -ext::vector < common::ranked_symbol < SymbolType, RankType > > && FullAndLinearIndex < SymbolType, RankType >::getString ( ) && { +template < class SymbolType, class RankType, template < typename > class StringIndex > +ext::vector < common::ranked_symbol < SymbolType, RankType > > && FullAndLinearIndex < SymbolType, RankType, StringIndex >::getString ( ) && { return std::move ( m_StringIndex ).getString ( ); } -template < class SymbolType, class RankType > -void FullAndLinearIndex < SymbolType, RankType >::setStringIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex ) { +template < class SymbolType, class RankType, template < typename > class StringIndex > +void FullAndLinearIndex < SymbolType, RankType, StringIndex >::setStringIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex ) { this->m_StringIndex = std::move ( stringIndex ); } -template < class SymbolType, class RankType > -void FullAndLinearIndex < SymbolType, RankType >::operator >>( std::ostream & out ) const { +template < class SymbolType, class RankType, template < typename > class StringIndex > +void FullAndLinearIndex < SymbolType, RankType, StringIndex >::operator >>( std::ostream & out ) const { out << "(FullAndLinearIndex " << this->m_StringIndex << ", " << m_JumpTable << ")"; } -template < class SymbolType, class RankType > -int FullAndLinearIndex < SymbolType, RankType >::compare ( const FullAndLinearIndex & other ) const { +template < class SymbolType, class RankType, template < typename > class StringIndex > +int FullAndLinearIndex < SymbolType, RankType, StringIndex >::compare ( const FullAndLinearIndex & other ) const { auto first = ext::tie ( getStringIndex ( ), getJumps ( ) ); auto second = ext::tie ( other.getStringIndex ( ), other.getJumps ( ) ); @@ -192,15 +192,15 @@ int FullAndLinearIndex < SymbolType, RankType >::compare ( const FullAndLinearIn return comp ( first, second ); } -template < class SymbolType, class RankType > -FullAndLinearIndex < SymbolType, RankType >::operator std::string ( ) const { +template < class SymbolType, class RankType, template < typename > class StringIndex > +FullAndLinearIndex < SymbolType, RankType, StringIndex >::operator std::string ( ) const { std::stringstream ss; ss << * this; return ss.str ( ); } -template < class SymbolType, class RankType > -alib::ObjectBase * FullAndLinearIndex < SymbolType, RankType >::inc ( ) && { +template < class SymbolType, class RankType, template < typename > class StringIndex > +alib::ObjectBase * FullAndLinearIndex < SymbolType, RankType, StringIndex >::inc ( ) && { return new alib::UniqueObject ( alib::Object ( std::move ( * this ) ), primitive::Integer ( 0 ) ); } @@ -210,49 +210,49 @@ alib::ObjectBase * FullAndLinearIndex < SymbolType, RankType >::inc ( ) && { namespace alib { -template < class SymbolType, class RankType > -struct normalize < indexes::arbology::FullAndLinearIndex < SymbolType, RankType >, typename std::enable_if < ! std::is_same < indexes::arbology::FullAndLinearIndex < SymbolType, RankType >, indexes::arbology::FullAndLinearIndex < > >::value >::type > { - static indexes::arbology::FullAndLinearIndex < > eval ( indexes::arbology::FullAndLinearIndex < SymbolType, RankType > && value ) { +template < class SymbolType, class RankType, template < typename > class StringIndex > +struct normalize < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex >, typename std::enable_if < ! std::is_same < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex >, indexes::arbology::FullAndLinearIndex < > >::value >::type > { + static indexes::arbology::FullAndLinearIndex < > eval ( indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > && value ) { indexes::stringology::PositionHeap < common::ranked_symbol < > > stringIndex = alib::normalize < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::eval ( std::move ( value ).getStringIndex ( ) ); return indexes::arbology::FullAndLinearIndex < > ( std::move ( stringIndex ), std::move ( value ).getJumps ( ) ); } }; -template < class SymbolType, class RankType > -struct xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType > > { - static indexes::arbology::FullAndLinearIndex < SymbolType, RankType > parse ( ext::deque < sax::Token >::iterator & input ); +template < class SymbolType, class RankType, template < typename > class StringIndex > +struct xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > > { + static indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > parse ( ext::deque < sax::Token >::iterator & input ); static bool first ( const ext::deque < sax::Token >::const_iterator & input ); static const std::string & xmlTagName ( ); - static void compose ( ext::deque < sax::Token > & output, const indexes::arbology::FullAndLinearIndex < SymbolType, RankType > & data ); + static void compose ( ext::deque < sax::Token > & output, const indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > & data ); }; -template < class SymbolType, class RankType > -indexes::arbology::FullAndLinearIndex < SymbolType, RankType > xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType > >::parse ( ext::deque < sax::Token >::iterator & input ) { +template < class SymbolType, class RankType, template < typename > class StringIndex > +indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > >::parse ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName ( ) ); 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 ); - indexes::arbology::FullAndLinearIndex < SymbolType, RankType > res ( std::move ( stringIndex ), std::move ( jumps ) ); + indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > res ( std::move ( stringIndex ), std::move ( jumps ) ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, xmlTagName ( ) ); return res; } -template < class SymbolType, class RankType > -bool xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType > >::first ( const ext::deque < sax::Token >::const_iterator & input ) { +template < class SymbolType, class RankType, template < typename > class StringIndex > +bool xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > >::first ( const ext::deque < sax::Token >::const_iterator & input ) { return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName ( ) ); } -template < class SymbolType, class RankType > -const std::string & xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType > >::xmlTagName ( ) { +template < class SymbolType, class RankType, template < typename > class StringIndex > +const std::string & xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > >::xmlTagName ( ) { static std::string xmlTagName = "FullAndLinearIndex"; return xmlTagName; } -template < class SymbolType, class RankType > -void xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType > >::compose ( ext::deque < sax::Token > & output, const indexes::arbology::FullAndLinearIndex < SymbolType, RankType > & index ) { +template < class SymbolType, class RankType, template < typename > class StringIndex > +void xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > >::compose ( ext::deque < sax::Token > & output, const indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > & index ) { output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::START_ELEMENT ); alib::xmlApi < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::compose ( output, index.getStringIndex ( ) ); alib::xmlApi < ext::vector < int > >::compose ( output, index.getJumps ( ) ); diff --git a/alib2data/src/indexes/arbology/NonlinearFullAndLinearIndex.h b/alib2data/src/indexes/arbology/NonlinearFullAndLinearIndex.h index 3ba840524db8b73ec5c457188107a58987202c0e..db033c829854fe08958c0fb12e2c562790ccb310 100644 --- a/alib2data/src/indexes/arbology/NonlinearFullAndLinearIndex.h +++ b/alib2data/src/indexes/arbology/NonlinearFullAndLinearIndex.h @@ -39,10 +39,10 @@ class GeneralAlphabet; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of RegExpElement. */ -template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType > +template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType, template < typename > class StringIndex = indexes::stringology::PositionHeap > class NonlinearFullAndLinearIndex final : public alib::ObjectBase { protected: - indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > m_StringIndex; + StringIndex < common::ranked_symbol < SymbolType, RankType > > m_StringIndex; ext::vector < int > m_JumpTable; ext::vector < unsigned > m_Repeats; @@ -57,14 +57,14 @@ public: */ virtual ObjectBase * plunder ( ) &&; - explicit NonlinearFullAndLinearIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable, ext::vector < unsigned > repeats ); + explicit NonlinearFullAndLinearIndex ( StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable, ext::vector < unsigned > repeats ); /** * @return Root node of the trie */ - const indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > & getStringIndex ( ) const &; + const StringIndex < common::ranked_symbol < SymbolType, RankType > > & getStringIndex ( ) const &; - indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > && getStringIndex ( ) &&; + StringIndex < common::ranked_symbol < SymbolType, RankType > > && getStringIndex ( ) &&; /** * @return subtree jump table @@ -96,7 +96,7 @@ public: * Sets the compressedBit vector for given symbol * @param tree root node to set */ - void setStringIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex ); + void setStringIndex ( StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex ); /** * Removes symbol from the alphabet of symbol available in the regular expression @@ -136,72 +136,72 @@ namespace indexes { namespace arbology { -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, class RankType, template < typename > class StringIndex > +NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::NonlinearFullAndLinearIndex ( StringIndex < 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, class RankType > -alib::ObjectBase * NonlinearFullAndLinearIndex < SymbolType, RankType >::clone ( ) const { +template < class SymbolType, class RankType, template < typename > class StringIndex > +alib::ObjectBase * NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::clone ( ) const { return new NonlinearFullAndLinearIndex ( * this ); } -template < class SymbolType, class RankType > -alib::ObjectBase * NonlinearFullAndLinearIndex < SymbolType, RankType >::plunder ( ) && { +template < class SymbolType, class RankType, template < typename > class StringIndex > +alib::ObjectBase * NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::plunder ( ) && { return new NonlinearFullAndLinearIndex ( std::move ( * this ) ); } -template < class SymbolType, class RankType > -const indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > & NonlinearFullAndLinearIndex < SymbolType, RankType >::getStringIndex ( ) const & { +template < class SymbolType, class RankType, template < typename > class StringIndex > +const StringIndex < common::ranked_symbol < SymbolType, RankType > > & NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::getStringIndex ( ) const & { return m_StringIndex; } -template < class SymbolType, class RankType > -indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > && NonlinearFullAndLinearIndex < SymbolType, RankType >::getStringIndex ( ) && { +template < class SymbolType, class RankType, template < typename > class StringIndex > +StringIndex < common::ranked_symbol < SymbolType, RankType > > && NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::getStringIndex ( ) && { return std::move ( m_StringIndex ); } -template < class SymbolType, class RankType > -const ext::vector < int > & NonlinearFullAndLinearIndex < SymbolType, RankType >::getJumps ( ) const & { +template < class SymbolType, class RankType, template < typename > class StringIndex > +const ext::vector < int > & NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::getJumps ( ) const & { return m_JumpTable; } -template < class SymbolType, class RankType > -ext::vector < int > && NonlinearFullAndLinearIndex < SymbolType, RankType >::getJumps ( ) && { +template < class SymbolType, class RankType, template < typename > class StringIndex > +ext::vector < int > && NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::getJumps ( ) && { return std::move ( m_JumpTable ); } -template < class SymbolType, class RankType > -const ext::vector < unsigned > & NonlinearFullAndLinearIndex < SymbolType, RankType >::getRepeats ( ) const & { +template < class SymbolType, class RankType, template < typename > class StringIndex > +const ext::vector < unsigned > & NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::getRepeats ( ) const & { return m_Repeats; } -template < class SymbolType, class RankType > -ext::vector < unsigned > && NonlinearFullAndLinearIndex < SymbolType, RankType >::getRepeats ( ) && { +template < class SymbolType, class RankType, template < typename > class StringIndex > +ext::vector < unsigned > && NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::getRepeats ( ) && { return std::move ( m_Repeats ); } -template < class SymbolType, class RankType > -const ext::vector < common::ranked_symbol < SymbolType, RankType > > & NonlinearFullAndLinearIndex < SymbolType, RankType >::getString ( ) const & { +template < class SymbolType, class RankType, template < typename > class StringIndex > +const ext::vector < common::ranked_symbol < SymbolType, RankType > > & NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::getString ( ) const & { return m_StringIndex.getString ( ); } -template < class SymbolType, class RankType > -ext::vector < common::ranked_symbol < SymbolType, RankType > > && NonlinearFullAndLinearIndex < SymbolType, RankType >::getString ( ) && { +template < class SymbolType, class RankType, template < typename > class StringIndex > +ext::vector < common::ranked_symbol < SymbolType, RankType > > && NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::getString ( ) && { return std::move ( m_StringIndex ).getString ( ); } -template < class SymbolType, class RankType > -void NonlinearFullAndLinearIndex < SymbolType, RankType >::setStringIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex ) { +template < class SymbolType, class RankType, template < typename > class StringIndex > +void NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::setStringIndex ( StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex ) { this->m_StringIndex = std::move ( stringIndex ); } -template < class SymbolType, class RankType > -void NonlinearFullAndLinearIndex < SymbolType, RankType >::operator >>( std::ostream & out ) const { +template < class SymbolType, class RankType, template < typename > class StringIndex > +void NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::operator >>( std::ostream & out ) const { out << "(NonlinearFullAndLinearIndex " << this->m_StringIndex << ", " << m_JumpTable << ")"; } -template < class SymbolType, class RankType > -int NonlinearFullAndLinearIndex < SymbolType, RankType >::compare ( const NonlinearFullAndLinearIndex & other ) const { +template < class SymbolType, class RankType, template < typename > class StringIndex > +int NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::compare ( const NonlinearFullAndLinearIndex & other ) const { auto first = ext::tie ( getStringIndex ( ), getJumps ( ), getRepeats ( ) ); auto second = ext::tie ( other.getStringIndex ( ), other.getJumps ( ), other.getRepeats ( ) ); @@ -210,15 +210,15 @@ int NonlinearFullAndLinearIndex < SymbolType, RankType >::compare ( const Nonlin return comp ( first, second ); } -template < class SymbolType, class RankType > -NonlinearFullAndLinearIndex < SymbolType, RankType >::operator std::string ( ) const { +template < class SymbolType, class RankType, template < typename > class StringIndex > +NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::operator std::string ( ) const { std::stringstream ss; ss << * this; return ss.str ( ); } -template < class SymbolType, class RankType > -alib::ObjectBase * NonlinearFullAndLinearIndex < SymbolType, RankType >::inc ( ) && { +template < class SymbolType, class RankType, template < typename > class StringIndex > +alib::ObjectBase * NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >::inc ( ) && { return new alib::UniqueObject ( alib::Object ( std::move ( * this ) ), primitive::Integer ( 0 ) ); } @@ -228,52 +228,52 @@ alib::ObjectBase * NonlinearFullAndLinearIndex < SymbolType, RankType >::inc ( ) namespace alib { -template < class SymbolType, class RankType > -struct normalize < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType >, typename std::enable_if < ! std::is_same < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType >, indexes::arbology::NonlinearFullAndLinearIndex < > >::value >::type > { - static indexes::arbology::NonlinearFullAndLinearIndex < > eval ( indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > && value ) { - indexes::stringology::PositionHeap < common::ranked_symbol < > > stringIndex = alib::normalize < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::eval ( std::move ( value ).getStringIndex ( ) ); +template < class SymbolType, class RankType, template < typename > class StringIndex > +struct normalize < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >, typename std::enable_if < ! std::is_same < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex >, indexes::arbology::NonlinearFullAndLinearIndex < > >::value >::type > { + static indexes::arbology::NonlinearFullAndLinearIndex < > eval ( indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > && value ) { + StringIndex < common::ranked_symbol < > > stringIndex = alib::normalize < StringIndex < common::ranked_symbol < SymbolType, RankType > > >::eval ( std::move ( value ).getStringIndex ( ) ); return indexes::arbology::NonlinearFullAndLinearIndex < > ( std::move ( stringIndex ), std::move ( value ).getJumps ( ), std::move ( value ).getRepeats ( ) ); } }; -template < class SymbolType, class RankType > -struct xmlApi < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > > { - static indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > parse ( ext::deque < sax::Token >::iterator & input ); +template < class SymbolType, class RankType, template < typename > class StringIndex > +struct xmlApi < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > > { + static indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > parse ( ext::deque < sax::Token >::iterator & input ); static bool first ( const ext::deque < sax::Token >::const_iterator & input ); static const std::string & xmlTagName ( ); - static void compose ( ext::deque < sax::Token > & output, const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > & data ); + static void compose ( ext::deque < sax::Token > & output, const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > & data ); }; -template < class SymbolType, class RankType > -indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > xmlApi < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > >::parse ( ext::deque < sax::Token >::iterator & input ) { +template < class SymbolType, class RankType, template < typename > class StringIndex > +indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > xmlApi < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > >::parse ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName ( ) ); - indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex = alib::xmlApi < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::parse ( input ); + StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex = alib::xmlApi < StringIndex < 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 ); - indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > res ( std::move ( stringIndex ), std::move ( jumps ), std::move ( repeats ) ); + indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > res ( std::move ( stringIndex ), std::move ( jumps ), std::move ( repeats ) ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, xmlTagName ( ) ); return res; } -template < class SymbolType, class RankType > -bool xmlApi < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > >::first ( const ext::deque < sax::Token >::const_iterator & input ) { +template < class SymbolType, class RankType, template < typename > class StringIndex > +bool xmlApi < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > >::first ( const ext::deque < sax::Token >::const_iterator & input ) { return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName ( ) ); } -template < class SymbolType, class RankType > -const std::string & xmlApi < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > >::xmlTagName ( ) { +template < class SymbolType, class RankType, template < typename > class StringIndex > +const std::string & xmlApi < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > >::xmlTagName ( ) { static std::string xmlTagName = "NonlinearFullAndLinearIndex"; return xmlTagName; } -template < class SymbolType, class RankType > -void xmlApi < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > >::compose ( ext::deque < sax::Token > & output, const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType > & index ) { +template < class SymbolType, class RankType, template < typename > class StringIndex > +void xmlApi < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > >::compose ( ext::deque < sax::Token > & output, const indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > & index ) { output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::START_ELEMENT ); - alib::xmlApi < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::compose ( output, index.getStringIndex ( ) ); + alib::xmlApi < StringIndex < common::ranked_symbol < SymbolType, RankType > > >::compose ( output, index.getStringIndex ( ) ); alib::xmlApi < ext::vector < int > >::compose ( output, index.getJumps ( ) ); alib::xmlApi < ext::vector < unsigned > >::compose ( output, index.getRepeats ( ) ); output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::END_ELEMENT );