9#include <string/LinearString.h>
32 template <
class SymbolType,
size_t BitmaskBitCount >
37template <
class SymbolType,
size_t BitmaskBitCount >
42 size_t patternLength = pattern.
getString ( ).getContent ( ).size ( );
43 size_t subjectLength = subject.
getContent ( ).size ( );
44 size_t posInSubject = 0;
45 size_t bitmaskLength =
std::min ( BitmaskBitCount, patternLength );
49 while ( posInSubject + patternLength <= subjectLength ) {
50 size_t posInPattern = bitmaskLength;
51 size_t lastPosOfFactor = bitmaskLength;
54 currentBitmask.set ( );
56 while ( posInPattern > 0 && currentBitmask.any ( ) ) {
58 if ( symbolVectorIter == pattern.
getData ( ).end ( ) )
61 currentBitmask &= symbolVectorIter->second;
65 if ( currentBitmask.test ( bitmaskLength - 1 ) ) {
67 if ( posInPattern > 0 )
68 lastPosOfFactor = posInPattern;
70 size_t k = bitmaskLength;
73 while ( k < patternLength && pattern.
getString ( ).getContent ( ).at ( k ) == subject.
getContent ( ).at ( posInSubject + k ) ) k++;
75 if ( k == patternLength )
77 occ.insert ( posInSubject );
84 posInSubject += lastPosOfFactor;
Class extending the bitset class from the standard library. Original reason is to allow printing of t...
Definition: bitset.hpp:42
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
Bit set string index. Stores a bit set for each symbol of the alphabet. The bit set of symbol a conta...
Definition: BitSetIndex.h:54
const ext::map< SymbolType, ext::bitset< BitmaskBitCount > > & getData() const &
Definition: BitSetIndex.h:185
const string::LinearString< SymbolType > & getString() const &
Definition: BitSetIndex.h:195
Linear string.
Definition: LinearString.h:57
const ext::vector< SymbolType > & getContent() const &
Definition: LinearString.h:238
Definition: BNDMOccurrences.h:23
static ext::set< unsigned > query(const indexes::stringology::BitSetIndex< SymbolType, BitmaskBitCount > &pattern, const string::LinearString< SymbolType > &subject)
Definition: BNDMOccurrences.h:38
constexpr const T & min(const T &a)
Definition: algorithm.hpp:310
Definition: ArithmeticCompression.h:18