Added RLCSA index option
[SXSI/TextCollection.git] / incbwt / bits / deltavector.h
index 28334fe..12b41de 100644 (file)
@@ -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&);
 };