Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
Public Member Functions | Friends
tree::PrefixBarTree< SymbolType > Class Template Reference

Tree structure represented as linear sequece as result of preorder traversal with additional bar symbols. The representation is so called unranked, therefore it consists of unranked symbols bars are unranked as well. More...

#include <PrefixBarTree.h>

Inheritance diagram for tree::PrefixBarTree< SymbolType >:
[legend]
Collaboration diagram for tree::PrefixBarTree< SymbolType >:
[legend]

Public Member Functions

 PrefixBarTree (SymbolType bar, ext::set< SymbolType > alphabet, ext::vector< SymbolType > data)
 Creates a new instance of the tree with concrete alphabet, bar, and content. More...
 
 PrefixBarTree (SymbolType bar, ext::vector< SymbolType > data)
 Creates a new instance of the tree based on the content and bar, the alphabet is implicitly created from the content. More...
 
 PrefixBarTree (SymbolType bar, const UnrankedTree< SymbolType > &tree)
 Creates a new instance of the tree based on the UnrankedTree. The linear representation is constructed (including bars) by preorder traversal on the tree parameter. Bar symbol is provided as a parameter. More...
 
 PrefixBarTree (const UnrankedTree< SymbolType > &tree)
 Creates a new instance of the tree based on the UnrankedTree. The linear representation is constructed (including bars) by preorder traversal on the tree parameter. Bar symbol is created using some default value. More...
 
const ext::set< SymbolType > & getAlphabet () const &
 
ext::set< SymbolType > && getAlphabet () &&
 
void extendAlphabet (const ext::set< SymbolType > &symbols)
 
const SymbolType & getBar () const &
 
SymbolType && getBar () &&
 
const ext::vector< SymbolType > & getContent () const &
 
ext::vector< SymbolType > && getContent () &&
 
void setContent (ext::vector< SymbolType > data)
 
bool isEmpty () const
 
auto operator<=> (const PrefixBarTree &other) const
 
bool operator== (const PrefixBarTree &other) const
 
 operator string::LinearString< SymbolType > () const
 Creates a new instance of the string from a linear representation of a tree. More...
 
- Public Member Functions inherited from core::Components< PrefixBarTree< SymbolType >, ext::set< SymbolType >, component::Set, GeneralAlphabet, SymbolType, component::Value, BarSymbol >
void accessComponent ()
 

Friends

ext::ostreamoperator<< (ext::ostream &out, const PrefixBarTree &instance)
 

Additional Inherited Members

- Static Public Member Functions inherited from core::Components< PrefixBarTree< SymbolType >, ext::set< SymbolType >, component::Set, GeneralAlphabet, SymbolType, component::Value, BarSymbol >
static void registerComponent ()
 
static void unregisterComponent ()
 

Detailed Description

template<class SymbolType>
class tree::PrefixBarTree< SymbolType >

Tree structure represented as linear sequece as result of preorder traversal with additional bar symbols. The representation is so called unranked, therefore it consists of unranked symbols bars are unranked as well.

The bars represent end mark of all subtrees in the notation.

T = ( A, B \in A, C ), A (Alphabet) = finite set of unranked symbols, B (Bar) = unranked symbol representing bar, C (Content) = linear representation of the tree content

Template Parameters
SymbolTypeused for the symbol of the alphabet

Constructor & Destructor Documentation

◆ PrefixBarTree() [1/4]

template<class SymbolType >
tree::PrefixBarTree< SymbolType >::PrefixBarTree ( SymbolType  bar,
ext::set< SymbolType >  alphabet,
ext::vector< SymbolType >  data 
)
explicit

Creates a new instance of the tree with concrete alphabet, bar, and content.

Parameters
barsthe bar symbol
alphabetthe initial alphabet of the tree
datathe initial tree in linear representation

◆ PrefixBarTree() [2/4]

template<class SymbolType >
tree::PrefixBarTree< SymbolType >::PrefixBarTree ( SymbolType  bar,
ext::vector< SymbolType >  data 
)
explicit

Creates a new instance of the tree based on the content and bar, the alphabet is implicitly created from the content.

Parameters
barthe bar symbol
datathe initial tree in linear representation

◆ PrefixBarTree() [3/4]

template<class SymbolType >
tree::PrefixBarTree< SymbolType >::PrefixBarTree ( SymbolType  bar,
const UnrankedTree< SymbolType > &  tree 
)
explicit

