Class SkippingIterator<E>

  • All Implemented Interfaces:

    public class SkippingIterator<E>
    extends AbstractIteratorDecorator<E>
    Decorates another iterator to skip the first N elements.

    In case an offset parameter other than 0 is provided, the decorated iterator is immediately advanced to this position, skipping all elements before that position.

    • Constructor Detail

      • SkippingIterator

        public SkippingIterator​(Iterator<E> iterator,
                                long offset)
        Decorates the specified iterator to skip all elements until the iterator reaches the position at offset.

        The iterator is immediately advanced until it reaches the position at offset, incurring O(n) time.

        iterator - the iterator to be decorated
        offset - the index of the first element of the decorated iterator to return
        NullPointerException - if iterator is null
        IllegalArgumentException - if offset is negative