List of usage examples for java.util HashSet HashSet
public HashSet(int initialCapacity)
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);/* w w w.j a v a 2 s.com*/ return set; }
From source file:Main.java
public static <T> Set<T> set(T... items) { return new HashSet<T>(Arrays.asList(items)); }
From source file:Main.java
public static Set<Object> listToHashSet(List<?> list) { return new HashSet<>(list); }
From source file:Main.java
public static boolean containSameItems(Collection c1, Collection c2) { Set s1 = (c1 instanceof Set) ? (Set) c1 : new HashSet(c1); Set s2 = (c2 instanceof Set) ? (Set) c2 : new HashSet(c2); return s1.equals(s2); }
From source file:Main.java
@SafeVarargs public static <T> Set<T> set(T... elements) { return new HashSet<T>(list(elements)); }
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);/* www . j a v a 2s .c om*/ return result; }
From source file:Main.java
public static Set toSet(Object[] someElements) { Set asSet = new HashSet(someElements.length); for (int i = 0; i < someElements.length; i++) asSet.add(someElements[i]);// w w w .j av a2s. co m return asSet; }
From source file:Main.java
public static double computeDice(Collection<String> c1, Collection<String> c2) { Set<String> intersection = new HashSet<>(c1); intersection.retainAll(c1);// w w w. java 2s .com intersection.retainAll(c2); if (intersection.size() == 0) return 0.0; double score = 2 * (double) intersection.size() / (c1.size() + c2.size()); return score; }
From source file:Main.java
public static <T> Set<T> buildSet(T... ts) { Set<T> set = new HashSet<T>(ts.length * 2); addAll(set, ts);/* w w w . j a v a2 s. co m*/ return set; }
From source file:Main.java
public static <T> boolean hasDuplicates(Collection<T> collection) { Set<T> set = new HashSet<T>(collection); return set.size() != collection.size(); }