@Test public void nextIndex() { final long seed = Randoms.seed(); final Random random = new Random(seed); final Array<Integer> proxy = Array.of(ObjectStore.ofLength(1000)); for (int i = 0; i < proxy.length(); ++i) { proxy.set(i, random.nextInt()); } random.setSeed(seed); final ListIterator<Integer> it = new BaseSeqIterator<>(proxy); int count = 0; while (it.hasNext()) { Assert.assertEquals(it.nextIndex(), count); Assert.assertEquals(proxy.get(it.nextIndex()), it.next()); ++count; } Assert.assertEquals(count, proxy.length()); }
@Override public int nextIndex() { return cursor; }
BaseSeqIterator implements ListIterator<T> { @Override public int nextIndex() { return cursor; } }
BaseSeqIterator implements ListIterator<T> { @Override public int nextIndex() { return cursor; } BaseSeqIterator(final S array); }
BaseSeqIterator implements ListIterator<T> { @Override public int nextIndex() { return cursor; } BaseSeqIterator(final S array); @Override boolean hasNext(); @Override T next(); @Override int nextIndex(); @Override boolean hasPrevious(); @Override T previous(); @Override int previousIndex(); @Override void set(final T value); @Override void add(final T value); @Override void remove(); }
BaseSeqIterator implements ListIterator<T> { @Override public int nextIndex() { return cursor; } BaseSeqIterator(final S array); @Override boolean hasNext(); @Override T next(); @Override int nextIndex(); @Override boolean hasPrevious(); @Override T previous(); @Override int previousIndex(); @Override void set(final T value); @Override void add(final T value); @Override void remove(); final S array; }