List of usage examples for java.util LinkedHashSet LinkedHashSet
public LinkedHashSet(Collection<? extends E> c)
From source file:Main.java
public static void assertAllDifferent(List<?> entities) { Set<?> set = new LinkedHashSet<>(entities); if (set.size() != entities.size()) { throw new IllegalArgumentException("All entities must be different: " + entities + ", " + set); }/* w w w. ja v a 2 s . c o m*/ }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> Collection<T> unique(Collection<T> c, Collection<T> result) { if (c == null) { return result; }/* w w w . j a v a 2s . co m*/ Set<T> s = new LinkedHashSet<T>(c); result.addAll(s); return result; }
From source file:Main.java
public static <E> LinkedHashSet<E> newLinkedHashSet(E... elements) { if (elements == null) { throw new NullPointerException(); }// w w w . j av a2 s .c om return new LinkedHashSet<E>(Arrays.asList(elements)); }
From source file:Main.java
/** * it returns an ordered Set implementation with the specified initial capacity * /*from w w w . jav a 2 s .com*/ * @return */ public static <T> Set<T> newOrderedSet(int initialCapacity) { return new LinkedHashSet<>(initialCapacity); }
From source file:Main.java
public static <T> Set<T> copyToLinkedHashSet(Collection<? extends T> src) { if (src.isEmpty()) { return Collections.emptySet(); }//from w w w. j ava 2 s. c o m return Collections.unmodifiableSet(new LinkedHashSet<T>(src)); }
From source file:Main.java
/** * Get a new {@link LinkedHashSet} with the elements * @param elements T//from w ww . j av a 2s. c o m * @param <T> * @return Set */ @SuppressWarnings("unchecked") public static <T> Set<T> linkSet(final T... elements) { return new LinkedHashSet<T>(Arrays.asList(elements)); }
From source file:Main.java
public static <E> Set<E> removeDups(Collection<E> c) { return new LinkedHashSet<E>(c); }
From source file:Main.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static <T> List<T> distinceList(List<T> l) { return new ArrayList(new LinkedHashSet(l)); }
From source file:Main.java
public static final <E> List<E> flatten(Collection<?>... collections) { List<E> resultList = new ArrayList<>(); for (Collection<?> collection : collections) { resultList.addAll((Collection<? extends E>) collection); }/* ww w . java2s . c o m*/ return new ArrayList<>(new LinkedHashSet<>(resultList)); }
From source file:Main.java
public static <T> LinkedHashSet<T> createLinkedHashSet(Iterable<? extends T> c) { LinkedHashSet<T> set;//from ww w .j a v a 2 s.c o m if ((c instanceof Collection)) { set = new LinkedHashSet((Collection) c); } else { set = new LinkedHashSet(); iterableToCollection(c, set); } return set; }