Example usage for java.util Set addAll

List of usage examples for java.util Set addAll

Introduction

In this page you can find the example usage for java.util Set addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

Usage

From source file:Main.java

public static <T> Set<T> union(Set<? extends T> a, Set<? extends T> b) {
    Set<T> result = new HashSet<T>(a);
    result.addAll(b);
    return result;
}

From source file:Main.java

public static void sortDates(final List<DAY> dayList) {
    final Set<DAY> set = new TreeSet<DAY>();
    set.addAll(dayList);
    for (final DAY day : set) {
        System.out.println(day);//from ww  w. j a va 2 s.  co m
    }
}

From source file:Main.java

/**
 * @param <T>//from   w w w . ja  v  a 2 s . c o  m
 * @param list
 * @return list
 */
public static <T> Set<T> list2Set(List<T> list) {
    Set<T> set = new HashSet<T>();
    set.addAll(list);
    return set;
}

From source file:Main.java

public static <E> Set<E> union(Set<? extends E> x, Set<? extends E> y) {
    Set<E> union = new HashSet<E>();
    union.addAll(x);
    union.addAll(y);//  w w w . j av a2  s  .co  m
    return union;
}

From source file:Main.java

public static <E> Set<E> union(final Set<E> set1, final Set<E> set2) {
    Set<E> set = new HashSet<>(set1);
    set.addAll(set2);
    return Collections.unmodifiableSet(set);
}

From source file:Main.java

public static <T> ArrayList<T> union(Collection<T> l1, Collection<T> l2) {
    Set<T> s = new HashSet<>();
    s.addAll(l1);
    s.addAll(l2);/*from w  ww.j a va  2 s.c  o  m*/
    return new ArrayList<>(s);
}

From source file:Main.java

public static <T> Set<T> createWeakSet(Iterable<T> items) {
    Set<T> set = createWeakSet();
    set.addAll(Sets.newHashSet(items));
    return set;/*from w w  w .j  a  v a  2  s. c o m*/
}

From source file:Main.java

public static <T> Set<T> union(Set<T> x, Set<T> y) {

    Set<T> result = newEmptySet();

    result.addAll(x);
    result.addAll(y);//  ww  w  .j  a v  a2s  .com
    return result;
}

From source file:Main.java

public static <T> Set<T> asSet(T... elements) {
    Set<T> toReturn = new HashSet<>();
    toReturn.addAll(Arrays.asList(elements));
    return toReturn;
}

From source file:Main.java

public static <T> List<T> union(List<T> list1, List<T> list2) {
    Set<T> set = new HashSet<T>();

    set.addAll(list1);
    set.addAll(list2);/*from  ww w . j  a  v a  2  s.  c om*/

    return new ArrayList<T>(set);
}