43 template<
class RandomIterator>
47 const RandomIterator begin_2,
48 const RandomIterator end_1,
const RandomIterator end_2
51 unsigned int count = 0;
52 RandomIterator it_1 = begin_1, it_2 = begin_2;
55 while ( (it_1 != end_1) && (it_2 != end_2) && ! quit )
76 template<
class RandomIterator>
78 const RandomIterator end,
79 std::map<unsigned int,unsigned int>& out)
const
87 for (++it_k; it_k!=end; ++it_k)
91 z = common_prefix_length(begin, it_k, end, end);
97 it_r = it_k.operator+(z) - 1;
102 unsigned int k_bis = it_k - it_l;
105 if ( out.find(k_bis) == out.end() )
110 if ( z <= (
unsigned int)it_b )
119 it_q += common_prefix_length(it_q, it_b+1, end, end);
121 out[it_k] = it_q - it_k;
137 template<
class RandomIterator>
139 const RandomIterator end,
140 std::map<unsigned int, unsigned int>& out)
const
142 std::map<unsigned int, unsigned int> z;
146 z_boxes(begin, end, z);
154 if (z.find(j) != z.end())
155 out[j + z[j] - 1] = z[j];
171 template<
class RandomIterator>
172 template<
class UnaryPredicate>
174 (
const RandomIterator pattern_begin,
const RandomIterator pattern_end,
175 const RandomIterator text_begin,
const RandomIterator text_end,
176 UnaryPredicate& action )
const
178 std::map<unsigned int, unsigned int> spi;
183 const int pattern_length = pattern_end - pattern_begin;
184 const int text_length = text_end - text_begin;
186 assert(pattern_begin != pattern_end);
188 spi_prime(pattern_begin, pattern_end, spi);
192 while ( ((
int)it_t <= text_length - (pattern_length - it_p)) && !stop )
196 common = common_prefix_length(it_p, it_t, pattern_end, text_end);
205 if ( (
int)it_p == pattern_length+1 )
206 stop = !action( (
int)it_t - pattern_length-1 );
209 it_p.
set(pattern_begin+i, i+1);