47 template <
class SymbolType >
50 template <
class SymbolType >
52 template <
class SymbolType >
55 template <
class SymbolType >
58 template <
class SymbolType >
60 template <
class SymbolType >
62 template <
class SymbolType >
65 template <
class SymbolType >
67 template <
class SymbolType >
70 template <
class SymbolType >
72 template <
class SymbolType >
76 template <
class SymbolType >
78 template <
class SymbolType >
80 template <
class SymbolType >
82 template <
class SymbolType >
85 template <
class SymbolType >
87 template <
class SymbolType >
90 template <
class SymbolType >
92 template <
class SymbolType >
94 template <
class SymbolType >
96 template <
class SymbolType,
class RepeatsType >
99 template <
class SymbolType >
101 template <
class SymbolType >
104 template <
class SymbolType >
107 template <
class SymbolType >
109 template <
class SymbolType >
114template <
class SymbolType >
116 if ( patternIter == patternEnd )
117 return subjectIter == subjectEnd;
119 if ( patternIter->getData ( ) == subtreeGap ) {
120 if ( matchHelper ( subjectIter, subjectEnd, std::next ( patternIter ), patternEnd, subtreeVariable, subtreeGap ) )
123 while ( subjectIter != subjectEnd ) {
125 if ( matchHelper ( subjectIter, subjectEnd, patternIter, patternEnd, subtreeVariable, subtreeGap ) )
130 }
else if ( subjectIter != subjectEnd ) {
131 if ( matchHelper ( * subjectIter, * patternIter, subtreeVariable, subtreeGap ) )
132 return matchHelper ( std::next ( subjectIter ), subjectEnd, std::next ( patternIter ), patternEnd, subtreeVariable, subtreeGap );
140template <
class SymbolType >
142 if ( pattern.
getData ( ) == subtreeVariable )
return true;
149template <
class SymbolType >
151 if ( patternIter == patternEnd )
152 return subjectIter == subjectEnd;
154 if ( patternIter->getData ( ) == subtreeGap ) {
155 if ( matchHelper ( subjectIter, subjectEnd, std::next ( patternIter ), patternEnd, subtreeVariable, subtreeGap, nodeWildcard ) )
158 while ( subjectIter != subjectEnd ) {
160 if ( matchHelper ( subjectIter, subjectEnd, patternIter, patternEnd, subtreeVariable, subtreeGap, nodeWildcard ) )
165 }
else if ( subjectIter != subjectEnd ) {
166 if ( matchHelper ( * subjectIter, * patternIter, subtreeVariable, subtreeGap, nodeWildcard ) )
167 return matchHelper ( std::next ( subjectIter ), subjectEnd, std::next ( patternIter ), patternEnd, subtreeVariable, subtreeGap, nodeWildcard );
175template <
class SymbolType >
177 if ( pattern.
getData ( ) == subtreeVariable )
return true;
179 if ( subject.
getData ( ) != pattern.
getData ( ) && nodeWildcard != pattern.
getData ( ) )
return false;
184template <
class SymbolType >
186 if ( pattern.
getData ( ) == subtreeVariable )
return true;
188 if ( subject.
getData ( ) != pattern.
getData ( ) && ( ! nodeWildcards.contains ( pattern.
getData ( ) ) || pattern.
getData ( ).getRank ( ) != subject.
getData ( ).getRank ( ) ) )
193 if ( !matchHelper ( std::get < 0 > ( childs ), std::get < 1 > ( childs ), subtreeVariable, nodeWildcards ) )
return false;
198template <
class SymbolType >
200 if ( pattern.
getData ( ) == subtreeVariable )
return true;
202 if ( nonlinearVariables.count ( pattern.
getData ( ) ) ) {
203 auto setting = variablesSetting.find ( pattern.
getData ( ) );
205 if ( setting != variablesSetting.end ( ) )
return repeats.getData ( ).getSymbol ( ) == setting->second;
207 variablesSetting.insert (
std::make_pair ( pattern.
getData ( ), repeats.getData ( ).getSymbol ( ) ) );
216 if ( !matchHelper ( std::get < 0 > ( childs ), std::get < 1 > ( childs ), subtreeVariable, nonlinearVariables, std::get < 2 > ( childs ), variablesSetting ) )
return false;
221template <
class SymbolType >
223 if ( matchHelper ( subject, pattern, subtreeVariable, nodeWildcards ) ) occ.insert ( index );
228 matchInternal ( index, occ, child, pattern, subtreeVariable, nodeWildcards );
231template <
class SymbolType >
233 if ( matchHelper ( subject, pattern, subtreeVariable, subtreeGap ) ) occ.insert ( index );
238 matchInternal ( index, occ, child, pattern, subtreeVariable, subtreeGap );
241template <
class SymbolType >
243 if ( matchHelper ( subject, pattern, subtreeVariable, subtreeGap, nodeWildcard ) ) occ.insert ( index );
248 matchInternal ( index, occ, child, pattern, subtreeVariable, subtreeGap, nodeWildcard );
251template <
class SymbolType,
class RepeatsType >
255 if ( matchHelper ( subject, pattern, subtreeVariable, nonlinearVariables, repeats, variablesSetting ) ) occ.insert ( index );
260 matchInternal ( index, occ, std::get < 0 > ( childs ), pattern, subtreeVariable, nonlinearVariables, std::get < 1 > ( childs ) );
263template <
class SymbolType >
265 if ( patternIter == patternEnd )
266 return subjectIter == subjectEnd;
268 if ( patternIter->getData ( ) == subtreeGap ) {
269 if ( matchUnorderedHelper ( subjectIter, subjectEnd, std::next ( patternIter ), patternEnd, subtreeVariable, subtreeGap ) )
272 while ( subjectIter != subjectEnd ) {
274 if ( matchUnorderedHelper ( subjectIter, subjectEnd, patternIter, patternEnd, subtreeVariable, subtreeGap ) )
279 }
else if ( subjectIter != subjectEnd ) {
280 if ( matchUnorderedHelper ( subjectIter->get ( ), * patternIter, subtreeVariable, subtreeGap ) )
281 return matchUnorderedHelper ( std::next ( subjectIter ), subjectEnd, std::next ( patternIter ), patternEnd, subtreeVariable, subtreeGap );
289template <
class SymbolType >
291 if ( pattern.
getData ( ) == subtreeVariable )
return true;
296 for (
const auto & child : subject.
getChildren ( ) ) {
297 subjectChildrenRefs.emplace_back ( child );
301 if ( matchUnorderedHelper ( subjectChildrenRefs.
begin ( ), subjectChildrenRefs.
end ( ), pattern.
getChildren ( ).begin ( ), pattern.
getChildren ( ).end ( ), subtreeVariable, subtreeGap ) )
303 }
while ( next_permutation ( subjectChildrenRefs.
begin ( ), subjectChildrenRefs.
end ( ) ) );
308template <
class SymbolType >
310 if ( pattern.
getData ( ) == subtreeVariable )
return true;
317 if ( ! matchUnorderedHelper ( std::get < 0 > ( childs ), std::get < 1 > ( childs ).
get ( ), subtreeVar ) )
324 for (
const auto & child : pattern.
getChildren ( ) ) {
325 patternChildrenRefs.emplace_back ( child );
329 if ( testPermutation ( subject.
getChildren ( ), patternChildrenRefs, subtreeVariable ) )
331 }
while ( next_permutation ( patternChildrenRefs.
begin ( ), patternChildrenRefs.
end ( ) ) );
336template <
class SymbolType >
338 if ( matchUnorderedHelper ( subject, pattern, subtreeVariable ) ) occ.insert ( index );
343 matchUnorderedInternal ( index, occ, child, pattern, subtreeVariable );
346template <
class SymbolType >
348 if ( matchUnorderedHelper ( subject, pattern, subtreeVariable, subtreeGap ) ) occ.insert ( index );
353 matchUnorderedInternal ( index, occ, child, pattern, subtreeVariable, subtreeGap );
356template <
class SymbolType >
365template <
class SymbolType >
374template <
class SymbolType >
383template <
class SymbolType >
392template <
class SymbolType >
401template <
class SymbolType >
412template <
class SymbolType >
421template <
class SymbolType >
437template <
class SymbolType >
454template <
class SymbolType >
470template <
class SymbolType >
Definition: ExactPatternMatch.h:41
static ext::set< unsigned > match(const tree::UnorderedUnrankedTree< SymbolType > &subject, const tree::UnorderedUnrankedPattern< SymbolType > &pattern)
Definition: ExactPatternMatch.h:357
Definition: ranked_symbol.hpp:20
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
Class extending the reference wrapper class from the standard library. Original reason is to allow it...
Definition: functional.hpp:108
Class introducing a tree with interface trying to be close to the interface of standard library conta...
Definition: tree.hpp:52
T & getData()
Getter of the value in the root node.
Definition: tree.hpp:100
ext::vector< tree > & getChildren()
Getter of children of the root node.
Definition: tree.hpp:120
Class extending the tuple class from the standard library. Original reason is to allow printing of th...
Definition: tuple.hpp:42
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
Nonlinear tree pattern represented as linear sequece as result of preorder traversal with additional ...
Definition: PrefixRankedBarNonlinearPattern.h:91
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
const ext::vector< common::ranked_symbol< SymbolType > > & getContent() const &
Definition: PrefixRankedBarPattern.h:334
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
Nonlinear tree pattern represented as linear sequece as result of preorder traversal....
Definition: PrefixRankedNonlinearPattern.h:82
const ext::vector< common::ranked_symbol< SymbolType > > & getContent() const &
Definition: PrefixRankedNonlinearPattern.h:333
Tree pattern represented as linear sequece as result of preorder traversal. The representation is so ...
Definition: PrefixRankedPattern.h:77
const ext::vector< common::ranked_symbol< SymbolType > > & getContent() const &
Definition: PrefixRankedPattern.h:262
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
Extended tree pattern represented in its natural representation. The representation is so called rank...
Definition: RankedExtendedPattern.h:74
const ext::set< common::ranked_symbol< SymbolType > > & getNodeWildcards() const &
Definition: RankedExtendedPattern.h:155
const ext::tree< common::ranked_symbol< SymbolType > > & getContent() const &
Definition: RankedExtendedPattern.h:281
const common::ranked_symbol< SymbolType > & getSubtreeWildcard() const &
Definition: RankedExtendedPattern.h:182
Nonlinear tree pattern represented in its natural representation. The representation is so called ran...
Definition: RankedNonlinearPattern.h:74
const ext::set< common::ranked_symbol< SymbolType > > & getNonlinearVariables() const &
Definition: RankedNonlinearPattern.h:183
const common::ranked_symbol< SymbolType > & getSubtreeWildcard() const &
Definition: RankedNonlinearPattern.h:165
const ext::tree< common::ranked_symbol< SymbolType > > & getContent() const &
Definition: RankedNonlinearPattern.h:286
Tree pattern represented in its natural representation. The representation is so called ranked,...
Definition: RankedPattern.h:72
const ext::tree< common::ranked_symbol< SymbolType > > & getContent() const &
Definition: RankedPattern.h:251
const common::ranked_symbol< SymbolType > & getSubtreeWildcard() const &
Definition: RankedPattern.h:153
Tree structure represented in its natural representation. The representation is so called ranked,...
Definition: RankedTree.h:72
const ext::tree< common::ranked_symbol< SymbolType > > & getContent() const &
Definition: RankedTree.h:252
Tree pattern represented in its natural representation. The representation is so called ranked,...
Definition: UnorderedRankedPattern.h:72
const ext::tree< common::ranked_symbol< SymbolType > > & getContent() const &
Definition: UnorderedRankedPattern.h:251
const common::ranked_symbol< SymbolType > & getSubtreeWildcard() const &
Definition: UnorderedRankedPattern.h:153
Tree structure represented in its natural representation. The representation is so called ranked,...
Definition: UnorderedRankedTree.h:70
const ext::tree< common::ranked_symbol< SymbolType > > & getContent() const &
Definition: UnorderedRankedTree.h:228
Tree pattern represented in its natural representation. The representation is so called unranked,...
Definition: UnorderedUnrankedPattern.h:73
const SymbolType & getSubtreeGap() const &
Definition: UnorderedUnrankedPattern.h:163
const ext::tree< SymbolType > & getContent() const &
Definition: UnorderedUnrankedPattern.h:261
const SymbolType & getSubtreeWildcard() const &
Definition: UnorderedUnrankedPattern.h:145
Tree pattern represented in its natural representation. The representation is so called unranked,...
Definition: UnorderedUnrankedTree.h:69
const ext::tree< SymbolType > & getContent() const &
Definition: UnorderedUnrankedTree.h:217
Extended tree pattern represented in its natural representation. The representation is so called unra...
Definition: UnrankedExtendedPattern.h:76
const SymbolType & getNodeWildcard() const &
Definition: UnrankedExtendedPattern.h:150
const SymbolType & getSubtreeGap() const &
Definition: UnrankedExtendedPattern.h:186
const SymbolType & getSubtreeWildcard() const &
Definition: UnrankedExtendedPattern.h:168
const ext::tree< SymbolType > & getContent() const &
Definition: UnrankedExtendedPattern.h:285
Tree pattern represented in its natural representation. The representation is so called unranked,...
Definition: UnrankedPattern.h:73
const ext::tree< SymbolType > & getContent() const &
Definition: UnrankedPattern.h:263
const SymbolType & getSubtreeGap() const &
Definition: UnrankedPattern.h:165
const SymbolType & getSubtreeWildcard() const &
Definition: UnrankedPattern.h:147
Tree represented in its natural representation. The representation is so called unranked,...
Definition: UnrankedTree.h:69
const ext::tree< SymbolType > & getContent() const &
Definition: UnrankedTree.h:217
static size_t occurrence(const PrefixRankedBarTree< SymbolType > &subject, const ext::vector< int > &subjectSubtreeJumpTable, const PrefixRankedBarTree< SymbolType > &pattern, size_t subjectPosition, size_t patternStartIndex=0)
Definition: ForwardOccurrenceTest.h:42
static ext::vector< int > compute(const tree::PrefixRankedBarTree< SymbolType > &subject)
Definition: SubtreeJumpTable.h:49
Definition: BoyerMooreHorspool.h:22
int i
Definition: AllEpsilonClosure.h:118
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
const_tuple_foreach< Types ... > make_tuple_foreach(const Types &... args)
Function construction of foreach tuple pack helper.
Definition: foreach.hpp:280
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
auto & get(ext::ptr_array< Type, N > &tpl)
Specialisation of get function for pointer arrays.
Definition: ptr_array.hpp:693