Java Utililty Methods Set Union

List of utility methods to do Set Union

  1. HOME
  2. Java
  3. S
  4. Set Union

Description

The list of methods to do Set Union are organized into topic(s).

Method

Set union(final Iterable> elements)
union
return new HashSet<T>() {
 private static final long serialVersionUID = -3161916411604210423L;
 for (final Set<T> s : elements) {
 addAll(s);
};
...
Set union(final Set set1, final Set set2)
union
Set<E> set = new HashSet<>(set1);
set.addAll(set2);
return Collections.unmodifiableSet(set);
Set union(final Set... elements)
union
return ((elements.length == 0) ? Collections.<T>emptySet()
 : new HashSet<T>(elements.length * elements[0].size()) {
 private static final long serialVersionUID = -3161916411604210423L;
 for (final Set<T> s : elements) {
 addAll(s);
 });
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;
Set union(Set left, Set right)
union
Set<T> smaller;
Set<T> bigger;
if (left.size() > right.size()) {
 bigger = left;
 smaller = right;
} else {
 bigger = right;
 smaller = left;
...
Set union(Set setA, Set setB)
Union.
if (isEmpty(setA) && !isEmpty(setB)) {
 return Collections.unmodifiableSet(setB);
if (!isEmpty(setA) && isEmpty(setB)) {
 return Collections.unmodifiableSet(setA);
if (isEmpty(setA) && isEmpty(setB)) {
 return new LinkedHashSet<T>();
...
Set union(Set setA, Set setB)
This method finds the union of set A and set B
Set<T> union = new HashSet<T>(setA);
union.addAll(setB);
return union;
Set union(Set... sets)
Returns the union of multiple sets.
if (sets == null)
 return new HashSet<>();
Set<T> result = new HashSet<>();
for (Set<T> s : sets) {
 if (s != null)
 result.addAll(s);
return result;
...
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);


AltStyle によって変換されたページ (->オリジナル) /