13#include <string/LinearString.h>
34 template <
class SymbolType >
39 size_t div_up (
const size_t &x ,
const size_t &y ) {
40 return ( x % y == 1 ) ? x / y + 1 : x / y ;
43 template <
class SymbolType >
50 content.push_back ( endSymbol );
55 contentPatt.push_back ( endSymbol );
57 std::vector y = content ;
58 std::vector x = contentPatt ;
59 size_t n = y.size() - 1 , m = x.size() - 1 ;
62 size_t p = 0 ,
q = 0 ;
63 size_t s = 0 , p1 = 1 , q1 = 0 ;
64 size_t p2 = 0 , q2 = 0 ;
69 while( x[s + p1 + q1] == x[s + q1] ) ++ q1 ;
70 if ( p1 + q1 >= k * p1 ) {
77 if ( s + p1 + q1 == m )
goto search ;
78 p1 +=
std::max(
static_cast < size_t > ( 1 ) ,
div_up ( q1 , k ) ) ;
83 while( x[s + p2 + q2] == x[s + q2] && p2 + q2 < k* p2 ) ++ q2 ;
84 if ( p2 + q2 == k * p2 )
goto parse ;
85 if ( s + p2 + q2 == m )
goto search ;
86 if ( q2 == p1 + q1 ) {
96 while ( x[s + p1 + q1] == x[s + q1]) ++ q1 ;
97 while ( p1 + q1 >= k * p1 ) {
103 if ( p1 < p2 )
goto parse ;
107 while ( p <= n - m ) {
108 while ( p + s +
q < n && y[p + s +
q] == x[s +
q]) ++
q;
109 if (
q == m - s && std::equal( y.begin() + p, y.begin() + p + s , x.begin())) occ.insert(p);
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: GalilSeiferas.h:28
static ext::set< unsigned > match(const string::LinearString< SymbolType > &subject, const string::LinearString< SymbolType > &pattern)
Definition: GalilSeiferas.h:44
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
q
Definition: SingleInitialStateEpsilonTransition.h:85
T createUnique(T object, const Alphabets &... alphabets)
Definition: createUnique.hpp:46
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
void start(measurements::stealth_string name, measurements::Type type)
Definition: measurements.cpp:14
void end()
Definition: measurements.cpp:19
size_t div_up(const size_t &x, const size_t &y)
Definition: GalilSeiferas.h:39
Definition: ArithmeticCompression.h:18