List of usage examples for java.util HashSet HashSet
public HashSet()
From source file:Main.java
public static <T> Set<T> toSet(Iterable<T> iterable) { Collections d;/*from w w w .j a v a 2 s. c o m*/ Set<T> temp = new HashSet<>(); iterable.forEach(temp::add); return temp; }
From source file:Main.java
public static Set toSet(String... values) { Set<Object> set = new HashSet(); for (String value : values) { set.add(value);//from w w w.j a v a 2 s . c o m } return set; }
From source file:Main.java
public static <T> Set<T> set(T... elements) { Set<T> set = new HashSet<T>(); for (T ele : elements) { set.add(ele);// w w w .ja v a2 s. c om } return set; }
From source file:Main.java
public static <E> Set<E> intersect(Set<E> a, Set<E> b) { Set<E> intersect = new HashSet<>(); for (E entryA : a) { if (b.contains(entryA)) { intersect.add(entryA);/*from ww w. j a va2 s . co m*/ } } for (E entryB : b) { if (a.contains(entryB)) { intersect.add(entryB); } } return intersect; }
From source file:Main.java
public static <T> Set<T> set(T... elements) { HashSet<T> ret = new HashSet<T>(); for (T element : elements) ret.add(element);/*from w ww .j ava 2 s . co m*/ return ret; }
From source file:Main.java
public static <T> Set<T> arrayToSet(T[] array) { Set<T> set = new HashSet<T>(); for (T t : array) set.add(t);//from w w w . j a v a 2s . c o m return set; }
From source file:Capture.java
static <T> Set<T> listToSet(List<T> list) { Set<T> set = new HashSet<T>(); set.addAll(list); return set; }
From source file:Main.java
static public <T> void unique(List<T> list) { HashSet<T> h = new HashSet<T>(); for (T i : list) { h.add(i);/*from w w w . j a va2 s . c om*/ } list.clear(); for (T i : h) { list.add(i); } }
From source file:Main.java
public static <T> Set<T> newHashSet(T... elements) { HashSet<T> set = new HashSet<T>(); for (T e : elements) { set.add(e);//from ww w . j av a2 s . co m } return set; }
From source file:Main.java
public static <T> Set<T> hashSetFromArray(final T[] objs) { final Set<T> set = new HashSet<T>(); for (final T obj : objs) { set.add(obj);/*from w ww . ja va 2 s . c om*/ } return set; }