Class Iterators


  • public final class Iterators
    extends Object
    Static utility methods for Iterator.
    Author:
    Martin Kouba
    • Method Detail

      • addAll

        public static <T> boolean addAll​(Collection<T> target,
                                         Iterator<? extends T> iterator)
        Add all elements in the iterator to the collection.
        Parameters:
        target -
        iterator -
        Returns:
        true if the target was modified, false otherwise
      • concat

        public static <T> Iterator<T> concat​(Iterator<? extends Iterator<? extends T>> iterators)
        Combine the iterators into a single one.
        Parameters:
        iterators - An iterator of iterators
        Returns:
        a single combined iterator
      • transform

        public static <T,​R> Iterator<R> transform​(Iterator<T> iterator,
                                                        Function<? super T,​? extends R> function)
        Parameters:
        iterator -
        function -
        Returns:
        an iterator that applies the given function to each element of the original iterator