Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
BitParallelismFactors.h
Go to the documentation of this file.
1
6#pragma once
7
9#include <string/LinearString.h>
10#include <global/GlobalData.h>
11
12#include <ext/foreach>
13
14namespace stringology {
15
16namespace query {
17
24public:
31 template < class SymbolType >
33
34};
35
36template < class SymbolType >
38 if ( string.getContent ( ).empty ( ) ) {
39 if ( bitParallelIndex.getData ( ).begin ( ) == bitParallelIndex.getData ( ).end ( ) )
40 return { };
41
42 return { ext::sequence < unsigned > ( 0 ).begin ( ), ext::sequence < unsigned > ( bitParallelIndex.getData ( ).begin ( )->second.size ( ) ).end ( ) };
43 }
44
45 auto symbolIter = string.getContent ( ).begin ( );
46 typename ext::map < SymbolType, ext::vector < bool > >::const_iterator symbolVectorIter = bitParallelIndex.getData ( ).find ( * symbolIter );
47 if ( symbolVectorIter == bitParallelIndex.getData ( ).end ( ) )
48 return { };
49
50 ext::vector < bool > indexVector = symbolVectorIter->second;
51
52 for ( ++ symbolIter; symbolIter != string.getContent ( ).end ( ); ++ symbolIter ) {
53 symbolVectorIter = bitParallelIndex.getData ( ).find ( * symbolIter );
54 if ( symbolVectorIter == bitParallelIndex.getData ( ).end ( ) )
55 return { };
56
57 indexVector = ( indexVector << 1 ) & symbolVectorIter->second;
58 }
59
61 for ( unsigned i = 0; i < indexVector.size ( ); i++ )
62 if ( indexVector [ i ] )
63 res.insert ( i - string.getContent ( ).size ( ) + 1 );
64
65 return res;
66}
67
68} /* namespace query */
69
70} /* namespace stringology */
71
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
Representation of integer sequence usable in foreach form of for loop.
Definition: foreach.hpp:408
virtual_pointer_to_integer< IntegralType > begin()
Getter of the begin iterator into the sequence.
Definition: foreach.hpp:447
virtual_pointer_to_integer< IntegralType > end()
Getter of the end iterator into the sequence.
Definition: foreach.hpp:457
Definition: set.hpp:44
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
Bit parallel string index. Stores a bit vector for each symbol of the alphabet. The bit vector of sym...
Definition: BitParallelIndex.h:51
const ext::map< SymbolType, ext::vector< bool > > & getData() const &
Definition: BitParallelIndex.h:170
Linear string.
Definition: LinearString.h:57
Definition: BitParallelismFactors.h:23
static ext::set< unsigned > query(const indexes::stringology::BitParallelIndex< SymbolType > &bitParallelIndex, const string::LinearString< SymbolType > &string)
Definition: BitParallelismFactors.h:37
int i
Definition: AllEpsilonClosure.h:118
return res
Definition: MinimizeByPartitioning.h:145
void end()
Definition: measurements.cpp:19
Definition: ArithmeticCompression.h:18