Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
CompressedBitParallelismFactors.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
24
25public:
32 template < class SymbolType >
34};
35
36template < class SymbolType >
38 if ( string.getContent ( ).empty ( ) ) {
39 if ( compressedBitParallelIndex.getData ( ).begin ( ) == compressedBitParallelIndex.getData ( ).end ( ) )
40 return { };
41
42 return { ext::sequence < unsigned > ( 0 ).begin ( ), ext::sequence < unsigned > ( compressedBitParallelIndex.getData ( ).begin ( )->second.size ( ) ).end ( ) };
43 }
44
45 auto symbolIter = string.getContent ( ).begin ( );
46 typename ext::map < SymbolType, common::SparseBoolVector >::const_iterator symbolVectorIter = compressedBitParallelIndex.getData ( ).find ( * symbolIter );
47
48 if ( symbolVectorIter == compressedBitParallelIndex.getData ( ).end ( ) )
49 return { };
50
51 common::SparseBoolVector indexVector = symbolVectorIter->second;
52
53 for ( ++ symbolIter; symbolIter != string.getContent ( ).end ( ); ++ symbolIter ) {
54 symbolVectorIter = compressedBitParallelIndex.getData ( ).find ( * symbolIter );
55 if ( symbolVectorIter == compressedBitParallelIndex.getData ( ).end ( ) )
56 return { };
57
58 indexVector = ( indexVector << 1 ) & symbolVectorIter->second;
59 }
60
62
63 for ( unsigned i : indexVector )
64 res.insert ( i - string.getContent ( ).size ( ) + 1 );
65
66 return res;
67}
68
69} /* namespace query */
70
71} /* namespace stringology */
72
Definition: SparseBoolVector.hpp:27
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
Compressed bit parallel string index. Stores a bit vector for each symbol of the alphabet....
Definition: CompressedBitParallelIndex.h:53
const ext::map< SymbolType, common::SparseBoolVector > & getData() const &
Definition: CompressedBitParallelIndex.h:172
Linear string.
Definition: LinearString.h:57
Definition: CompressedBitParallelismFactors.h:23
static ext::set< unsigned > query(const indexes::stringology::CompressedBitParallelIndex< SymbolType > &compressedBitParallelIndex, const string::LinearString< SymbolType > &string)
Definition: CompressedBitParallelismFactors.h:37
int i
Definition: AllEpsilonClosure.h:118
return res
Definition: MinimizeByPartitioning.h:145
void end()
Definition: measurements.cpp:19
Definition: ArithmeticCompression.h:18