Skip to content
Snippets Groups Projects
Commit e9ddc18d authored by Jan Trávníček's avatar Jan Trávníček
Browse files

update suffix trie indexes to components2

parent a4fd9c00
No related branches found
No related tags found
No related merge requests found
......@@ -24,23 +24,23 @@ namespace indexes {
SuffixTrieFinalMark::SuffixTrieFinalMark ( std::set < alphabet::Symbol > 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 < > ( ) ), tree ( NULL ) {
SuffixTrieFinalMark::SuffixTrieFinalMark ( std::set < alphabet::Symbol > alphabet, SuffixTrieNodeFinalMark tree ) : std::Components2 < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), 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 < > ( ) ), tree ( NULL ) {
SuffixTrieFinalMark::SuffixTrieFinalMark ( const SuffixTrieTerminatingSymbol & other ) : std::Components2 < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), 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 < > ( ) ), tree ( other.tree->clone ( ) ) {
SuffixTrieFinalMark::SuffixTrieFinalMark ( const SuffixTrieFinalMark & other ) : std::Components2 < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), tree ( other.tree->clone ( ) ) {
this->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 < > ( ) ), tree ( other.tree ) {
SuffixTrieFinalMark::SuffixTrieFinalMark ( SuffixTrieFinalMark && other ) noexcept : std::Components2 < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( other.accessComponent < GeneralAlphabet > ( ).get ( ) ) ), std::tuple < > ( ) ), tree ( other.tree ) {
this->tree->attachTree ( this );
other.tree = NULL;
}
......@@ -135,24 +135,6 @@ void SuffixTrieFinalMark::compose ( std::deque < sax::Token > & out ) const {
 
} /* namespace indexes */
 
namespace std {
template < >
bool indexes::SuffixTrieFinalMark::Component < indexes::SuffixTrieFinalMark, alphabet::Symbol, indexes::GeneralAlphabet >::used ( const alphabet::Symbol & symbol ) const {
return static_cast < const indexes::SuffixTrieFinalMark * > ( this )->getRoot ( ).testSymbol ( symbol );
}
template < >
bool indexes::SuffixTrieFinalMark::Component < indexes::SuffixTrieFinalMark, alphabet::Symbol, indexes::GeneralAlphabet >::available ( const alphabet::Symbol & ) const {
return true;
}
template < >
void indexes::SuffixTrieFinalMark::Component < indexes::SuffixTrieFinalMark, alphabet::Symbol, indexes::GeneralAlphabet >::valid ( const alphabet::Symbol & ) const {
}
} /* namespace std */
namespace alib {
 
auto suffixTreeFinalMarkParserRegister = xmlApi < alib::Object >::ParserRegister < indexes::SuffixTrieFinalMark > ( );
......
......@@ -12,7 +12,7 @@
#include <list>
#include <string>
#include <set>
#include <core/components.hpp>
#include <core/components2.hpp>
#include "SuffixTrieNodeFinalMark.h"
#include <object/ObjectBase.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::Components2 < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > {
protected:
SuffixTrieNodeFinalMark * tree;
 
......@@ -114,4 +114,23 @@ public:
 
} /* namespace tree */
 
namespace std {
template < >
class ComponentConstraint2< indexes::SuffixTrieFinalMark, alphabet::Symbol, indexes::GeneralAlphabet > {
public:
static bool used ( const indexes::SuffixTrieFinalMark & index, const alphabet::Symbol & symbol ) {
return index.getRoot ( ).testSymbol ( symbol );
}
static bool available ( const indexes::SuffixTrieFinalMark &, const alphabet::Symbol & ) {
return true;
}
static void valid ( const indexes::SuffixTrieFinalMark &, const alphabet::Symbol & ) {
}
};
} /* namespace std */
#endif /* SUFFIX_TRIE_FINAL_MARK_H_ */
......@@ -23,18 +23,18 @@ namespace indexes {
SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( std::set < alphabet::Symbol > alphabet, alphabet::Symbol 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 ) ) ), tree ( NULL ) {
SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( std::set < alphabet::Symbol > alphabet, alphabet::Symbol terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ) : std::Components2 < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( std::move ( alphabet ) ), std::make_tuple ( std::move ( terminatingSymbol ) ) ), 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 ( const SuffixTrieTerminatingSymbol & other ) : std::Components < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( other.getAlphabet ( ) ), std::make_tuple ( other.getTerminatingSymbol ( ) ) ), tree ( other.tree->clone ( ) ) {
SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( const SuffixTrieTerminatingSymbol & other ) : std::Components2 < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( other.getAlphabet ( ) ), std::make_tuple ( other.getTerminatingSymbol ( ) ) ), tree ( other.tree->clone ( ) ) {
this->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 ( ) ) ) ), tree ( other.tree ) {
SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( SuffixTrieTerminatingSymbol && other ) noexcept : std::Components2 < 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 ( ) ) ) ), tree ( other.tree ) {
this->tree->attachTree ( this );
other.tree = NULL;
}
......@@ -132,33 +132,6 @@ void SuffixTrieTerminatingSymbol::compose ( std::deque < sax::Token > & out ) co
 
} /* namespace indexes */
 
