Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
Repetition.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/vector>
9#include <string/LinearString.h>
10
11namespace string {
12
13namespace properties {
14
16public:
23 template < class SymbolType >
25};
26
27template < class SymbolType >
29 const auto& x = string.getContent();
30 size_t maxlen = 0 , first = 0 , second = 0 ;
31 for ( size_t i = 0 ; i < x.size() ; ++ i ) {
32 for ( size_t j = i + 1 ; j < x.size() ; ++ j ) {
33 size_t k = 0 ;
34 while ( i + k < j && j + k < x.size() && x[i + k] == x[j + k]) ++ k ;
35 if ( k > maxlen ) {
36 maxlen = k ;
37 first = i ;
38 second = j ;
39 }
40 }
41 }
42 return ext::make_tuple(maxlen, first, second) ;
43}
44
45} /* namespace properties */
46
47} /* namespace string */
48
Class extending the tuple class from the standard library. Original reason is to allow printing of th...
Definition: tuple.hpp:42
Linear string.
Definition: LinearString.h:57
Definition: Repetition.h:15
static ext::tuple< size_t, size_t, size_t > construct(const string::LinearString< SymbolType > &string)
Definition: Repetition.h:28
p second
Definition: ToRegExpAlgebraic.h:126
int i
Definition: AllEpsilonClosure.h:118
constexpr auto make_tuple(Elements &&... args)
Helper of extended tuple construction. The tuple is constructed from values pack, types are deduced.
Definition: tuple.hpp:203
Definition: RandomStringFactory.cpp:12