Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
FirstVariableOffsetFront.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <cassert>
9
14
15namespace tree {
16
17namespace properties {
18
20public:
21 template < class SymbolType >
22 static size_t offset ( const tree::PrefixRankedPattern < SymbolType > & pattern );
23 template < class SymbolType >
24 static size_t offset ( const tree::PrefixRankedNonlinearPattern < SymbolType > & pattern );
25 template < class SymbolType >
26 static size_t offset ( const tree::PrefixRankedBarPattern < SymbolType > & pattern );
27 template < class SymbolType >
28 static size_t offset ( const tree::PrefixRankedBarNonlinearPattern < SymbolType > & pattern );
29
30};
31
32template < class SymbolType >
35}
36
37template < class SymbolType >
39 // find the distance between the beginning of the pattern and the index
40 // of the first symbol representing the variable's bar
41 size_t res = pattern.getContent ( ).size ( ) + 1;
42
43 size_t i = pattern.getContent ( ).size ( );
44 assert ( i != 0 ); // pattern size may never be 0
45 do {
46 -- i;
47 if ( pattern.getContent ( )[i] == pattern.getSubtreeWildcard ( ) || pattern.getNonlinearVariables ( ).count ( pattern.getContent ( )[i] ) )
48 res = i;
49 } while ( i > 0 );
50
51 return res;
52}
53
54template < class SymbolType >
57}
58
59template < class SymbolType >
61 // find the distance between the beginning of the pattern and the index
62 // of the first symbol representing the variable's bar
63 size_t res = pattern.getContent ( ).size ( ) + 1;
64
65 size_t i = pattern.getContent ( ).size ( );
66 assert ( i != 0 ); // pattern size may never be 0
67 do {
68 -- i;
69 if ( pattern.getContent ( )[i] == pattern.getSubtreeWildcard ( ) || pattern.getNonlinearVariables ( ).count ( pattern.getContent ( )[i] ) )
70 res = i;
71 } while ( i > 0 );
72
73 return res;
74}
75
76} /* namespace properties */
77
78} /* namespace tree */
Nonlinear tree pattern represented as linear sequece as result of preorder traversal with additional ...
Definition: PrefixRankedBarNonlinearPattern.h:91
const ext::set< common::ranked_symbol< SymbolType > > & getNonlinearVariables() const &
Definition: PrefixRankedBarNonlinearPattern.h:277
const common::ranked_symbol< SymbolType > & getSubtreeWildcard() const &
Definition: PrefixRankedBarNonlinearPattern.h:259
const ext::vector< common::ranked_symbol< SymbolType > > & getContent() const &
Definition: PrefixRankedBarNonlinearPattern.h:434
Tree pattern represented as linear sequece as result of preorder traversal with additional bar symbol...
Definition: PrefixRankedBarPattern.h:85
Nonlinear tree pattern represented as linear sequece as result of preorder traversal....
Definition: PrefixRankedNonlinearPattern.h:82
const ext::set< common::ranked_symbol< SymbolType > > & getNonlinearVariables() const &
Definition: PrefixRankedNonlinearPattern.h:208
const ext::vector< common::ranked_symbol< SymbolType > > & getContent() const &
Definition: PrefixRankedNonlinearPattern.h:333
const common::ranked_symbol< SymbolType > & getSubtreeWildcard() const &
Definition: PrefixRankedNonlinearPattern.h:190
Tree pattern represented as linear sequece as result of preorder traversal. The representation is so ...
Definition: PrefixRankedPattern.h:77
Definition: FirstVariableOffsetFront.h:19
static size_t offset(const tree::PrefixRankedPattern< SymbolType > &pattern)
Definition: FirstVariableOffsetFront.h:33
int i
Definition: AllEpsilonClosure.h:118
return res
Definition: MinimizeByPartitioning.h:145
Definition: BackwardOccurrenceTest.h:17