Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
SuffixTrieTerminatingSymbol.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/vector>
9#include <alib/list>
10#include <alib/string>
11#include <alib/set>
12#include <core/components.hpp>
14
15namespace indexes {
16
17class GeneralAlphabet;
18class TerminatingSymbol;
19
24class SuffixTrieTerminatingSymbol final : public core::Components < SuffixTrieTerminatingSymbol, ext::set < DefaultSymbolType >, component::Set, GeneralAlphabet, DefaultSymbolType, component::Value, TerminatingSymbol > {
25protected:
27
28public:
32
42
47
52
58
59 const ext::set < DefaultSymbolType > & getAlphabet ( ) const {
60 return accessComponent < GeneralAlphabet > ( ).get ( );
61 }
62
64 return accessComponent < TerminatingSymbol > ( ).get ( );
65 }
66
67 friend ext::ostream & operator << ( ext::ostream & out, const SuffixTrieTerminatingSymbol & instance );
68
69 auto operator <=> ( const SuffixTrieTerminatingSymbol & other ) const {
70 return std::tie ( * m_tree, getAlphabet(), getTerminatingSymbol() ) <=> std::tie ( * other.m_tree, other.getAlphabet(), other.getTerminatingSymbol() );
71 }
72
73 bool operator == ( const SuffixTrieTerminatingSymbol & other ) const {
74 return std::tie ( * m_tree, getAlphabet(), getTerminatingSymbol() ) == std::tie ( * other.m_tree, other.getAlphabet(), other.getTerminatingSymbol() );
75 }
76};
77
78} /* namespace tree */
79
80namespace core {
81
82template < >
83class SetConstraint< indexes::SuffixTrieTerminatingSymbol, DefaultSymbolType, indexes::GeneralAlphabet > {
84public:
85 static bool used ( const indexes::SuffixTrieTerminatingSymbol & index, const DefaultSymbolType & symbol ) {
86 return index.getTerminatingSymbol ( ) == symbol || index.getRoot ( ).testSymbol ( symbol );
87 }
88
90 return true;
91 }
92
94 }
95};
96
97template < >
98class ElementConstraint< indexes::SuffixTrieTerminatingSymbol, DefaultSymbolType, indexes::TerminatingSymbol > {
99public:
100 static bool available ( const indexes::SuffixTrieTerminatingSymbol & index, const DefaultSymbolType & symbol ) {
101 return index.getAlphabet ( ).contains ( symbol );
102 }
103
105 }
106};
107
108template < >
109struct xmlApi < indexes::SuffixTrieTerminatingSymbol > {
111 static bool first ( const ext::deque < sax::Token >::const_iterator & input );
112 static std::string xmlTagName ( );
113 static void compose ( ext::deque < sax::Token > & output, const indexes::SuffixTrieTerminatingSymbol & index );
114};
115
116} /* namespace core */
117
Definition: components.hpp:181
static void valid(const indexes::SuffixTrieTerminatingSymbol &, const DefaultSymbolType &)
Definition: SuffixTrieTerminatingSymbol.h:104
static bool available(const indexes::SuffixTrieTerminatingSymbol &index, const DefaultSymbolType &symbol)
Definition: SuffixTrieTerminatingSymbol.h:100
Definition: components.hpp:25
static bool available(const indexes::SuffixTrieTerminatingSymbol &, const DefaultSymbolType &)
Definition: SuffixTrieTerminatingSymbol.h:89
static void valid(const indexes::SuffixTrieTerminatingSymbol &, const DefaultSymbolType &)
Definition: SuffixTrieTerminatingSymbol.h:93
static bool used(const indexes::SuffixTrieTerminatingSymbol &index, const DefaultSymbolType &symbol)
Definition: SuffixTrieTerminatingSymbol.h:85
Definition: setComponents.hpp:26
Class extending the deque class from the standard library. Original reason is to allow printing of th...
Definition: deque.hpp:44
Definition: ostream.h:14
Definition: set.hpp:44
Definition: SuffixTrieNodeTerminatingSymbol.h:20
bool testSymbol(const DefaultSymbolType &symbol) const
Definition: SuffixTrieNodeTerminatingSymbol.cpp:146
Definition: SuffixTrieTerminatingSymbol.h:24
auto operator<=>(const SuffixTrieTerminatingSymbol &other) const
Definition: SuffixTrieTerminatingSymbol.h:69
~SuffixTrieTerminatingSymbol() noexcept
Definition: SuffixTrieTerminatingSymbol.cpp:58
void setTree(SuffixTrieNodeTerminatingSymbol tree)
Definition: SuffixTrieTerminatingSymbol.cpp:70
const SuffixTrieNodeTerminatingSymbol & getRoot() const
Definition: SuffixTrieTerminatingSymbol.cpp:62
SuffixTrieNodeTerminatingSymbol * m_tree
Definition: SuffixTrieTerminatingSymbol.h:26
SuffixTrieTerminatingSymbol & operator=(const SuffixTrieTerminatingSymbol &other)
Definition: SuffixTrieTerminatingSymbol.cpp:41
friend ext::ostream & operator<<(ext::ostream &out, const SuffixTrieTerminatingSymbol &instance)
Definition: SuffixTrieTerminatingSymbol.cpp:80
const ext::set< DefaultSymbolType > & getAlphabet() const
Definition: SuffixTrieTerminatingSymbol.h:59
const DefaultSymbolType & getTerminatingSymbol() const
Definition: SuffixTrieTerminatingSymbol.h:63
bool operator==(const SuffixTrieTerminatingSymbol &other) const
Definition: SuffixTrieTerminatingSymbol.h:73
SuffixTrieTerminatingSymbol(ext::set< DefaultSymbolType > alphabet, DefaultSymbolType terminatingSymbol)
Definition: SuffixTrieTerminatingSymbol.cpp:22
Definition: Object.h:16
Definition: BarSymbol.cpp:12
Definition: normalize.hpp:10
Definition: sigHandler.cpp:20
constexpr tuple< Elements &... > tie(Elements &... args) noexcept
Helper of extended tuple of references construction. The tuple is constructed to reffer to values in ...
Definition: tuple.hpp:218
Definition: CompressedBitParallelTreeIndex.h:40
Definition: BackwardOccurrenceTest.h:17
Definition: xmlApi.hpp:27