base/common/src/main/com/thesett/common/util/Filterators.java
public static <T> Collection<T> collectIterator(Iterator<T> iterator, Collection<T> targetCollection)
    {
        while (iterator.hasNext())
        {
            targetCollection.add(iterator.next());
        }

        return targetCollection;
    }
public static <T> Collection<T> collectIterator(Iterator<T> iterator, Collection<T> targetCollection)
    {
        while (iterator.hasNext())
        {
            targetCollection.add(iterator.next());
        }

        return targetCollection;
    }
public static < T > Collection < T > collectIterator ( Iterator < T > iterator , Collection < T > targetCollection ) { while ( iterator . hasNext ( ) ) { targetCollection . add ( iterator . next ( ) ) ; } return targetCollection ; }
Extracts all elements from an iterator, usually created from a filterator, and adds them into the target
collection, returning that collection as the result.

@param  <T>              The type of the iterator and collection to add to.
@param  iterator         The iterator to extract from.
@param  targetCollection The collection to add to.

@return The collection added to.
Extracts all elements from an iterator usually created from a filterator and adds them into the target collection returning that collection as the result .