Here you can find the source of union(Collection coll)
Parameter | Description |
---|---|
coll | A Collection of sets |
public static Set union(Collection coll)
//package com.java2s; //The MIT License import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.Set; public class Main { /**// w w w . ja v a 2 s . c o m * Returns the union of all the sets given in a collection. * * @param coll A Collection of sets */ public static Set union(Collection coll) { Set set = new HashSet(); for (Iterator i = coll.iterator(); i.hasNext();) { set.addAll((Collection) i.next()); } return set; } /** * Returns the union of two collections * * @param coll A Collection of sets */ public static Set union(Collection c1, Collection c2) { Set set = new HashSet(); set.addAll(c1); set.addAll(c2); return set; } }