### Question:
IntIteratorFlyweight implements PeekableIntIterator { @Override public PeekableIntIterator clone() { try { IntIteratorFlyweight x = (IntIteratorFlyweight) super.clone(); if(this.iter != null) { x.iter = this.iter.clone(); } return x; } catch (CloneNotSupportedException e) { return null; } } IntIteratorFlyweight();  IntIteratorFlyweight(RoaringBitmap r); @Override PeekableIntIterator clone(); @Override boolean hasNext(); @Override int next(); void wrap(RoaringBitmap r); @Override void advanceIfNeeded(final int minval); @Override int peekNext();  }### Answer:
@Test public void testIterationFromBitmapClone() { final Random source = new Random(0xcb000a2b9b5bdfb6L); final int[] data = takeSortedAndDistinct(source, 450000); for (int i = 0; i < 25000; ++i) { data[70000 + i] = data[70000] + i; } RoaringBitmap bitmap = RoaringBitmap.bitmapOf(data); bitmap.runOptimize(); IntIteratorFlyweight iter = (IntIteratorFlyweight) new IntIteratorFlyweight(bitmap).clone(); ReverseIntIteratorFlyweight reverseIter = (ReverseIntIteratorFlyweight) new ReverseIntIteratorFlyweight(bitmap).clone(); final List<Integer> intIteratorCopy = asList(iter); final List<Integer> reverseIntIteratorCopy = asList(reverseIter); assertEquals(bitmap.getCardinality(), intIteratorCopy.size()); assertEquals(bitmap.getCardinality(), reverseIntIteratorCopy.size()); assertEquals(Ints.asList(data), intIteratorCopy); assertEquals(Lists.reverse(Ints.asList(data)), reverseIntIteratorCopy); }
@Test public void testClone() { RoaringBitmap bitmap = RoaringBitmap.bitmapOf(1, 2, 3, 4, 5); IntIteratorFlyweight iter = new IntIteratorFlyweight(bitmap); PeekableIntIterator iterClone = iter.clone(); final List<Integer> iterList = asList(iter); final List<Integer> iterCloneList = asList(iterClone); assertEquals(iterList.toString(), iterCloneList.toString()); }