Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Concepts
GoodSuffixShiftTable.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/vector>
9
10#include <string/LinearString.h>
11
17
18namespace string {
19
20namespace properties {
21
26public:
31 template < class SymbolType >
33
34};
35
36template < class SymbolType >
39
41 size_t max = reversed.getContent ( ).size ( ) - borderArray.back ( );
42
44
46
47 ext::set < unsigned > state = factorAutomaton.getInitialState ( );
48 result.push_back ( 1 );
49 for ( const SymbolType & symbol : reversed.getContent ( ) ) {
50 state = factorAutomaton.getTransitions ( ).find ( ext::make_pair ( std::move ( state ), symbol ) )->second;
51 if ( state.size ( ) >= 2 ) {
52 unsigned first = * state.begin ( );
53 unsigned second = * std::next ( state.begin ( ) );
54
55 result.push_back ( second - first );
56 } else {
57 result.push_back ( max );
58 }
59 }
60
61 return result;
62}
63
64} /* namespace properties */
65
66} /* namespace string */
67
Deterministic finite automaton. Accepts regular languages.
Definition: DFA.h:71
const ext::map< ext::pair< StateType, SymbolType >, StateType > & getTransitions() const &
Definition: DFA.h:473
const StateType & getInitialState() const &
Definition: DFA.h:105
static automaton::DFA< SymbolType, StateType > determinize(const automaton::DFA< SymbolType, StateType > &automaton)
Definition: Determinize.h:276
static automaton::NFA< SymbolType, StateType > remove(const automaton::EpsilonNFA< SymbolType, StateType > &fsm)
Definition: EpsilonRemoverIncoming.h:96
Definition: set.hpp:44
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: set.hpp:99
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
Linear string.
Definition: LinearString.h:57
const ext::vector< SymbolType > & getContent() const &
Definition: LinearString.h:238
static ext::vector< size_t > construct(const string::LinearString< SymbolType > &string)
Definition: BorderArray.h:27
Definition: GoodSuffixShiftTable.h:25
static ext::vector< size_t > gss(const string::LinearString< SymbolType > &pattern)
Definition: GoodSuffixShiftTable.h:37
static string::LinearString< SymbolType > reverse(const string::LinearString< SymbolType > &arg)
Definition: StringReverse.h:35
static automaton::EpsilonNFA< SymbolType, unsigned > construct(const string::LinearString< SymbolType > &text)
Definition: NondeterministicExactFactorAutomaton.h:26
p second
Definition: ToRegExpAlgebraic.h:126
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
for(const StateType &state :fsm.getStates()) renamingData.insert(std Rename::RenamedAutomaton< T > result(renamingData.at(fsm.getInitialState()))
Definition: Rename.h:253
constexpr const T & max(const T &a)
Root case of maximum computation. The maximum from one value is the value itself.
Definition: algorithm.hpp:278
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
Definition: RandomStringFactory.cpp:12