Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
SuffixTrieFactors.h
Go to the documentation of this file.
1
6#pragma once
7
9#include <string/LinearString.h>
10
11namespace stringology {
12
13namespace query {
14
22 template < class SymbolType >
23 static void accumulateResult ( const ext::trie < SymbolType, std::optional < unsigned > > & trie, ext::set < unsigned > & res ) {
24 if ( trie.getData ( ) )
25 res.insert ( trie.getData ( ).value ( ) );
26
27 for ( const std::pair < const SymbolType, ext::trie < SymbolType, std::optional < unsigned > > > & child : trie.getChildren ( ) ) {
28 accumulateResult ( child.second, res );
29 }
30 }
31
32public:
39 template < class SymbolType >
41
42};
43
44template < class SymbolType >
47 for ( const SymbolType & symbol : string.getContent ( ) ) {
48 auto iter = node->getChildren ( ).find ( symbol );
49 if ( iter == node->getChildren ( ).end ( ) ) {
50 return {};
51 }
52 node = & iter->second;
53 }
54
56 accumulateResult ( * node, res );
57 return res;
58}
59
60} /* namespace query */
61
62} /* namespace stringology */
63
Definition: set.hpp:44
Class introducing a trie with interface trying to be close to the interface of standard library conta...
Definition: trie.hpp:47
Suffix trie string index. Tree like representation of all suffixes. Nodes of the trie are optionally ...
Definition: SuffixTrie.h:55
const ext::trie< SymbolType, std::optional< unsigned > > & getRoot() const &
Definition: SuffixTrie.h:205
Linear string.
Definition: LinearString.h:57
Definition: SuffixTrieFactors.h:21
static ext::set< unsigned > query(const indexes::stringology::SuffixTrie< SymbolType > &suffixTrie, const string::LinearString< SymbolType > &string)
Definition: SuffixTrieFactors.h:45
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
return res
Definition: MinimizeByPartitioning.h:145
Definition: Node.cpp:11
Definition: ArithmeticCompression.h:18