X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=incbwt%2Fbits%2Fdeltavector.h;fp=incbwt%2Fbits%2Fdeltavector.h;h=12b41dee99176fee7e3eba8ab1117f63ace3411b;hb=13e254b7c0ee22dffbc7c3125cee0408f9b375da;hp=28334fedb4a8571b08df56353c2841fd84c7c294;hpb=e4b6bdc7cc2a1372e4d4dae50acac55cebcc7e9b;p=SXSI%2FTextCollection.git diff --git a/incbwt/bits/deltavector.h b/incbwt/bits/deltavector.h index 28334fe..12b41de 100644 --- a/incbwt/bits/deltavector.h +++ b/incbwt/bits/deltavector.h @@ -21,6 +21,19 @@ class DeltaEncoder : public VectorEncoder ~DeltaEncoder(); void setBit(usint value); + void setRun(usint start, usint len); + + // These versions are just for compatibility with RLEVector. + void addBit(usint value); + void addRun(usint start, usint len); + void flush(); // Does nothing. + + protected: + + // These are not allowed. + DeltaEncoder(); + DeltaEncoder(const DeltaEncoder&); + DeltaEncoder& operator = (const DeltaEncoder&); }; @@ -31,29 +44,57 @@ class DeltaEncoder : public VectorEncoder class DeltaVector : public BitVector { public: + typedef DeltaEncoder Encoder; + DeltaVector(std::ifstream& file); DeltaVector(std::FILE * file); - DeltaVector(DeltaEncoder& encoder, usint universe_size); + DeltaVector(Encoder& encoder, usint universe_size); ~DeltaVector(); //-------------------------------------------------------------------------- - usint rank(usint value, bool at_least = false); + usint reportSize() const; + +//-------------------------------------------------------------------------- + + class Iterator : public BitVector::Iterator + { + public: + Iterator(const DeltaVector& par); + ~Iterator(); + + usint rank(usint value, bool at_least = false); + + usint select(usint index); + usint selectNext(); - usint select(usint index); - usint selectNext(); + pair_type valueAfter(usint value); + pair_type nextValue(); - pair_type valueAfter(usint value); - pair_type nextValue(); + pair_type selectRun(usint index, usint max_length); + pair_type selectNextRun(usint max_length); - pair_type selectRun(usint index, usint max_length); - pair_type selectNextRun(usint max_length); + bool isSet(usint value); - bool isSet(usint value); + // Counts the number of 1-bit runs. + usint countRuns(); + + protected: + + // These are not allowed. + Iterator(); + Iterator(const Iterator&); + Iterator& operator = (const Iterator&); + }; //-------------------------------------------------------------------------- - usint reportSize(); + protected: + + // These are not allowed. + DeltaVector(); + DeltaVector(const DeltaVector&); + DeltaVector& operator = (const DeltaVector&); };