List of usage examples for java.util Set addAll
boolean addAll(Collection<? extends E> c);
From source file:Main.java
public static <T> Set<T> union(Set<T> setA, Set<T> setB) { Set<T> tmp = new TreeSet<T>(setA); tmp.addAll(setB); return tmp;/*from w w w .j a va2s .c om*/ }
From source file:Main.java
/** * Returns union of two collections.//www . j av a2 s .com * * @param <T> the generic type * @param coll1 the coll1 * @param coll2 the coll2 * @return the collection */ public static <T> Collection<T> union(Collection<T> coll1, Collection<T> coll2) { Set<T> union = new HashSet<T>(coll1); union.addAll(new HashSet<T>(coll2)); return union; }
From source file:Main.java
public static <T> Set<T> getSortedIntersectionValues(Collection<T> colection1, Collection<T> colection2) { Set<T> set = new TreeSet<>(); set.addAll(getIntersectionValues(colection1, colection2)); return set;/* w ww . j a v a 2s . c o m*/ }
From source file:Main.java
public static <T> Collection<T> union(Collection<T> col1, Collection<T> col2) { Set<T> set = new HashSet<T>(clone(col1)); set.addAll(col2); return set;/*from w ww.j a v a 2s .c o m*/ }
From source file:Main.java
/** * create set from array//from ww w. ja v a2s.c om * * @param <T> * @param values * @return array values in list */ public static <T> Set<T> toSet(T... values) { Set<T> list = new LinkedHashSet<T>(); list.addAll(Arrays.asList(values)); return list; }
From source file:Main.java
public static <T> Set<T> union(Collection<? extends T> c1, Collection<? extends T> c2) { Set<T> result = new HashSet<T>(); result.addAll(c1); result.addAll(c2);/*from w w w . j ava 2s . co m*/ return result; }
From source file:Main.java
public static <T> Set<T> getReunionValues(Collection<? extends T> collectionA, Collection<? extends T> collectionB) { Set<T> newSet = new HashSet<T>(collectionA); newSet.addAll(collectionB); return newSet; }
From source file:Main.java
/** * Removes the duplicates./* w w w . j a v a 2 s. c om*/ * * @param <T> * the generic type * @param items * the items * @return the list */ public static <T> List<T> removeDuplicates(List<T> items) { Set<T> set = new LinkedHashSet<T>(); set.addAll(items); return new ArrayList<T>(set); }
From source file:Main.java
public static <T> Set<T> union(Set<T> s1, Set<T> s2) { Set<T> result = new HashSet<T>(s1); result.addAll(s2); return result; }
From source file:Main.java
/** * Transformation operation for a {@link Collection} to a {@link Set}. * /*from w w w . j a va2 s .c om*/ * @param <E> * the type of the given and returned values * @param collection * the collection to transform * @return the new {@link Set}, containing all entries of the given * collection */ public static <E extends Object> Set<E> asSet(Collection<E> collection) { Set<E> hashSet = new HashSet<E>(); hashSet.addAll(collection); return hashSet; }