Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
ExactSubtreeRepeatsFromSubtreeAutomaton.h
Go to the documentation of this file.
1
6#pragma once
7
9
13
14namespace arbology {
15
16namespace properties {
17
22 template < class SymbolType >
23 static void repeatsInternal ( const tree::PrefixRankedTree < SymbolType > & originalTree, const automaton::InputDrivenDPDA < common::ranked_symbol < SymbolType >, char, ext::set < unsigned > > & automaton, ext::vector < common::ranked_symbol < unsigned > > & repeats, const ext::set < unsigned > & state, unsigned size, unsigned ac );
24
25public:
30 template < class SymbolType >
32
33};
34
35template < class SymbolType >
36void ExactSubtreeRepeatsFromSubtreeAutomaton::repeatsInternal ( const tree::PrefixRankedTree < SymbolType > & originalTree, const automaton::InputDrivenDPDA < common::ranked_symbol < SymbolType >, char, ext::set < unsigned > > & automaton, ext::vector < common::ranked_symbol < unsigned > > & repeats, const ext::set < unsigned > & state, unsigned size, unsigned ac ) {
37 if ( state.empty ( ) )
38 return;
39
40 if ( ac == 0 )
41 for ( unsigned label : state )
42 repeats [ label - size ] = common::ranked_symbol < unsigned > ( * state.begin ( ) - size, originalTree.getContent ( ) [ * state.begin ( ) - size ].getRank ( ) );
43 else
44 for ( const std::pair < const ext::pair < ext::set < unsigned >, common::ranked_symbol < SymbolType > >, ext::set < unsigned > > & transition : automaton.getTransitionsFromState ( state ) )
45 repeatsInternal ( originalTree, automaton, repeats, transition.second, size + 1, ac - 1 + transition.first.second.getRank ( ) );
46}
47
48template < class SymbolType >
53 repeatsInternal ( tree, deterministicSubtreePushdownAutomaton, data, deterministicSubtreePushdownAutomaton.getInitialState ( ), 0, 1 );
55}
56
57} /* namespace properties */
58
59} /* namespace arbology */
60
static automaton::InputDrivenNPDA< common::ranked_symbol< SymbolType >, char, unsigned > construct(const tree::PrefixRankedTree< SymbolType > &tree)
Definition: ExactSubtreeAutomaton.h:27
Definition: ExactSubtreeRepeatsFromSubtreeAutomaton.h:21
static tree::PrefixRankedTree< unsigned > repeats(const tree::PrefixRankedTree< SymbolType > &tree)
Definition: ExactSubtreeRepeatsFromSubtreeAutomaton.h:49
Deterministic input driven pushdown automaton. Accepts subset of context free languages.
Definition: InputDrivenDPDA.h:79
const StateType & getInitialState() const &
Definition: InputDrivenDPDA.h:131
Nondeterministic input driven pushdown automaton. Accepts subset of context free languages.
Definition: InputDrivenNPDA.h:79
static automaton::DFA< SymbolType, StateType > determinize(const automaton::DFA< SymbolType, StateType > &automaton)
Definition: Determinize.h:276
Definition: ranked_symbol.hpp:20
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
Definition: set.hpp:44
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
Tree structure represented as linear sequece as result of preorder traversal. The representation is s...
Definition: PrefixRankedTree.h:71
const ext::vector< common::ranked_symbol< SymbolType > > & getContent() const &
Definition: PrefixRankedTree.h:235
Definition: BoyerMooreHorspool.h:22
Definition: ToGrammar.h:31
Definition: FailStateLabel.cpp:12
Definition: BackwardOccurrenceTest.h:17