14#include <string/LinearString.h>
22 size_t div_up (
const size_t &x ,
const size_t &y ) {
23 return ( x % y == 1 ) ? x / y + 1 : x / y ;
26 template <
class SymbolType>
31 size_t n = text.size(), m = pat.size();
34 while (
i <= n - m ) {
36 while ( j < m && text[
i + j ] == pat[j] ) ++ j ;
37 if ( j == m ) occ.insert(
i) ;
44 template <
class SymbolType>
46 size_t n = text.size(), m = pat.size();
49 while (
i <= n - m ) {
51 while ( j < m && text[
i + j ] == pat[j] ) ++ j ;
52 if ( j == m )
return i ;
58 template <
class SymbolType>
63 size_t n = text.size(), m = pat.size();
66 while (
i <= n - m ) {
67 if ( text[
i + p] != pat[p] || text[
i +
q] != pat[
q] ) ++
i ;
70 while ( j < m && text[
i + j] == pat[j] ) ++ j ;
71 if ( j == m ) occ.insert(
i ) ;
72 if ( j <
q - 1 )
i += p ;
80 template <
class SymbolType>
82 size_t n = text.size(), m = pat.size();
85 while (
i <= n - m ) {
86 if ( text[
i + p] != pat[p] || text[
i +
q] != pat[
q] ) ++
i ;
89 while ( j < m && text[
i + j] == pat[j] ) ++ j ;
90 if ( j == m )
return i ;
91 if ( j <
q - 1 )
i += p ;
98 template <
class SymbolType>
103 size_t n = text.size(), m = pat.size();
106 ssize_t periodic_prefix , period ;
110 while (
static_cast < size_t > (
i ) <= n - m ) {
111 if (periodic_prefix == -1) {
112 i = SimpleTextSearchingFirst(text, vv_ ,
i );
113 }
else {
i = SeqSamplingFirst(text, vv_ , periodic_prefix - period , periodic_prefix ,
i ); }
114 if (
i == -1 ||
static_cast < size_t > (
i ) > n - m )
return occ ;
115 size_t j = 2 * per - 1;
116 while (j < m && text[
i + j] == pat[j]) ++j;
121 i +=
std::max ( j - per ,
static_cast < size_t > ( 1 ) ) ;
139 template <
class SymbolType >
144 template <
class SymbolType >
146 ssize_t periodic_prefix , period ;
153 if ( periodic_prefix == -1 ) {
154 res = SimpleTextSearching( subject , pattern) ;
155 }
else if (
static_cast < size_t > ( periodic_prefix ) < pattern.
getContent().size() ) {
156 res = SeqSampling( subject, pattern , periodic_prefix - period, periodic_prefix ) ;
157 }
else res = Mix( subject, pattern, period ) ;
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: vector.hpp:125
Linear string.
Definition: LinearString.h:57
const ext::vector< SymbolType > & getContent() const &
Definition: LinearString.h:238
static ext::pair< ssize_t, ssize_t > construct(const string::LinearString< SymbolType > &string)
Definition: PeriodicPrefix.h:43
Definition: SequentialSampling.h:133
static ext::set< unsigned > match(const string::LinearString< SymbolType > &subject, const string::LinearString< SymbolType > &pattern)
Definition: SequentialSampling.h:145
int i
Definition: AllEpsilonClosure.h:118
return res
Definition: MinimizeByPartitioning.h:145
q
Definition: SingleInitialStateEpsilonTransition.h:85
constexpr tuple< Elements &... > tie(Elements &... args) noexcept
Helper of extended tuple of references construction. The tuple is constructed to reffer to values in ...
Definition: tuple.hpp:218
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