/** * Resets the iterator back to the start of the list. */ @Override public void reset() { _reset(); }
/** * Gets an iterator that iterates through an array of {@link Iterator}s * one after another. * * @param <E> the element type * @param iterators the iterators to use, not null or empty or contain nulls * @return a combination iterator over the iterators * @throws NullPointerException if iterators array is null or contains a null */ public static <E> Iterator<E> chainedIterator(final Iterator<? extends E>... iterators) { return new IteratorChain<>(iterators); }
/** * Returns <code>true</code> if any child iterator has remaining elements. * * @return true if this iterator has remaining elements */ @Override public boolean hasNext() { start(); return anyValueSet(valueSet) || anyHasNext(iterators); }
/** * Gets an iterator over an object array. * * @param <E> the element type * @param array the array over which to iterate * @return an iterator over the array * @throws NullPointerException if array is null */ public static <E> ResettableIterator<E> arrayIterator(final E... array) { return new ObjectArrayIterator<>(array); }
@Override public MapIterator<K, V> mapIterator() { if (map instanceof IterableMap) { final MapIterator<K, V> it = ((IterableMap<K, V>) map).mapIterator(); return UnmodifiableMapIterator.unmodifiableMapIterator(it); } final MapIterator<K, V> it = new EntrySetMapIterator<>(map); return UnmodifiableMapIterator.unmodifiableMapIterator(it); }
@Override public K next() { lastKey = super.next(); canRemove = true; return lastKey; }
@Override public E next() { last = super.next(); return last; }
/** * Gets an iterator that supports pushback of elements. * * @param <E> the element type * @param iterator the iterator to decorate, not null * @return a pushback iterator * @throws NullPointerException if the iterator is null * @since 4.0 */ public static <E> Iterator<E> pushbackIterator(final Iterator<? extends E> iterator) { return PushbackIterator.pushbackIterator(iterator); }
/** * Returns an iterator that interleaves elements from the decorated iterators. * * @param <E> the element type * @param iterators the array of iterators to interleave * @return an iterator, interleaving the decorated iterators * @throws NullPointerException if any iterator is null * @since 4.1 */ public static <E> ZippingIterator<E> zippingIterator(final Iterator<? extends E>... iterators) { return new ZippingIterator<>(iterators); }
@Override public E previous() { last = super.previous(); return last; }
/** * Resets the iterator back to the start index. */ @Override public void reset() { super.reset(); this.lastItemIndex = -1; }
/** * Gets an immutable version of a {@link ListIterator}. The returned object * will always throw an {@link UnsupportedOperationException} for * the {@link Iterator#remove}, {@link ListIterator#add} and * {@link ListIterator#set} methods. * * @param <E> the element type * @param listIterator the iterator to make immutable * @return an immutable version of the iterator */ public static <E> ListIterator<E> unmodifiableListIterator(final ListIterator<E> listIterator) { return UnmodifiableListIterator.umodifiableListIterator(listIterator); }
/** * Gets an empty iterator. * <p> * This iterator is a valid iterator object that will iterate over nothing. * * @param <E> the element type * @return an iterator over nothing */ public static <E> ResettableIterator<E> emptyIterator() { return EmptyIterator.<E>resettableEmptyIterator(); }
/** * Gets an empty ordered iterator. * <p> * This iterator is a valid iterator object that will iterate * over nothing. * * @param <E> the element type * @return an ordered iterator over nothing */ public static <E> OrderedIterator<E> emptyOrderedIterator() { return EmptyOrderedIterator.<E>emptyOrderedIterator(); }
/** * Gets an immutable version of an {@link Iterator}. The returned object * will always throw an {@link UnsupportedOperationException} for * the {@link Iterator#remove} method. * * @param <E> the element type * @param iterator the iterator to make immutable * @return an immutable version of the iterator */ public static <E> Iterator<E> unmodifiableIterator(final Iterator<E> iterator) { return UnmodifiableIterator.unmodifiableIterator(iterator); }
/** * Gets the index of the item to be retrieved if {@link #previous()} is called. * * @return the index of the item to be retrieved next */ @Override public int previousIndex() { return this.index - getStartIndex() - 1; }
@Override public E next() { last = super.next(); return last; }
@Override public E next() { lastElement = super.next(); canRemove = true; return lastElement; }