Creates a new instance of the tree based on the UnrankedTree. The linear representation is constructed (including bars) by preorder traversal on the tree parameter. Bar symbol is provided as a parameter.

Parameters
barthe bar symbol
treeRankedTree representation of a tree.

◆ PrefixBarTree() [4/4]

template<class SymbolType >
tree::PrefixBarTree< SymbolType >::PrefixBarTree ( const UnrankedTree< SymbolType > &  tree)
explicit

Creates a new instance of the tree based on the UnrankedTree. The linear representation is constructed (including bars) by preorder traversal on the tree parameter. Bar symbol is created using some default value.

Parameters
treeUnrankedTree representation of a tree.

Member Function Documentation

◆ extendAlphabet()

template<class SymbolType >
void tree::PrefixBarTree< SymbolType >::extendAlphabet ( const ext::set< SymbolType > &  symbols)
inline

Adder of an alphabet symbols.

Parameters
symbolsthe new symbols to be added to the alphabet

◆ getAlphabet() [1/2]

template<class SymbolType >
ext::set< SymbolType > && tree::PrefixBarTree< SymbolType >::getAlphabet ( ) &&
inline

Getter of the alphabet.

Returns
the alphabet of the tree
Here is the call graph for this function:

◆ getAlphabet() [2/2]

template<class SymbolType >
const ext::set< SymbolType > & tree::PrefixBarTree< SymbolType >::getAlphabet ( ) const &
inline

Getter of the alphabet.

Returns
the alphabet of the tree
Here is the caller graph for this function:

◆ getBar() [1/2]

template<class SymbolType >
SymbolType && tree::PrefixBarTree< SymbolType >::getBar ( ) &&
inline

Getter of the bar symbol.

Returns
the bar symbol of the tree
Here is the call graph for this function:

◆ getBar() [2/2]

template<class SymbolType >
const SymbolType & tree::PrefixBarTree< SymbolType >::getBar ( ) const &
inline

Getter of the bar symbol.

Returns
the bar symbol of the tree
Here is the caller graph for this function:

◆ getContent() [1/2]

template<class SymbolType >
ext::vector< SymbolType > && tree::PrefixBarTree< SymbolType >::getContent ( ) &&

Getter of the tree representation.

Returns
List of symbols forming the linear representation of the tree.

◆ getContent() [2/2]

template<class SymbolType >
const ext::vector< SymbolType > & tree::PrefixBarTree< SymbolType >::getContent ( ) const &

Getter of the tree representation.

Returns
List of symbols forming the linear representation of the tree.
Here is the caller graph for this function:

◆ isEmpty()

template<class SymbolType >
bool tree::PrefixBarTree< SymbolType >::isEmpty
Returns
true if tree is an empty word (vector length is 0). The method is present to allow compatibility with strings. Tree is never empty in this datatype.

◆ operator string::LinearString< SymbolType >()

template<class SymbolType >
tree::PrefixBarTree< SymbolType >::operator string::LinearString< SymbolType > ( ) const
inlineexplicit

Creates a new instance of the string from a linear representation of a tree.

Returns
tree casted to string
Here is the call graph for this function:

◆ operator<=>()

template<class SymbolType >
auto tree::PrefixBarTree< SymbolType >::operator<=> ( const PrefixBarTree< SymbolType > &  other) const
inline

The three way comparison implementation

Parameters
otherthe other instance
Returns
the ordering between this object and the other.
Here is the call graph for this function:

◆ operator==()

template<class SymbolType >
bool tree::PrefixBarTree< SymbolType >::operator== ( const PrefixBarTree< SymbolType > &  other) const
inline

The equality comparison implementation.

Parameters
otherthe other object to compare with.
Returns
true if this and other objects are equal, false othervise
Here is the call graph for this function:

◆ setContent()

template<class SymbolType >
void tree::PrefixBarTree< SymbolType >::setContent ( ext::vector< SymbolType >  data)

Setter of the representation of the tree.

Exceptions
TreeExceptionwhen new tree representation is not valid or when symbol of the representation are not present in the alphabet
Parameters
datanew List of symbols forming the representation of the tree.
Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

template<class SymbolType >
ext::ostream & operator<< ( ext::ostream out,
const PrefixBarTree< SymbolType > &  instance 
)
friend

Print this object as raw representation to ostream.

Parameters
outostream where to print
instanceobject to print
Returns
modified output stream

The documentation for this class was generated from the following file: