@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); }
@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 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 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); }
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(); }
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();  }