Here you can find the source of addAllToSet(Set
public static <T> void addAllToSet(Set<T> set, Iterator<? extends T> it)
//package com.java2s; /**/*from ww w . j a v a2 s. c o m*/ * This file is part of the Joana IFC project. It is developed at the * Programming Paradigms Group of the Karlsruhe Institute of Technology. * * For further details on licensing please read the information at * http://joana.ipd.kit.edu or contact the authors. */ import java.util.Iterator; import java.util.Set; public class Main { public static <T> void addAllToSet(Set<T> set, Iterator<? extends T> it) { while (it.hasNext()) { set.add(it.next()); } } }