bitmap4 implements XdrAble, Iterable<Integer> { @Override public Iterator<Integer> iterator() { return new Iterator<Integer>() { int currentIndex = -1; @Override public boolean hasNext() { if (value == null || currentIndex > value.length * Integer.SIZE) { return false; } currentIndex++; for (; currentIndex < value.length * Integer.SIZE; currentIndex++) { int bitmapIdx = currentIndex / Integer.SIZE; int bit = (value[bitmapIdx] >> currentIndex % Integer.SIZE) & 1; if (bit != 0) { return true; } } return false; } @Override public Integer next() { checkPosition(); return currentIndex; } @Override public void remove() { throw new UnsupportedOperationException(); } private void checkPosition() { if (value == null || currentIndex < 0 || currentIndex > value.length * Integer.SIZE) { throw new NoSuchElementException(); } } }; } bitmap4();  bitmap4(int [] value);  bitmap4(XdrDecodingStream xdr); void xdrEncode(XdrEncodingStream xdr); void xdrDecode(XdrDecodingStream xdr); static bitmap4 of(int ... values); void set(int bit); boolean isSet(int bit); boolean isEmpty(); @Override Iterator<Integer> iterator(); @Override int hashCode(); @Override boolean equals(Object obj); public int[] value; }
@Test public void testIterratorNoValues() { bitmap4 bitmap = new bitmap4(); assertFalse(bitmap.iterator().hasNext()); }
@Test public void testIterratorZeroValues() { bitmap4 bitmap = new bitmap4( new int[] {0, 0}); assertFalse(bitmap.iterator().hasNext()); }