Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
ExactSubsequenceAutomaton.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <automaton/FSM/DFA.h>
9#include <string/LinearString.h>
10
11namespace stringology {
12
13namespace indexing {
14
16public:
21 template < class SymbolType >
23};
24
25template < class SymbolType >
28 for(const SymbolType & symbol : text.getAlphabet ( ) ) {
29 f[symbol] = 0;
30 }
31
33 res.addFinalState ( 0 );
34 res.setInputAlphabet ( text.getAlphabet ( ) );
35
36 unsigned i = 1;
37 for ( const SymbolType & symbol : text.getContent ( ) ) {
38 res.addState ( i );
39 res.addFinalState ( i );
40
41 for ( unsigned j = f [ symbol ]; j < i; j++ ) {
42 res.addTransition ( j, symbol, i );
43 }
44 f[symbol] = i;
45 i++;
46 }
47
48 return res;
49}
50
51} /* namespace indexing */
52
53} /* namespace stringology */
54
Deterministic finite automaton. Accepts regular languages.
Definition: DFA.h:71
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
Linear string.
Definition: LinearString.h:57
const ext::set< SymbolType > & getAlphabet() const &
Definition: LinearString.h:103
const ext::vector< SymbolType > & getContent() const &
Definition: LinearString.h:238
Definition: ExactSubsequenceAutomaton.h:15
static automaton::DFA< SymbolType, unsigned > construct(const string::LinearString< SymbolType > &text)
Definition: ExactSubsequenceAutomaton.h:26
int i
Definition: AllEpsilonClosure.h:118
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
return res
Definition: MinimizeByPartitioning.h:145
Definition: ArithmeticCompression.h:18