/hostadmiral/trunk/src/ak/hostadmiral/util/CollectionUtils.java |
---|
0,0 → 1,22 |
package ak.hostadmiral.util; |
import java.util.Collection; |
import java.util.Iterator; |
public class CollectionUtils |
{ |
/** |
* adds elements of second collection to the first one if they are not in it yet |
*/ |
public static Collection addUnique(Collection first, Collection second) |
{ |
if(first == null || second == null) return first; |
for(Iterator i = second.iterator(); i.hasNext(); ) { |
Object o = i.next(); |
if(!first.contains(o)) first.add(o); |
} |
return first; |
} |
} |