8#include <string/LinearString.h>
26 template <
class SymbolType >
32 template <
class SymbolType >
36 template <
class SymbolType >
39 template <
class SymbolType >
40 static ext::set < ext::pair < string::LinearString < SymbolType >,
unsigned > > processState (
const ext::set <
ext::pair < unsigned, unsigned > > & previousState,
ext::vector < SymbolType > & lfactor,
unsigned previousDepth,
unsigned k,
const automaton::NFA<
SymbolType,
ext::pair<unsigned, unsigned> > & approximateSuffixNDA,
const string::LinearString < SymbolType > & pattern,
bool restricted );
43template <
class SymbolType >
48template <
class SymbolType >
56 return processState ( initialState, lfactor, depth, k, approximateSuffixNDA, pattern, restricted );
59template <
class SymbolType >
60ext::set < ext::pair < string::LinearString < SymbolType >,
unsigned > > ApproximateCoversComputation::processState (
const ext::set <
ext::pair < unsigned, unsigned > > & previousState,
ext::vector < SymbolType > & lfactor,
unsigned previousDepth,
unsigned k,
const automaton::NFA <
SymbolType,
ext::pair < unsigned, unsigned > > & approximateSuffixNDA,
const string::LinearString < SymbolType > & pattern,
bool restricted ) {
65 unsigned depth = previousDepth + 1;
67 for (
const auto & state : previousState ) {
69 for (
const auto & it : transition_range ) {
70 newState.insert ( it.second );
76 if ( newState.size ( ) > 1 && ( restricted == levelZero ) ) {
77 if ( newState.
begin ( ) -> first == depth ) {
78 lfactor.push_back ( symbol );
80 if ( newState.rbegin ( ) -> first == pattern.
getContent ( ).size ( ) ) {
82 auto it = std::next ( newState.rbegin ( ) );
83 auto prev = newState.rbegin ( );
85 for ( ; it != newState.rend ( ); ++ it, ++ prev ) {
86 if ( prev -> first - it -> first > lfactor.size ( ) ) {
93 unsigned l = smallestDistanceCover ( newState, lfactor );
94 if ( lfactor.size ( ) > l ) {
101 resultSet.insert ( resultSet2.
begin ( ), resultSet2.
end ( ) );
110template <
class SymbolType >
117 lmax = std::accumulate ( subset.begin ( ), subset.end ( ), subset.begin ( ) ->
second, [ ] (
unsigned cMax,
const ext::pair < unsigned, unsigned > & e ) { return std::max ( cMax, e.second ); } );
121 auto it = std::next ( subset.begin ( ) );
122 auto prev = subset.begin ( );
123 auto last = std::prev ( subset.end ( ) );
124 while ( it != subset.end ( ) ) {
126 if ( it != last && it ->
second == l ) {
127 it = subset.erase ( it );
129 if ( it -> first - prev -> first > coverCandidate.size ( ) )
Nondeterministic finite automaton. Accepts regular languages.
Definition: NFA.h:66
const StateType & getInitialState() const &
Definition: NFA.h:107
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: set.hpp:99
auto end() &
Inherited behavior of end for non-const instance.
Definition: set.hpp:129
auto equal_range(K &&key) const &
Make range of elements with key equal to the key.
Definition: set.hpp:200
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::set< SymbolType > & getAlphabet() const &
Definition: LinearString.h:103
const ext::vector< SymbolType > & getContent() const &
Definition: LinearString.h:238
Definition: ApproximateCoversComputation.h:15
static ext::set< ext::pair< string::LinearString< SymbolType >, unsigned > > compute(const string::LinearString< SymbolType > &pattern, unsigned k, bool restricted=false)
Definition: ApproximateCoversComputation.h:49
static automaton::NFA< SymbolType, ext::pair< unsigned int, unsigned int > > construct(const string::LinearString< SymbolType > &pattern, unsigned int k)
Definition: NondeterministicApproximateSuffixAutomatonForHammingDistance.h:24
p second
Definition: ToRegExpAlgebraic.h:126
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
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
any_of(T &&...) -> any_of< T... >
Definition: ApproximateCoversComputation.cpp:9