public static <E> Set<E> toSet(Iterator<? extends E> iterator)
	{
		Set<E> set = new LinkedHashSet<E>();
		while (iterator.hasNext()) {
			set.add(iterator.next());
		}
		return set;
	}
public static <E> Set<E> toSet(Iterator<? extends E> iterator)
	{
		Set<E> set = new LinkedHashSet<E>();
		while (iterator.hasNext()) {
			set.add(iterator.next());
		}
		return set;
	}
public static < E > Set < E > toSet ( Iterator < ? extends E > iterator ) { Set < E > set = new LinkedHashSet < E > ( ) ; while ( iterator . hasNext ( ) ) { set . add ( iterator . next ( ) ) ; } return set ; }
Returns a {@code Set} containing all the given {@code Iterator}'s
elements. The returned {@code Set} has the same iteration order as
the given {@code Iterator}. This method consumes entirely the input
{@code Iterator}.

@param <E> the type of the returned {@code Set}'s elements.
@param iterator the {@code Iterator} to consume.

@return the {@code Set} created from the given {@code Iterator}.

@throws NullPointerException if {@code iterator} is {@code null}.
Returns a { @code Set } containing all the given { @code Iterator } s elements . The returned { @code Set } has the same iteration order as the given { @code Iterator } . This method consumes entirely the input { @code Iterator } .