Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
SuffixArrayNaive.h
Go to the documentation of this file.
1
6#pragma once
7
9#include <string/LinearString.h>
10
11namespace stringology {
12
13namespace indexing {
14
21public:
27 template < class SymbolType >
29
30};
31
32template < class SymbolType >
35
36 for ( unsigned i = 0; i < w.getContent ( ).size ( ); ++ i )
37 data.push_back ( i );
38
39 sort ( data.begin ( ), data.end ( ), [ & ] ( unsigned first, unsigned second ) {
40 for ( ; first < w.getContent ( ).size ( ) && second < w.getContent ( ).size ( ); ++ first, ++ second ) {
41 auto res = w.getContent ( ) [ first ] <=> w.getContent ( ) [ second ];
42
43 if ( res != 0 )
44 return res < 0;
45 }
46
47 // if same up to the maximal size, the shorter suffix is smaller
48 return first > second;
49 } );
50
52}
53
54} /* namespace indexing */
55
56} /* namespace stringology */
57
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
auto end() &
Inherited behavior of end for non-const instance.
Definition: vector.hpp:155
Suffix array string index. Linear representation of all suffixes ordered lexicographically....
Definition: SuffixArray.h:51
Linear string.
Definition: LinearString.h:57
const ext::vector< SymbolType > & getContent() const &
Definition: LinearString.h:238
Definition: SuffixArrayNaive.h:20
static indexes::stringology::SuffixArray< SymbolType > construct(const string::LinearString< SymbolType > &w)
Definition: SuffixArrayNaive.h:33
p second
Definition: ToRegExpAlgebraic.h:126
int i
Definition: AllEpsilonClosure.h:118
Definition: ArithmeticCompression.h:18