Interface AsyncPeekIterator<T>

    • Method Detail

      • peek

        T peek()
        throws NoSuchElementException
        Get the next item of the scan without advancing it. This item can be called multiple times, and it should return the same value each time as long as there are no intervening calls to next().
        Returns:
        the next item that will be returned by next()
        Throws:
        NoSuchElementException - if there are no items remaining in the scan
      • wrap

        static <T> AsyncPeekIterator<T> wrap​(@Nonnull
                                             AsyncIterator<T> iterator)
        Wrap an AsyncIterator with an AsyncPeekIterator. The returned scan iterator return the same sequence of elements as the supplied AsyncIterator instance in the same order. The wrapping implementation is free to advance the underlying iterator, so it is unsafe to modify iterator directly after calling this method. The returned iterator is also not thread safe, so concurrent calls to onHasNext, for example, may lead to unexpected behavior.
        Type Parameters:
        T - type of items returned by the scan
        Parameters:
        iterator - AsyncIterator to wrap
        Returns:
        an scan over the same values as scan that supports peek semantics