// Path: src/main/java/com/googlecode/javaewah/ChunkIterator.java
// public interface ChunkIterator {
// 
//     /**
//      * Is there more?
//      *
//      * @return true, if there is more, false otherwise
//      */
//     boolean hasNext();
// 
//     /**
//      * Return the next bit
//      *
//      * @return the bit
//      */
//     boolean nextBit();
// 
//     /**
//      * Return the length of the next bit
//      *
//      * @return the length
//      */
//     int nextLength();
// 
//     /**
//      * Move the iterator at the next different bit
//      */
//     void move();
// 
//     /**
//      * Move the iterator at the next ith bit
//      *
//      * @param bits  the number of bits to skip
//      */
//     void move(int bits);
// 
// }
// 
// Path: src/main/java/com/googlecode/javaewah32/EWAHCompressedBitmap32.java
// public static final int WORD_IN_BITS = 32;


import static com.googlecode.javaewah32.EWAHCompressedBitmap32.WORD_IN_BITS;
import com.googlecode.javaewah.ChunkIterator;
    @Override
    public void move() {
        move(this.nextLength);
    }

    @Override
    public void move(int bits) {
        this.nextLength -= bits;
        if(this.nextLength <= 0) {
            do {
                this.nextBit = null;
                updateNext();
                this.hasNext = moveToNextRLW();
            } while(this.nextLength <= 0 && this.hasNext);
        }
    }

    private boolean moveToNextRLW() {
        while (!runningHasNext() && !literalHasNext()) {
            if (!hasNextRLW()) {
                return this.nextBit!=null;
            }
            setRLW(nextRLW());
            updateNext();
        }
        return true;
    }

  private void setRLW(RunningLengthWord32 rlw) {
        this.runningLength = Math.min(this.sizeInBits,
// Path: src/main/java/com/googlecode/javaewah/ChunkIterator.java
// public interface ChunkIterator {
// 
//     /**
//      * Is there more?
//      *
//      * @return true, if there is more, false otherwise
//      */
//     boolean hasNext();
// 
//     /**
//      * Return the next bit
//      *
//      * @return the bit
//      */
//     boolean nextBit();
// 
//     /**
//      * Return the length of the next bit
//      *
//      * @return the length
//      */
//     int nextLength();
// 
//     /**
//      * Move the iterator at the next different bit
//      */
//     void move();
// 
//     /**
//      * Move the iterator at the next ith bit
//      *
//      * @param bits  the number of bits to skip
//      */
//     void move(int bits);
// 
// }
// 
// Path: src/main/java/com/googlecode/javaewah32/EWAHCompressedBitmap32.java
// public static final int WORD_IN_BITS = 32;


// Path: src/main/java/com/googlecode/javaewah32/ChunkIteratorImpl32.java
import static com.googlecode.javaewah32.EWAHCompressedBitmap32.WORD_IN_BITS;
import com.googlecode.javaewah.ChunkIterator;

    @Override
    public void move() {
        move(this.nextLength);
    }

    @Override
    public void move(int bits) {
        this.nextLength -= bits;
        if(this.nextLength <= 0) {
            do {
                this.nextBit = null;
                updateNext();
                this.hasNext = moveToNextRLW();
            } while(this.nextLength <= 0 && this.hasNext);
        }
    }

    private boolean moveToNextRLW() {
        while (!runningHasNext() && !literalHasNext()) {
            if (!hasNextRLW()) {
                return this.nextBit!=null;
            }
            setRLW(nextRLW());
            updateNext();
        }
        return true;
    }

  private void setRLW(RunningLengthWord32 rlw) {
        this.runningLength = Math.min(this.sizeInBits,
                                      this.position + WORD_IN_BITS * rlw.getRunningLength());