30template <
class SymbolType = DefaultSymbolType >
31class PrefixRankedBarTree;
36#include <ext/algorithm>
54#include <string/LinearString.h>
77template <
class SymbolType >
78class PrefixRankedBarTree final :
public core::Components < PrefixRankedBarTree < SymbolType >, ext::set < common::ranked_symbol < SymbolType > >, component::Set, std::tuple < GeneralAlphabet, BarSymbols > > {
130 return this->
template accessComponent < GeneralAlphabet > ( ).get ( );
139 return std::move ( this->
template accessComponent < GeneralAlphabet > ( ).
get ( ) );
148 this->
template accessComponent < GeneralAlphabet > ( ).add ( symbols );
157 return this->
template accessComponent < BarSymbols > ( ).get ( );
166 return std::move ( this->
template accessComponent < BarSymbols > ( ).
get ( ) );
175 this->
template accessComponent < BarSymbols > ( ).add ( bars );
237 out <<
"(PrefixRankedBarTree";
239 out <<
" bars = " << instance.
getBars ( );
240 out <<
" content = " << instance.
getContent ( );
255template <
class SymbolType >
257 setContent ( std::move ( data ) );
260template <
class SymbolType >
264template <
class SymbolType >
268template <
class SymbolType >
272template <
class SymbolType >
277template <
class SymbolType >
279 return std::move ( this->m_Data );
282template <
class SymbolType >
284 arityChecksum ( data );
288 throw TreeException (
"Input symbols not in the alphabet." );
291 this->m_Data = std::move ( data );
294template <
class SymbolType >
303 if ( getBars ( ).contains ( symbol ) )
304 return Data { current.terminals, static_cast < int > ( current.bars + symbol.getRank ( ) - 1 ), current.types - 1 };
306 return Data { static_cast < int > ( current.terminals + symbol.getRank ( ) - 1 ), current.bars, current.types + 1 };
309 if ( accRes.terminals != 0 || accRes.bars != 0 || accRes.types != 0 )
310 throw TreeException (
"The string does not form a tree" );
313template <
class SymbolType >
315 return this->m_Data.empty ( );
327template <
class SymbolType >
341 return std::find ( content.
begin ( ), content.
end ( ), symbol ) != content.
end ( );
371template <
class SymbolType >
385 return std::find ( content.
begin ( ), content.
end ( ), symbol ) != content.
end ( );
397 return tree.template accessComponent < tree::GeneralAlphabet > ( ).get ( ).count ( symbol );
415template <
class SymbolType >
static ext::vector< common::ranked_symbol< DefaultSymbolType > > normalizeRankedSymbols(ext::vector< common::ranked_symbol< SymbolType > > &&symbols)
Definition: SymbolNormalize.h:113
static ext::set< common::ranked_symbol< DefaultSymbolType > > normalizeRankedAlphabet(ext::set< common::ranked_symbol< SymbolType > > &&symbols)
Definition: SymbolNormalize.h:59
Definition: ranked_symbol.hpp:20
Definition: components.hpp:181
static bool available(const tree::PrefixRankedBarTree< SymbolType > &tree, const common::ranked_symbol< SymbolType > &symbol)
Definition: PrefixRankedBarTree.h:396
static bool used(const tree::PrefixRankedBarTree< SymbolType > &tree, const common::ranked_symbol< SymbolType > &symbol)
Definition: PrefixRankedBarTree.h:382
static void valid(const tree::PrefixRankedBarTree< SymbolType > &, const common::ranked_symbol< SymbolType > &)
Definition: PrefixRankedBarTree.h:406
static bool used(const tree::PrefixRankedBarTree< SymbolType > &tree, const common::ranked_symbol< SymbolType > &symbol)
Definition: PrefixRankedBarTree.h:338
static bool available(const tree::PrefixRankedBarTree< SymbolType > &, const common::ranked_symbol< SymbolType > &)
Definition: PrefixRankedBarTree.h:352
static void valid(const tree::PrefixRankedBarTree< SymbolType > &, const common::ranked_symbol< SymbolType > &)
Definition: PrefixRankedBarTree.h:362
Definition: setComponents.hpp:26
Output iterator calling a callback function on assignment.
Definition: iterator.hpp:923
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: set.hpp:99
auto end() &
Inherited behavior of end for non-const instance.
Definition: set.hpp:129
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: vector.hpp:125
auto end() &
Inherited behavior of end for non-const instance.
Definition: vector.hpp:155
Linear string.
Definition: LinearString.h:57
Tree structure represented as linear sequece as result of preorder traversal with additional bar symb...
Definition: PrefixRankedBarTree.h:78
const ext::vector< common::ranked_symbol< SymbolType > > & getContent() const &
Definition: PrefixRankedBarTree.h:273
bool operator==(const PrefixRankedBarTree &other) const
Definition: PrefixRankedBarTree.h:224
const ext::set< common::ranked_symbol< SymbolType > > & getAlphabet() const &
Definition: PrefixRankedBarTree.h:129
void extendBars(const ext::set< common::ranked_symbol< SymbolType > > &bars)
Definition: PrefixRankedBarTree.h:174
PrefixRankedBarTree(ext::set< common::ranked_symbol< SymbolType > > bars, ext::set< common::ranked_symbol< SymbolType > > alphabet, ext::vector< common::ranked_symbol< SymbolType > > data)
Creates a new instance of the tree with concrete alphabet, bars, and content.
Definition: PrefixRankedBarTree.h:256
void setContent(ext::vector< common::ranked_symbol< SymbolType > > data)
Definition: PrefixRankedBarTree.h:283
ext::set< common::ranked_symbol< SymbolType > > && getBars() &&
Definition: PrefixRankedBarTree.h:165
bool isEmpty() const
Definition: PrefixRankedBarTree.h:314
void extendAlphabet(const ext::set< common::ranked_symbol< SymbolType > > &symbols)
Definition: PrefixRankedBarTree.h:147
ext::set< common::ranked_symbol< SymbolType > > && getAlphabet() &&
Definition: PrefixRankedBarTree.h:138
friend ext::ostream & operator<<(ext::ostream &out, const PrefixRankedBarTree &instance)
Definition: PrefixRankedBarTree.h:236
const ext::set< common::ranked_symbol< SymbolType > > & getBars() const &
Definition: PrefixRankedBarTree.h:156
Tree structure represented in its natural representation. The representation is so called ranked,...
Definition: RankedTree.h:72
static ext::set< common::ranked_symbol< SymbolType > > computeBars(const ext::set< common::ranked_symbol< SymbolType > > &alphabet, const SymbolType &barBase)
Definition: TreeAuxiliary.h:89
static ext::vector< common::ranked_symbol< SymbolType > > treeToPrefix(const ext::tree< common::ranked_symbol< SymbolType > > &tree)
Definition: TreeAuxiliary.h:185
Definition: TreeException.h:15
Definition: BarSymbol.cpp:12
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
Definition: Permutation.hpp:18
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
auto begin(Container &&cont) -> decltype(std::forward(cont).begin())
Definition: iterator.hpp:900
void end()
Definition: measurements.cpp:19
auto & get(ext::ptr_array< Type, N > &tpl)
Specialisation of get function for pointer arrays.
Definition: ptr_array.hpp:693
Definition: BackwardOccurrenceTest.h:17
static tree::PrefixRankedBarTree< > eval(tree::PrefixRankedBarTree< SymbolType > &&value)
Definition: PrefixRankedBarTree.h:417
Definition: normalize.hpp:13