Class SizedIterator<E>

  • Type Parameters:
    E - the type of elements returned by this iterator
    All Implemented Interfaces:
    Iterator<E>

    @ParametersAreNonnullByDefault
    public class SizedIterator<E>
    extends Object
    implements Iterator<E>
    A size-based Iterator that loads each value with a IntFunction.
    • Constructor Detail

      • SizedIterator

        public SizedIterator​(@Nonnegative
                             int size,
                             IntFunction<E> mappingFunction)
        Constructs a new SizedIterator.
        Parameters:
        size - the size of the iterator
        mappingFunction - the function used to retrieve the value at a specified index
      • SizedIterator

        public SizedIterator​(@Nonnegative
                             int size,
                             IntFunction<E> mappingFunction,
                             @Nonnegative
                             int index)
        Constructs a new SizedIterator.
        Parameters:
        size - the size of the iterator
        mappingFunction - the function used to retrieve the value at a specified index
        index - the starting index
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface Iterator<E>
      • next

        public E next()
        Specified by:
        next in interface Iterator<E>
      • remove

        public void remove()
        Specified by:
        remove in interface Iterator<E>