Set
union(Set one, Set two) Form a new set that is the union of two IntSets.
HashSet n = new HashSet(one.size() + two.size());
Iterator it = one.iterator();
while (it.hasNext()) {
n.add(it.next());
it = two.iterator();
while (it.hasNext()) {
n.add(it.next());
...
Set>
union(Set> a, Set> b) Returns union of
a and
b as a
Hashtable containing all elements in
a and
b
if (a == null || b == null || a.size() == 0 || b.size() == 0)
return Collections.EMPTY_SET;
Set<Object> union = new HashSet<Object>((a.size() < b.size()) ? b : a);
Set<?> src = (a.size() < b.size()) ? b : a;
for (Object o : src) {
if (!union.contains(o))
union.add(o);
return union;
String[]
union(String[] set1, String[] set2) Same as union, but for Strings.
String[] set = new String[set1.length + set2.length];
System.arraycopy(set1, 0, set, 0, set1.length);
System.arraycopy(set2, 0, set, set1.length, set2.length);
return (String[]) unique(set);