public static <E, R extends Collection<E>> R all(Iterator<E> iterator, Supplier<R> supplier) {
        final Function<Iterator<E>, R> consumer = new ConsumeIntoCollection<>(supplier);
        return consumer.apply(iterator);
    }
public static < E , R extends Collection < E > > R all ( Iterator < E > iterator , Supplier < R > supplier ) { final Function < Iterator < E > , R > consumer = new ConsumeIntoCollection < > ( supplier ) ; return consumer . apply ( iterator ) ; }
Yields all elements of the iterator (in a collection created by the
supplier).

@param <R> the returned collection type
@param <E> the collection element type
@param iterator the iterator that will be consumed
@param supplier the factory used to get the returned collection
@return a collection filled with iterator values