Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.nio.ByteBuffer;
import java.util.BitSet;
import java.util.NoSuchElementException;

/**
* WrappedImmutableBitSetBitmap implements ImmutableBitmap for java.util.BitSet
Expand Down Expand Up @@ -47,26 +48,35 @@ public WrappedImmutableBitSetBitmap(ByteBuffer byteBuffer){

private class BitSetIterator implements IntIterator
{
private int pos = -1;
private int nextPos;

BitSetIterator()
{
nextPos = bitmap.nextSetBit(0);
}

@Override
public boolean hasNext()
{
return bitmap.nextSetBit(pos + 1) >= 0;
return nextPos >= 0;
}

@Override
public int next()
{
pos = bitmap.nextSetBit(pos + 1);
int pos = nextPos;
if (pos < 0) {
throw new NoSuchElementException();
}
nextPos = bitmap.nextSetBit(pos + 1);
return pos;
}

@Override
public IntIterator clone()
{
BitSetIterator newIt = new BitSetIterator();
newIt.pos = pos;
newIt.nextPos = nextPos;
return newIt;
}
}
Expand Down