From 219203e55f897e00378253773a4b3978403a709e Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Fri, 12 Jan 2018 23:20:47 +0100 Subject: [PATCH] fix full and linear index for trees --- .../indexing/FullAndLinearIndexConstruction.h | 12 +++++----- .../src/indexes/arbology/FullAndLinearIndex.h | 24 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.h b/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.h index b5d1ca7788..e1300bbe64 100644 --- a/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.h +++ b/alib2algo/src/arbology/indexing/FullAndLinearIndexConstruction.h @@ -31,20 +31,20 @@ public: * @return the index */ 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 ); + static indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > 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::FullAndLinearIndex < SymbolType, RankType > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree ); + static indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree ); }; 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 > ( StringIndexConstructionAlgo::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) ); +indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > FullAndLinearIndexConstruction::construct ( const tree::PrefixRankedTree < SymbolType, RankType > & w ) { + return indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > ( StringIndexConstructionAlgo::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) ); } 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 > ( StringIndexConstructionAlgo::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) ); +indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > FullAndLinearIndexConstruction::construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & w ) { + return indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > ( StringIndexConstructionAlgo::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) ); } } /* namespace indexing */ diff --git a/alib2data/src/indexes/arbology/FullAndLinearIndex.h b/alib2data/src/indexes/arbology/FullAndLinearIndex.h index cf1470241e..b3c359ec75 100644 --- a/alib2data/src/indexes/arbology/FullAndLinearIndex.h +++ b/alib2data/src/indexes/arbology/FullAndLinearIndex.h @@ -42,7 +42,7 @@ class GeneralAlphabet; template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType, template < typename > class StringIndex = indexes::stringology::PositionHeap > class FullAndLinearIndex final : public object::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; public: @@ -56,14 +56,14 @@ public: */ virtual ObjectBase * plunder ( ) &&; - explicit FullAndLinearIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable ); + explicit FullAndLinearIndex ( StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable ); /** * @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 @@ -84,7 +84,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 @@ -125,7 +125,7 @@ namespace indexes { namespace arbology { 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 ) ) { +FullAndLinearIndex < SymbolType, RankType, StringIndex >::FullAndLinearIndex ( StringIndex < 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 > @@ -139,12 +139,12 @@ object::ObjectBase * FullAndLinearIndex < SymbolType, RankType, StringIndex >::p } template < class SymbolType, class RankType, template < typename > class StringIndex > -const indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > & FullAndLinearIndex < SymbolType, RankType, StringIndex >::getStringIndex ( ) const & { +const StringIndex < common::ranked_symbol < SymbolType, RankType > > & FullAndLinearIndex < SymbolType, RankType, StringIndex >::getStringIndex ( ) const & { return m_StringIndex; } template < class SymbolType, class RankType, template < typename > class StringIndex > -indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > && FullAndLinearIndex < SymbolType, RankType, StringIndex >::getStringIndex ( ) && { +StringIndex < common::ranked_symbol < SymbolType, RankType > > && FullAndLinearIndex < SymbolType, RankType, StringIndex >::getStringIndex ( ) && { return std::move ( m_StringIndex ); } @@ -159,7 +159,7 @@ ext::vector < int > && FullAndLinearIndex < 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 ) { +void FullAndLinearIndex < SymbolType, RankType, StringIndex >::setStringIndex ( StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex ) { this->m_StringIndex = std::move ( stringIndex ); } @@ -199,7 +199,7 @@ namespace core { 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 = core::normalize < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::eval ( std::move ( value ).getStringIndex ( ) ); + StringIndex < common::ranked_symbol < > > stringIndex = core::normalize < StringIndex < common::ranked_symbol < SymbolType, RankType > > >::eval ( std::move ( value ).getStringIndex ( ) ); return indexes::arbology::FullAndLinearIndex < > ( std::move ( stringIndex ), std::move ( value ).getJumps ( ) ); } @@ -216,7 +216,7 @@ struct xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, St 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 = core::xmlApi < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::parse ( input ); + StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex = core::xmlApi < StringIndex < common::ranked_symbol < SymbolType, RankType > > >::parse ( input ); ext::vector < int > jumps = core::xmlApi < ext::vector < int > >::parse ( input ); indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > res ( std::move ( stringIndex ), std::move ( jumps ) ); @@ -240,7 +240,7 @@ const std::string & xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, 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 ); - core::xmlApi < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::compose ( output, index.getStringIndex ( ) ); + core::xmlApi < StringIndex < common::ranked_symbol < SymbolType, RankType > > >::compose ( output, index.getStringIndex ( ) ); core::xmlApi < ext::vector < int > >::compose ( output, index.getJumps ( ) ); output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::END_ELEMENT ); } -- GitLab