public static <T> Set<T> createSet (Iterator<T> elements) {
        final Set<T> result = new HashSet<> ();
        while (elements.hasNext ()) result.add (elements.next ());
        return result;
    }
public static < T > Set < T > createSet ( Iterator < T > elements ) { final Set < T > result = new HashSet < > ( ) ; while ( elements . hasNext ( ) ) result . add ( elements . next ( ) ) ; return result ; }
Create a {@link java.util.Set} from an {@link Iterator}.