namespace std {
template < >
bool indexes::SuffixTrieTerminatingSymbol::Component < indexes::SuffixTrieTerminatingSymbol, alphabet::Symbol, indexes::GeneralAlphabet >::used ( const alphabet::Symbol & symbol ) const {
return static_cast < const indexes::SuffixTrieTerminatingSymbol * > ( this )->getTerminatingSymbol ( ) == symbol || static_cast < const indexes::SuffixTrieTerminatingSymbol * > ( this )->getRoot ( ).testSymbol ( symbol );
}
template < >
bool indexes::SuffixTrieTerminatingSymbol::Component < indexes::SuffixTrieTerminatingSymbol, alphabet::Symbol, indexes::GeneralAlphabet >::available ( const alphabet::Symbol & ) const {
return true;
}
template < >
bool indexes::SuffixTrieTerminatingSymbol::Element < indexes::SuffixTrieTerminatingSymbol, alphabet::Symbol, indexes::TerminatingSymbol >::available ( const alphabet::Symbol & symbol ) const {
return static_cast < const indexes::SuffixTrieTerminatingSymbol * > ( this )->getAlphabet ( ).count ( symbol );
}
template < >
void indexes::SuffixTrieTerminatingSymbol::Component < indexes::SuffixTrieTerminatingSymbol, alphabet::Symbol, indexes::GeneralAlphabet >::valid ( const alphabet::Symbol & ) const {
}
template < >
void indexes::SuffixTrieTerminatingSymbol::Element < indexes::SuffixTrieTerminatingSymbol, alphabet::Symbol, indexes::TerminatingSymbol >::valid ( const alphabet::Symbol & ) const {
}
} /* namespace std */
namespace alib {
 
auto suffixTreeTerminatingSymbolParserRegister = xmlApi < alib::Object >::ParserRegister < indexes::SuffixTrieTerminatingSymbol > ( );
......
......@@ -12,7 +12,7 @@
#include <list>
#include <string>
#include <set>
#include <core/components.hpp>
#include <core/components2.hpp>
#include "SuffixTrieNodeTerminatingSymbol.h"
#include <object/ObjectBase.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::Components2 < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > {
protected:
SuffixTrieNodeTerminatingSymbol * tree;
 
......@@ -110,4 +110,34 @@ public:
 
} /* namespace tree */
 
namespace std {
template < >
class ComponentConstraint2< indexes::SuffixTrieTerminatingSymbol, alphabet::Symbol, indexes::GeneralAlphabet > {
public:
static bool used ( const indexes::SuffixTrieTerminatingSymbol & index, const alphabet::Symbol & symbol ) {
return index.getTerminatingSymbol ( ) == symbol || index.getRoot ( ).testSymbol ( symbol );
}
static bool available ( const indexes::SuffixTrieTerminatingSymbol &, const alphabet::Symbol & ) {
return true;
}
static void valid ( const indexes::SuffixTrieTerminatingSymbol &, const alphabet::Symbol & ) {
}
};
template < >
class ElementConstraint2< indexes::SuffixTrieTerminatingSymbol, alphabet::Symbol, indexes::TerminatingSymbol > {
public:
static bool available ( const indexes::SuffixTrieTerminatingSymbol & index, const alphabet::Symbol & symbol ) {
return index.getAlphabet ( ).count ( symbol );
}
static void valid ( const indexes::SuffixTrieTerminatingSymbol &, const alphabet::Symbol & ) {
}
};
} /* namespace std */
#endif /* SUFFIX_TRIE_TERMINATING_SYMBOL_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment