Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
ApproximateEnhancedCoversComputation.h
Go to the documentation of this file.
1
6#pragma once
7
9
10namespace stringology::cover {
15public:
24 template < class SymbolType >
26};
27
28template < class SymbolType >
30 // found approximate enhanced covers are not stored directly but rather as a
31 // set of lfactors
33
34 // the maximum number of covered positions
35 unsigned h = 0;
36
37 // there are no borders for an empty string and a string with only one
38 // character
39 if ( x.getContent ( ).size ( ) < 2 )
41
42 State previousState = constrFirstState ( x, k, x.getContent ( )[0] );
43
44 // check if the first character is a border (makes sense only for k = 0)
45 if ( isBorder ( previousState, x, k ) )
46 updateEnhCov ( previousState, result, h );
47
48 for ( size_t i = 1; i < x.getContent ( ).size ( ); ++i ) {
49 State nextState = constrNextState ( x, previousState, k, x.getContent ( )[previousState.depth] );
50
51 if ( nextState.elements.size ( ) < 2 )
52 break;
53
54 if ( isBorder ( nextState, x, k ) )
55 updateEnhCov ( nextState, result, h );
56
57 previousState = std::move ( nextState );
58 }
59
60 // in the end the set of actual strings is computed from the set of lfactors
61 return getFactors ( x, result );
62}
63
64} /* namespace stringology::cover */
Definition: set.hpp:44
Linear string.
Definition: LinearString.h:57
const ext::vector< SymbolType > & getContent() const &
Definition: LinearString.h:238
Definition: ApproximateEnhancedCoversCommon.h:20
static bool isBorder(const State &state, const string::LinearString< SymbolType > &x, unsigned k)
Definition: ApproximateEnhancedCoversCommon.h:171
static State constrNextState(const string::LinearString< SymbolType > &x, const State &previousState, unsigned k, const SymbolType &symbol)
Definition: ApproximateEnhancedCoversCommon.h:142
static ext::set< string::LinearString< SymbolType > > getFactors(const string::LinearString< SymbolType > &x, ext::set< ext::pair< unsigned int, unsigned int > > &enhCovers)
Definition: ApproximateEnhancedCoversCommon.h:189
static State constrFirstState(const string::LinearString< SymbolType > &x, unsigned k, const SymbolType &symbol)
Definition: ApproximateEnhancedCoversCommon.h:115
static void updateEnhCov(const State &state, ext::set< ext::pair< unsigned, unsigned > > &enhCovers, unsigned &h)
Definition: ApproximateEnhancedCoversCommon.h:92
Definition: ApproximateEnhancedCoversComputation.h:14
static ext::set< string::LinearString< SymbolType > > compute(const string::LinearString< SymbolType > &x, unsigned k)
Definition: ApproximateEnhancedCoversComputation.h:29
int i
Definition: AllEpsilonClosure.h:118
for(const StateType &state :fsm.getStates()) renamingData.insert(std Rename::RenamedAutomaton< T > result(renamingData.at(fsm.getInitialState()))
Definition: Rename.h:253
Definition: ApproximateCoversComputation.cpp:9
Definition: ApproximateEnhancedCoversCommon.h:41
ext::vector< Element > elements
Definition: ApproximateEnhancedCoversCommon.h:51