From 34205e37978b972a4740267a628da8514310a33f Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Thu, 22 Dec 2016 15:59:37 +0100 Subject: [PATCH] use default data types in experimental indexes --- .../src/indexes/common/IndexFromXMLParser.cpp | 14 ++++---- .../src/indexes/common/IndexFromXMLParser.h | 2 +- .../src/indexes/common/IndexToXMLComposer.cpp | 8 ++--- .../src/indexes/common/IndexToXMLComposer.h | 2 +- .../suffixTrie/SuffixTrieFinalMark.cpp | 12 +++---- .../indexes/suffixTrie/SuffixTrieFinalMark.h | 18 +++++------ .../suffixTrie/SuffixTrieNodeFinalMark.cpp | 32 +++++++++---------- .../suffixTrie/SuffixTrieNodeFinalMark.h | 27 ++++++++-------- .../SuffixTrieNodeTerminatingSymbol.cpp | 30 ++++++++--------- .../SuffixTrieNodeTerminatingSymbol.h | 25 +++++++-------- .../SuffixTrieTerminatingSymbol.cpp | 16 +++++----- .../suffixTrie/SuffixTrieTerminatingSymbol.h | 26 +++++++-------- 12 files changed, 105 insertions(+), 107 deletions(-) diff --git a/alib2data_experimental/src/indexes/common/IndexFromXMLParser.cpp b/alib2data_experimental/src/indexes/common/IndexFromXMLParser.cpp index 63caa45057..3055bd57f6 100644 --- a/alib2data_experimental/src/indexes/common/IndexFromXMLParser.cpp +++ b/alib2data_experimental/src/indexes/common/IndexFromXMLParser.cpp @@ -13,12 +13,12 @@ namespace indexes { -std::set < alphabet::Symbol > IndexFromXMLParser::parseAlphabet ( std::deque < sax::Token >::iterator & input ) { - std::set < alphabet::Symbol > symbols; +std::set < DefaultSymbolType > IndexFromXMLParser::parseAlphabet ( std::deque < sax::Token >::iterator & input ) { + std::set < DefaultSymbolType > symbols; sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "alphabet" ); while ( sax::FromXMLParserHelper::isTokenType ( input, sax::Token::TokenType::START_ELEMENT ) ) - symbols.insert ( alib::xmlApi < alphabet::Symbol >::parse ( input ) ); + symbols.insert ( alib::xmlApi < DefaultSymbolType >::parse ( input ) ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, "alphabet" ); return symbols; @@ -26,12 +26,12 @@ std::set < alphabet::Symbol > IndexFromXMLParser::parseAlphabet ( std::deque < s SuffixTrieNodeFinalMark * IndexFromXMLParser::parseSuffixTrieNodeFinalMark ( std::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "node" ); - std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * > children; + std::map < DefaultSymbolType, SuffixTrieNodeFinalMark * > children; bool finalMark = alib::xmlApi < bool >::parse ( input ); while ( sax::FromXMLParserHelper::isTokenType ( input, sax::Token::TokenType::START_ELEMENT ) ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "child" ); - alphabet::Symbol symbol = alib::xmlApi < alphabet::Symbol >::parse ( input ); + DefaultSymbolType symbol = alib::xmlApi < DefaultSymbolType >::parse ( input ); children.insert ( std::make_pair ( std::move ( symbol ), parseSuffixTrieNodeFinalMark ( input ) ) ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, "child" ); } @@ -43,11 +43,11 @@ SuffixTrieNodeFinalMark * IndexFromXMLParser::parseSuffixTrieNodeFinalMark ( std SuffixTrieNodeTerminatingSymbol * IndexFromXMLParser::parseSuffixTrieNodeTerminatingSymbol ( std::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "node" ); - std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * > children; + std::map < DefaultSymbolType, SuffixTrieNodeTerminatingSymbol * > children; while ( sax::FromXMLParserHelper::isTokenType ( input, sax::Token::TokenType::START_ELEMENT ) ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "child" ); - alphabet::Symbol symbol = alib::xmlApi < alphabet::Symbol >::parse ( input ); + DefaultSymbolType symbol = alib::xmlApi < DefaultSymbolType >::parse ( input ); children.insert ( std::make_pair ( std::move ( symbol ), parseSuffixTrieNodeTerminatingSymbol ( input ) ) ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, "child" ); } diff --git a/alib2data_experimental/src/indexes/common/IndexFromXMLParser.h b/alib2data_experimental/src/indexes/common/IndexFromXMLParser.h index 95f4926180..8f1de94b39 100644 --- a/alib2data_experimental/src/indexes/common/IndexFromXMLParser.h +++ b/alib2data_experimental/src/indexes/common/IndexFromXMLParser.h @@ -25,7 +25,7 @@ class IndexFromXMLParser { public: static SuffixTrieNodeFinalMark * parseSuffixTrieNodeFinalMark ( std::deque < sax::Token >::iterator & input ); static SuffixTrieNodeTerminatingSymbol * parseSuffixTrieNodeTerminatingSymbol ( std::deque < sax::Token >::iterator & input ); - static std::set < alphabet::Symbol > parseAlphabet ( std::deque < sax::Token >::iterator & input ); + static std::set < DefaultSymbolType > parseAlphabet ( std::deque < sax::Token >::iterator & input ); }; } /* namespace indexes */ diff --git a/alib2data_experimental/src/indexes/common/IndexToXMLComposer.cpp b/alib2data_experimental/src/indexes/common/IndexToXMLComposer.cpp index 4fe7520319..52b9e5d970 100644 --- a/alib2data_experimental/src/indexes/common/IndexToXMLComposer.cpp +++ b/alib2data_experimental/src/indexes/common/IndexToXMLComposer.cpp @@ -11,11 +11,11 @@ namespace indexes { -void IndexToXMLComposer::composeAlphabet ( std::deque < sax::Token > & out, const std::set < alphabet::Symbol > & symbols ) { +void IndexToXMLComposer::composeAlphabet ( std::deque < sax::Token > & out, const std::set < DefaultSymbolType > & symbols ) { out.emplace_back ( sax::Token ( "alphabet", sax::Token::TokenType::START_ELEMENT ) ); for ( const auto & symbol : symbols ) - alib::xmlApi < alphabet::Symbol >::compose ( out, symbol ); + alib::xmlApi < DefaultSymbolType >::compose ( out, symbol ); out.emplace_back ( sax::Token ( "alphabet", sax::Token::TokenType::END_ELEMENT ) ); } @@ -26,7 +26,7 @@ void IndexToXMLComposer::composeNode ( std::deque < sax::Token > & out, const Su for ( const auto & child : node.getChildren ( ) ) { out.emplace_back ( sax::Token ( "child", sax::Token::TokenType::START_ELEMENT ) ); - alib::xmlApi < alphabet::Symbol >::compose ( out, child.first ); + alib::xmlApi < DefaultSymbolType >::compose ( out, child.first ); composeNode ( out, * child.second ); out.emplace_back ( sax::Token ( "child", sax::Token::TokenType::END_ELEMENT ) ); } @@ -39,7 +39,7 @@ void IndexToXMLComposer::composeNode ( std::deque < sax::Token > & out, const Su for ( const auto & child : node.getChildren ( ) ) { out.emplace_back ( sax::Token ( "child", sax::Token::TokenType::START_ELEMENT ) ); - alib::xmlApi < alphabet::Symbol >::compose ( out, child.first ); + alib::xmlApi < DefaultSymbolType >::compose ( out, child.first ); composeNode ( out, * child.second ); out.emplace_back ( sax::Token ( "child", sax::Token::TokenType::END_ELEMENT ) ); } diff --git a/alib2data_experimental/src/indexes/common/IndexToXMLComposer.h b/alib2data_experimental/src/indexes/common/IndexToXMLComposer.h index a1b0eec579..7cfd6cf55c 100644 --- a/alib2data_experimental/src/indexes/common/IndexToXMLComposer.h +++ b/alib2data_experimental/src/indexes/common/IndexToXMLComposer.h @@ -22,7 +22,7 @@ namespace indexes { */ class IndexToXMLComposer { public: - static void composeAlphabet ( std::deque < sax::Token > & out, const std::set < alphabet::Symbol > & symbols ); + static void composeAlphabet ( std::deque < sax::Token > & out, const std::set < DefaultSymbolType > & symbols ); static void composeNode ( std::deque < sax::Token > & out, const SuffixTrieNodeFinalMark & node ); static void composeNode ( std::deque < sax::Token > & out, const SuffixTrieNodeTerminatingSymbol & node ); diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.cpp b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.cpp index 482cb51c10..1f291a2d00 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.cpp +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.cpp @@ -22,26 +22,26 @@ namespace indexes { -SuffixTrieFinalMark::SuffixTrieFinalMark ( std::set < alphabet::Symbol > alphabet ) : SuffixTrieFinalMark ( std::move ( alphabet ), SuffixTrieNodeFinalMark ( { }, true ) ) { +SuffixTrieFinalMark::SuffixTrieFinalMark ( std::set < DefaultSymbolType > alphabet ) : SuffixTrieFinalMark ( std::move ( alphabet ), SuffixTrieNodeFinalMark ( { }, true ) ) { } -SuffixTrieFinalMark::SuffixTrieFinalMark ( std::set < alphabet::Symbol > alphabet, SuffixTrieNodeFinalMark tree ) : std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), m_tree ( NULL ) { +SuffixTrieFinalMark::SuffixTrieFinalMark ( std::set < DefaultSymbolType > alphabet, SuffixTrieNodeFinalMark tree ) : std::Components < SuffixTrieFinalMark, DefaultSymbolType, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), m_tree ( NULL ) { setTree ( std::move ( tree ) ); } SuffixTrieFinalMark::SuffixTrieFinalMark ( SuffixTrieNodeFinalMark tree ) : SuffixTrieFinalMark ( tree.computeMinimalAlphabet ( ), tree ) { } -SuffixTrieFinalMark::SuffixTrieFinalMark ( const SuffixTrieTerminatingSymbol & other ) : std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), m_tree ( NULL ) { +SuffixTrieFinalMark::SuffixTrieFinalMark ( const SuffixTrieTerminatingSymbol & other ) : std::Components < SuffixTrieFinalMark, DefaultSymbolType, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), m_tree ( NULL ) { this->accessComponent < GeneralAlphabet > ( ).remove ( other.accessElement < TerminatingSymbol > ( ).get ( ) ); setTree ( SuffixTrieNodeFinalMark ( other.getRoot ( ), other.accessElement < TerminatingSymbol > ( ).get ( ) ) ); } -SuffixTrieFinalMark::SuffixTrieFinalMark ( const SuffixTrieFinalMark & other ) : std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), m_tree ( other.m_tree->clone ( ) ) { +SuffixTrieFinalMark::SuffixTrieFinalMark ( const SuffixTrieFinalMark & other ) : std::Components < SuffixTrieFinalMark, DefaultSymbolType, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), m_tree ( other.m_tree->clone ( ) ) { this->m_tree->attachTree ( this ); } -SuffixTrieFinalMark::SuffixTrieFinalMark ( SuffixTrieFinalMark && other ) noexcept : std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( other.accessComponent < GeneralAlphabet > ( ).get ( ) ) ), std::tuple < > ( ) ), m_tree ( other.m_tree ) { +SuffixTrieFinalMark::SuffixTrieFinalMark ( SuffixTrieFinalMark && other ) noexcept : std::Components < SuffixTrieFinalMark, DefaultSymbolType, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( other.accessComponent < GeneralAlphabet > ( ).get ( ) ) ), std::tuple < > ( ) ), m_tree ( other.m_tree ) { this->m_tree->attachTree ( this ); other.m_tree = NULL; } @@ -118,7 +118,7 @@ SuffixTrieFinalMark::operator std::string ( ) const { SuffixTrieFinalMark SuffixTrieFinalMark::parse ( std::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, SuffixTrieFinalMark::getXmlTagName() ); - std::set < alphabet::Symbol > rankedAlphabet = IndexFromXMLParser::parseAlphabet ( input ); + std::set < DefaultSymbolType > rankedAlphabet = IndexFromXMLParser::parseAlphabet ( input ); SuffixTrieNodeFinalMark * root = IndexFromXMLParser::parseSuffixTrieNodeFinalMark ( input ); SuffixTrieFinalMark tree ( std::move ( rankedAlphabet ), std::move ( * root ) ); diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.h b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.h index 461ed8d894..0efc4903b9 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.h +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.h @@ -25,7 +25,7 @@ class GeneralAlphabet; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of RegExpElement. */ -class SuffixTrieFinalMark : public alib::ObjectBase, public std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > { +class SuffixTrieFinalMark : public alib::ObjectBase, public std::Components < SuffixTrieFinalMark, DefaultSymbolType, std::tuple < GeneralAlphabet >, std::tuple < > > { protected: SuffixTrieNodeFinalMark * m_tree; @@ -40,8 +40,8 @@ public: */ virtual ObjectBase * plunder ( ) &&; - explicit SuffixTrieFinalMark ( std::set < alphabet::Symbol > alphabet ); - explicit SuffixTrieFinalMark ( std::set < alphabet::Symbol > alphabet, SuffixTrieNodeFinalMark tree ); + explicit SuffixTrieFinalMark ( std::set < DefaultSymbolType > alphabet ); + explicit SuffixTrieFinalMark ( std::set < DefaultSymbolType > alphabet, SuffixTrieNodeFinalMark tree ); explicit SuffixTrieFinalMark ( SuffixTrieNodeFinalMark tree ); explicit SuffixTrieFinalMark ( const SuffixTrieTerminatingSymbol & tree ); @@ -66,7 +66,7 @@ public: */ SuffixTrieNodeFinalMark & getRoot ( ); - const std::set < alphabet::Symbol > & getAlphabet ( ) const { + const std::set < DefaultSymbolType > & getAlphabet ( ) const { return accessComponent < GeneralAlphabet > ( ).get ( ); } @@ -80,7 +80,7 @@ public: * Removes symbol from the alphabet of symbol available in the regular expression * @param symbol removed symbol from the alphabet */ - bool removeSymbolFromAlphabet ( const alphabet::Symbol & symbol ); + bool removeSymbolFromAlphabet ( const DefaultSymbolType & symbol ); /** * Prints XML representation of the tree to the output stream. @@ -119,17 +119,17 @@ public: namespace std { template < > -class ComponentConstraint< indexes::SuffixTrieFinalMark, alphabet::Symbol, indexes::GeneralAlphabet > { +class ComponentConstraint< indexes::SuffixTrieFinalMark, DefaultSymbolType, indexes::GeneralAlphabet > { public: - static bool used ( const indexes::SuffixTrieFinalMark & index, const alphabet::Symbol & symbol ) { + static bool used ( const indexes::SuffixTrieFinalMark & index, const DefaultSymbolType & symbol ) { return index.getRoot ( ).testSymbol ( symbol ); } - static bool available ( const indexes::SuffixTrieFinalMark &, const alphabet::Symbol & ) { + static bool available ( const indexes::SuffixTrieFinalMark &, const DefaultSymbolType & ) { return true; } - static void valid ( const indexes::SuffixTrieFinalMark &, const alphabet::Symbol & ) { + static void valid ( const indexes::SuffixTrieFinalMark &, const DefaultSymbolType & ) { } }; diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.cpp b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.cpp index 4d21c42572..cde5382fdc 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.cpp +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.cpp @@ -13,7 +13,7 @@ namespace indexes { -SuffixTrieNodeFinalMark::SuffixTrieNodeFinalMark ( std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * > children, bool finalMark ) : m_children ( std::move ( children ) ), m_finalMark ( finalMark ), parentTree ( NULL ) { +SuffixTrieNodeFinalMark::SuffixTrieNodeFinalMark ( std::map < DefaultSymbolType, SuffixTrieNodeFinalMark * > children, bool finalMark ) : m_children ( std::move ( children ) ), m_finalMark ( finalMark ), parentTree ( NULL ) { for ( auto & element : this->m_children ) element.second->parent = this; @@ -21,7 +21,7 @@ SuffixTrieNodeFinalMark::SuffixTrieNodeFinalMark ( std::map < alphabet::Symbol, this->parent = NULL; } -SuffixTrieNodeFinalMark::SuffixTrieNodeFinalMark ( const SuffixTrieNodeTerminatingSymbol & other, const alphabet::Symbol & terminatingSymbol ) : m_finalMark ( false ), parentTree ( NULL ) { +SuffixTrieNodeFinalMark::SuffixTrieNodeFinalMark ( const SuffixTrieNodeTerminatingSymbol & other, const DefaultSymbolType & terminatingSymbol ) : m_finalMark ( false ), parentTree ( NULL ) { for ( auto & element : other.getChildren ( ) ) if ( element.first == terminatingSymbol ) this->m_finalMark = true; @@ -85,8 +85,8 @@ SuffixTrieNodeFinalMark::~SuffixTrieNodeFinalMark ( ) noexcept { m_children.clear ( ); } -const std::map < const alphabet::Symbol, const SuffixTrieNodeFinalMark * > & SuffixTrieNodeFinalMark::getChildren ( ) const { - return * reinterpret_cast < const std::map < const alphabet::Symbol, const SuffixTrieNodeFinalMark * > * > ( & m_children ); +const std::map < const DefaultSymbolType, const SuffixTrieNodeFinalMark * > & SuffixTrieNodeFinalMark::getChildren ( ) const { + return * reinterpret_cast < const std::map < const DefaultSymbolType, const SuffixTrieNodeFinalMark * > * > ( & m_children ); } bool SuffixTrieNodeFinalMark::getFinalMark ( ) const { @@ -97,34 +97,34 @@ void SuffixTrieNodeFinalMark::setFinalMark ( bool newFinalMark ) { m_finalMark = newFinalMark; } -const std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * > & SuffixTrieNodeFinalMark::getChildren ( ) { +const std::map < DefaultSymbolType, SuffixTrieNodeFinalMark * > & SuffixTrieNodeFinalMark::getChildren ( ) { return m_children; } -SuffixTrieNodeFinalMark & SuffixTrieNodeFinalMark::getChild ( const alphabet::Symbol & symbol ) { - std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * >::const_iterator iter = m_children.find ( symbol ); +SuffixTrieNodeFinalMark & SuffixTrieNodeFinalMark::getChild ( const DefaultSymbolType & symbol ) { + std::map < DefaultSymbolType, SuffixTrieNodeFinalMark * >::const_iterator iter = m_children.find ( symbol ); if ( iter == m_children.end ( ) ) throw exception::CommonException ( "child does not exist" ); return * iter->second; } -const SuffixTrieNodeFinalMark & SuffixTrieNodeFinalMark::getChild ( const alphabet::Symbol & symbol ) const { - std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * >::const_iterator iter = m_children.find ( symbol ); +const SuffixTrieNodeFinalMark & SuffixTrieNodeFinalMark::getChild ( const DefaultSymbolType & symbol ) const { + std::map < DefaultSymbolType, SuffixTrieNodeFinalMark * >::const_iterator iter = m_children.find ( symbol ); if ( iter == m_children.end ( ) ) throw exception::CommonException ( "child does not exist" ); return * iter->second; } -bool SuffixTrieNodeFinalMark::hasChild ( const alphabet::Symbol & symbol ) const { +bool SuffixTrieNodeFinalMark::hasChild ( const DefaultSymbolType & symbol ) const { if ( m_children.find ( symbol ) == m_children.end ( ) ) return false; return true; } -SuffixTrieNodeFinalMark & SuffixTrieNodeFinalMark::addChild ( alphabet::Symbol symbol, SuffixTrieNodeFinalMark node ) { - std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * >::iterator iter = m_children.find ( symbol ); +SuffixTrieNodeFinalMark & SuffixTrieNodeFinalMark::addChild ( DefaultSymbolType symbol, SuffixTrieNodeFinalMark node ) { + std::map < DefaultSymbolType, SuffixTrieNodeFinalMark * >::iterator iter = m_children.find ( symbol ); if ( iter != m_children.end ( ) ) throw exception::CommonException ( "child already exist" ); @@ -180,7 +180,7 @@ std::ostream & operator <<( std::ostream & out, const SuffixTrieNodeFinalMark & return out; } -bool SuffixTrieNodeFinalMark::testSymbol ( const alphabet::Symbol & symbol ) const { +bool SuffixTrieNodeFinalMark::testSymbol ( const DefaultSymbolType & symbol ) const { for ( const auto & child : this->m_children ) { if ( symbol == child.first ) return true; @@ -204,13 +204,13 @@ bool SuffixTrieNodeFinalMark::attachTree ( const SuffixTrieFinalMark * tree ) { return true; } -std::set < alphabet::Symbol > SuffixTrieNodeFinalMark::computeMinimalAlphabet ( ) const { - std::set < alphabet::Symbol > res; +std::set < DefaultSymbolType > SuffixTrieNodeFinalMark::computeMinimalAlphabet ( ) const { + std::set < DefaultSymbolType > res; computeMinimalAlphabet ( res ); return res; } -void SuffixTrieNodeFinalMark::computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const { +void SuffixTrieNodeFinalMark::computeMinimalAlphabet ( std::set < DefaultSymbolType > & alphabet ) const { for ( const auto & child : this->m_children ) { alphabet.insert ( child.first ); child.second->computeMinimalAlphabet ( alphabet ); diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.h b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.h index e38d6e6fa6..e8dac03c69 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.h +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.h @@ -8,8 +8,7 @@ #ifndef SUFFIX_TRIE_NODE_FINAL_MARK_H_ #define SUFFIX_TRIE_NODE_FINAL_MARK_H_ -#include <alphabet/Symbol.h> -#include <primitive/Unsigned.h> +#include <common/DefaultSymbolType.h> #include <map> #include <set> @@ -23,7 +22,7 @@ class SuffixTrieFinalMark; */ class SuffixTrieNodeFinalMark { protected: - std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * > m_children; + std::map < DefaultSymbolType, SuffixTrieNodeFinalMark * > m_children; bool m_finalMark; @@ -40,9 +39,9 @@ protected: bool attachTree ( const SuffixTrieFinalMark * indexes ); public: - explicit SuffixTrieNodeFinalMark ( std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * > children, bool finalMark ); + explicit SuffixTrieNodeFinalMark ( std::map < DefaultSymbolType, SuffixTrieNodeFinalMark * > children, bool finalMark ); - explicit SuffixTrieNodeFinalMark ( const SuffixTrieNodeTerminatingSymbol & other, const alphabet::Symbol & terminatingSymbol ); + explicit SuffixTrieNodeFinalMark ( const SuffixTrieNodeTerminatingSymbol & other, const DefaultSymbolType & terminatingSymbol ); SuffixTrieNodeFinalMark ( const SuffixTrieNodeFinalMark & other ); SuffixTrieNodeFinalMark ( SuffixTrieNodeFinalMark && other ) noexcept; @@ -63,17 +62,17 @@ public: /** * @copydoc SuffixTrieNodeFinalMark::computeMinimalAlphabet() */ - std::set < alphabet::Symbol > computeMinimalAlphabet ( ) const; + std::set < DefaultSymbolType > computeMinimalAlphabet ( ) const; /** * @copydoc SuffixTrieNodeFinalMark::computeMinimalAlphabet() */ - void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + void computeMinimalAlphabet ( std::set < DefaultSymbolType > & alphabet ) const; /** * @return children */ - const std::map < const alphabet::Symbol, const SuffixTrieNodeFinalMark * > & getChildren ( ) const; + const std::map < const DefaultSymbolType, const SuffixTrieNodeFinalMark * > & getChildren ( ) const; bool getFinalMark ( ) const; @@ -82,15 +81,15 @@ public: /** * @return children */ - const std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * > & getChildren ( ); + const std::map < DefaultSymbolType, SuffixTrieNodeFinalMark * > & getChildren ( ); - SuffixTrieNodeFinalMark & getChild ( const alphabet::Symbol & symbol ); + SuffixTrieNodeFinalMark & getChild ( const DefaultSymbolType & symbol ); - const SuffixTrieNodeFinalMark & getChild ( const alphabet::Symbol & symbol ) const; + const SuffixTrieNodeFinalMark & getChild ( const DefaultSymbolType & symbol ) const; - bool hasChild ( const alphabet::Symbol & symbol ) const; + bool hasChild ( const DefaultSymbolType & symbol ) const; - SuffixTrieNodeFinalMark & addChild ( alphabet::Symbol symbol, SuffixTrieNodeFinalMark node ); + SuffixTrieNodeFinalMark & addChild ( DefaultSymbolType symbol, SuffixTrieNodeFinalMark node ); SuffixTrieNodeFinalMark * getParent ( ); @@ -103,7 +102,7 @@ public: /** * @copydoc SuffixTrieNodeFinalMark::testSymbol() const */ - bool testSymbol ( const alphabet::Symbol & symbol ) const; + bool testSymbol ( const DefaultSymbolType & symbol ) const; /** * @copydoc SuffixTrieNodeFinalMark::operator>>() const diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.cpp b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.cpp index 0c35a339c1..d59843f9ac 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.cpp +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.cpp @@ -12,7 +12,7 @@ namespace indexes { -SuffixTrieNodeTerminatingSymbol::SuffixTrieNodeTerminatingSymbol ( std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * > children ) : m_children ( std::move ( children ) ), parentTree ( NULL ) { +SuffixTrieNodeTerminatingSymbol::SuffixTrieNodeTerminatingSymbol ( std::map < DefaultSymbolType, SuffixTrieNodeTerminatingSymbol * > children ) : m_children ( std::move ( children ) ), parentTree ( NULL ) { for ( auto & element : this->m_children ) element.second->parent = this; @@ -69,38 +69,38 @@ SuffixTrieNodeTerminatingSymbol::~SuffixTrieNodeTerminatingSymbol ( ) noexcept { m_children.clear ( ); } -const std::map < const alphabet::Symbol, const SuffixTrieNodeTerminatingSymbol * > & SuffixTrieNodeTerminatingSymbol::getChildren ( ) const { - return * reinterpret_cast < const std::map < const alphabet::Symbol, const SuffixTrieNodeTerminatingSymbol * > * > ( & m_children ); +const std::map < const DefaultSymbolType, const SuffixTrieNodeTerminatingSymbol * > & SuffixTrieNodeTerminatingSymbol::getChildren ( ) const { + return * reinterpret_cast < const std::map < const DefaultSymbolType, const SuffixTrieNodeTerminatingSymbol * > * > ( & m_children ); } -const std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * > & SuffixTrieNodeTerminatingSymbol::getChildren ( ) { +const std::map < DefaultSymbolType, SuffixTrieNodeTerminatingSymbol * > & SuffixTrieNodeTerminatingSymbol::getChildren ( ) { return m_children; } -SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::getChild ( const alphabet::Symbol & symbol ) { - std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * >::const_iterator iter = m_children.find ( symbol ); +SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::getChild ( const DefaultSymbolType & symbol ) { + std::map < DefaultSymbolType, SuffixTrieNodeTerminatingSymbol * >::const_iterator iter = m_children.find ( symbol ); if ( iter == m_children.end ( ) ) throw exception::CommonException ( "child does not exist" ); return * iter->second; } -const SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::getChild ( const alphabet::Symbol & symbol ) const { - std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * >::const_iterator iter = m_children.find ( symbol ); +const SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::getChild ( const DefaultSymbolType & symbol ) const { + std::map < DefaultSymbolType, SuffixTrieNodeTerminatingSymbol * >::const_iterator iter = m_children.find ( symbol ); if ( iter == m_children.end ( ) ) throw exception::CommonException ( "child does not exist" ); return * iter->second; } -bool SuffixTrieNodeTerminatingSymbol::hasChild ( const alphabet::Symbol & symbol ) const { +bool SuffixTrieNodeTerminatingSymbol::hasChild ( const DefaultSymbolType & symbol ) const { if ( m_children.find ( symbol ) == m_children.end ( ) ) return false; return true; } -SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::addChild ( alphabet::Symbol symbol, SuffixTrieNodeTerminatingSymbol node ) { - std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * >::iterator iter = m_children.find ( symbol ); +SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::addChild ( DefaultSymbolType symbol, SuffixTrieNodeTerminatingSymbol node ) { + std::map < DefaultSymbolType, SuffixTrieNodeTerminatingSymbol * >::iterator iter = m_children.find ( symbol ); if ( iter != m_children.end ( ) ) throw exception::CommonException ( "child already exist" ); @@ -156,7 +156,7 @@ std::ostream & operator <<( std::ostream & out, const SuffixTrieNodeTerminatingS return out; } -bool SuffixTrieNodeTerminatingSymbol::testSymbol ( const alphabet::Symbol & symbol ) const { +bool SuffixTrieNodeTerminatingSymbol::testSymbol ( const DefaultSymbolType & symbol ) const { for ( const auto & child : this->m_children ) { if ( symbol == child.first ) return true; @@ -180,13 +180,13 @@ bool SuffixTrieNodeTerminatingSymbol::attachTree ( const SuffixTrieTerminatingSy return true; } -std::set < alphabet::Symbol > SuffixTrieNodeTerminatingSymbol::computeMinimalAlphabet ( ) const { - std::set < alphabet::Symbol > res; +std::set < DefaultSymbolType > SuffixTrieNodeTerminatingSymbol::computeMinimalAlphabet ( ) const { + std::set < DefaultSymbolType > res; computeMinimalAlphabet ( res ); return res; } -void SuffixTrieNodeTerminatingSymbol::computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const { +void SuffixTrieNodeTerminatingSymbol::computeMinimalAlphabet ( std::set < DefaultSymbolType > & alphabet ) const { for ( const auto & child : this->m_children ) { alphabet.insert ( child.first ); child.second->computeMinimalAlphabet ( alphabet ); diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.h b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.h index 86aabe375a..59d26c3b41 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.h +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.h @@ -8,8 +8,7 @@ #ifndef SUFFIX_TRIE_NODE_TERMINATING_SYMBOL_H_ #define SUFFIX_TRIE_NODE_TERMINATING_SYMBOL_H_ -#include <alphabet/Symbol.h> -#include <primitive/Unsigned.h> +#include <common/DefaultSymbolType.h> #include <map> #include <set> @@ -22,7 +21,7 @@ class SuffixTrieTerminatingSymbol; */ class SuffixTrieNodeTerminatingSymbol { protected: - std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * > m_children; + std::map < DefaultSymbolType, SuffixTrieNodeTerminatingSymbol * > m_children; SuffixTrieNodeTerminatingSymbol * parent; @@ -37,7 +36,7 @@ protected: bool attachTree ( const SuffixTrieTerminatingSymbol * tree ); public: - explicit SuffixTrieNodeTerminatingSymbol ( std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * > children ); + explicit SuffixTrieNodeTerminatingSymbol ( std::map < DefaultSymbolType, SuffixTrieNodeTerminatingSymbol * > children ); SuffixTrieNodeTerminatingSymbol ( const SuffixTrieNodeTerminatingSymbol & other ); SuffixTrieNodeTerminatingSymbol ( SuffixTrieNodeTerminatingSymbol && other ) noexcept; @@ -58,30 +57,30 @@ public: /** * @copydoc RankedNode::computeMinimalAlphabet() */ - std::set < alphabet::Symbol > computeMinimalAlphabet ( ) const; + std::set < DefaultSymbolType > computeMinimalAlphabet ( ) const; /** * @copydoc SuffixTrieNodeTerminatingSymbol::computeMinimalAlphabet() */ - void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + void computeMinimalAlphabet ( std::set < DefaultSymbolType > & alphabet ) const; /** * @return children */ - const std::map < const alphabet::Symbol, const SuffixTrieNodeTerminatingSymbol * > & getChildren ( ) const; + const std::map < const DefaultSymbolType, const SuffixTrieNodeTerminatingSymbol * > & getChildren ( ) const; /** * @return children */ - const std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * > & getChildren ( ); + const std::map < DefaultSymbolType, SuffixTrieNodeTerminatingSymbol * > & getChildren ( ); - SuffixTrieNodeTerminatingSymbol & getChild ( const alphabet::Symbol & symbol ); + SuffixTrieNodeTerminatingSymbol & getChild ( const DefaultSymbolType & symbol ); - const SuffixTrieNodeTerminatingSymbol & getChild ( const alphabet::Symbol & symbol ) const; + const SuffixTrieNodeTerminatingSymbol & getChild ( const DefaultSymbolType & symbol ) const; - bool hasChild ( const alphabet::Symbol & symbol ) const; + bool hasChild ( const DefaultSymbolType & symbol ) const; - SuffixTrieNodeTerminatingSymbol & addChild ( alphabet::Symbol symbol, SuffixTrieNodeTerminatingSymbol node ); + SuffixTrieNodeTerminatingSymbol & addChild ( DefaultSymbolType symbol, SuffixTrieNodeTerminatingSymbol node ); SuffixTrieNodeTerminatingSymbol * getParent ( ); @@ -94,7 +93,7 @@ public: /** * @copydoc SuffixTrieNodeTerminatingSymbol::testSymbol() const */ - bool testSymbol ( const alphabet::Symbol & symbol ) const; + bool testSymbol ( const DefaultSymbolType & symbol ) const; /** * @copydoc SuffixTrieNodeTerminatingSymbol::operator>>() const diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.cpp b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.cpp index 89be56fb86..b5923de78b 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.cpp +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.cpp @@ -21,21 +21,21 @@ namespace indexes { -SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( std::set < alphabet::Symbol > alphabet, alphabet::Symbol terminatingSymbol ) : SuffixTrieTerminatingSymbol ( std::move ( alphabet ), std::move ( terminatingSymbol ), SuffixTrieNodeTerminatingSymbol ( { } ) ) { +SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( std::set < DefaultSymbolType > alphabet, DefaultSymbolType terminatingSymbol ) : SuffixTrieTerminatingSymbol ( std::move ( alphabet ), std::move ( terminatingSymbol ), SuffixTrieNodeTerminatingSymbol ( { } ) ) { } -SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( std::set < alphabet::Symbol > alphabet, alphabet::Symbol terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ) : std::Components < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( std::move ( alphabet ) ), std::make_tuple ( std::move ( terminatingSymbol ) ) ), m_tree ( NULL ) { +SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( std::set < DefaultSymbolType > alphabet, DefaultSymbolType terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ) : std::Components < SuffixTrieTerminatingSymbol, DefaultSymbolType, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( std::move ( alphabet ) ), std::make_tuple ( std::move ( terminatingSymbol ) ) ), m_tree ( NULL ) { setTree ( std::move ( tree ) ); } -SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( alphabet::Symbol terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ) : SuffixTrieTerminatingSymbol ( tree.computeMinimalAlphabet ( ) + std::set < alphabet::Symbol > { terminatingSymbol }, terminatingSymbol, tree ) { +SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( DefaultSymbolType terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ) : SuffixTrieTerminatingSymbol ( tree.computeMinimalAlphabet ( ) + std::set < DefaultSymbolType > { terminatingSymbol }, terminatingSymbol, tree ) { } -SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( const SuffixTrieTerminatingSymbol & other ) : std::Components < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( other.getAlphabet ( ) ), std::make_tuple ( other.getTerminatingSymbol ( ) ) ), m_tree ( other.m_tree->clone ( ) ) { +SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( const SuffixTrieTerminatingSymbol & other ) : std::Components < SuffixTrieTerminatingSymbol, DefaultSymbolType, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( other.getAlphabet ( ) ), std::make_tuple ( other.getTerminatingSymbol ( ) ) ), m_tree ( other.m_tree->clone ( ) ) { this->m_tree->attachTree ( this ); } -SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( SuffixTrieTerminatingSymbol && other ) noexcept : std::Components < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( std::move ( other.accessComponent < GeneralAlphabet > ( ).get ( ) ) ), std::make_tuple ( std::move ( other.accessElement < TerminatingSymbol > ( ).get ( ) ) ) ), m_tree ( other.m_tree ) { +SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( SuffixTrieTerminatingSymbol && other ) noexcept : std::Components < SuffixTrieTerminatingSymbol, DefaultSymbolType, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( std::move ( other.accessComponent < GeneralAlphabet > ( ).get ( ) ) ), std::make_tuple ( std::move ( other.accessElement < TerminatingSymbol > ( ).get ( ) ) ) ), m_tree ( other.m_tree ) { this->m_tree->attachTree ( this ); other.m_tree = NULL; } @@ -113,8 +113,8 @@ SuffixTrieTerminatingSymbol::operator std::string ( ) const { SuffixTrieTerminatingSymbol SuffixTrieTerminatingSymbol::parse ( std::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, SuffixTrieTerminatingSymbol::getXmlTagName() ); - std::set < alphabet::Symbol > rankedAlphabet = IndexFromXMLParser::parseAlphabet ( input ); - alphabet::Symbol terminatingSymbol = alib::xmlApi < alphabet::Symbol >::parse ( input ); + std::set < DefaultSymbolType > rankedAlphabet = IndexFromXMLParser::parseAlphabet ( input ); + DefaultSymbolType terminatingSymbol = alib::xmlApi < DefaultSymbolType >::parse ( input ); SuffixTrieNodeTerminatingSymbol * root = IndexFromXMLParser::parseSuffixTrieNodeTerminatingSymbol ( input ); SuffixTrieTerminatingSymbol tree ( std::move ( rankedAlphabet ), terminatingSymbol, std::move ( * root ) ); @@ -126,7 +126,7 @@ SuffixTrieTerminatingSymbol SuffixTrieTerminatingSymbol::parse ( std::deque < sa void SuffixTrieTerminatingSymbol::compose ( std::deque < sax::Token > & out ) const { out.emplace_back ( SuffixTrieTerminatingSymbol::getXmlTagName(), sax::Token::TokenType::START_ELEMENT ); IndexToXMLComposer::composeAlphabet ( out, getAlphabet ( ) ); - alib::xmlApi < alphabet::Symbol >::compose ( out, getTerminatingSymbol ( ) ); + alib::xmlApi < DefaultSymbolType >::compose ( out, getTerminatingSymbol ( ) ); IndexToXMLComposer::composeNode ( out, * m_tree ); out.emplace_back ( SuffixTrieTerminatingSymbol::getXmlTagName(), sax::Token::TokenType::END_ELEMENT ); } diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.h b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.h index c875decfa0..99093df96f 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.h +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.h @@ -25,7 +25,7 @@ class TerminatingSymbol; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of RegExpElement. */ -class SuffixTrieTerminatingSymbol : public alib::ObjectBase, public std::Components < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > { +class SuffixTrieTerminatingSymbol : public alib::ObjectBase, public std::Components < SuffixTrieTerminatingSymbol, DefaultSymbolType, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > { protected: SuffixTrieNodeTerminatingSymbol * m_tree; @@ -40,9 +40,9 @@ public: */ virtual ObjectBase * plunder ( ) &&; - explicit SuffixTrieTerminatingSymbol ( std::set < alphabet::Symbol > alphabet, alphabet::Symbol terminatingSymbol ); - explicit SuffixTrieTerminatingSymbol ( std::set < alphabet::Symbol > alphabet, alphabet::Symbol terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ); - explicit SuffixTrieTerminatingSymbol ( alphabet::Symbol terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ); + explicit SuffixTrieTerminatingSymbol ( std::set < DefaultSymbolType > alphabet, DefaultSymbolType terminatingSymbol ); + explicit SuffixTrieTerminatingSymbol ( std::set < DefaultSymbolType > alphabet, DefaultSymbolType terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ); + explicit SuffixTrieTerminatingSymbol ( DefaultSymbolType terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ); /** * Copy constructor. @@ -70,11 +70,11 @@ public: */ void setTree ( SuffixTrieNodeTerminatingSymbol tree ); - const std::set < alphabet::Symbol > & getAlphabet ( ) const { + const std::set < DefaultSymbolType > & getAlphabet ( ) const { return accessComponent < GeneralAlphabet > ( ).get ( ); } - const alphabet::Symbol & getTerminatingSymbol ( ) const { + const DefaultSymbolType & getTerminatingSymbol ( ) const { return accessElement < TerminatingSymbol > ( ).get ( ); } @@ -115,28 +115,28 @@ public: namespace std { template < > -class ComponentConstraint< indexes::SuffixTrieTerminatingSymbol, alphabet::Symbol, indexes::GeneralAlphabet > { +class ComponentConstraint< indexes::SuffixTrieTerminatingSymbol, DefaultSymbolType, indexes::GeneralAlphabet > { public: - static bool used ( const indexes::SuffixTrieTerminatingSymbol & index, const alphabet::Symbol & symbol ) { + static bool used ( const indexes::SuffixTrieTerminatingSymbol & index, const DefaultSymbolType & symbol ) { return index.getTerminatingSymbol ( ) == symbol || index.getRoot ( ).testSymbol ( symbol ); } - static bool available ( const indexes::SuffixTrieTerminatingSymbol &, const alphabet::Symbol & ) { + static bool available ( const indexes::SuffixTrieTerminatingSymbol &, const DefaultSymbolType & ) { return true; } - static void valid ( const indexes::SuffixTrieTerminatingSymbol &, const alphabet::Symbol & ) { + static void valid ( const indexes::SuffixTrieTerminatingSymbol &, const DefaultSymbolType & ) { } }; template < > -class ElementConstraint< indexes::SuffixTrieTerminatingSymbol, alphabet::Symbol, indexes::TerminatingSymbol > { +class ElementConstraint< indexes::SuffixTrieTerminatingSymbol, DefaultSymbolType, indexes::TerminatingSymbol > { public: - static bool available ( const indexes::SuffixTrieTerminatingSymbol & index, const alphabet::Symbol & symbol ) { + static bool available ( const indexes::SuffixTrieTerminatingSymbol & index, const DefaultSymbolType & symbol ) { return index.getAlphabet ( ).count ( symbol ); } - static void valid ( const indexes::SuffixTrieTerminatingSymbol &, const alphabet::Symbol & ) { + static void valid ( const indexes::SuffixTrieTerminatingSymbol &, const DefaultSymbolType & ) { } }; -- GitLab