List of usage examples for java.util LinkedHashSet LinkedHashSet
public LinkedHashSet(Collection<? extends E> c)
From source file:Main.java
/** * Creates a new {@link LinkedHashSet} with the provided elements. * * @param <E>//from www.ja va2s. c o m * the elements' type * @param elements * the elements to add to the new LinkedHashSet * @return a new LinkedHashSet with the provided elements */ public static <E> LinkedHashSet<E> newLinkedHashSet(E... elements) { return new LinkedHashSet<>(Arrays.asList(elements)); }
From source file:com.cse.Controller.PermissionHolder.java
public static int removePermissions(PermissionType... permissionArray) { permissions.remove(new LinkedHashSet<PermissionType>(Arrays.asList(permissionArray))); revokePermissions(getPermissionString(permissionArray)); return permissionArray.length;//returns number of permissions removed }
From source file:Main.java
public static <ELEMENT> LinkedHashSet<ELEMENT> newLinkedHashSetSized(int size) { return new LinkedHashSet<ELEMENT>(size); }
From source file:com.cedac.security.oauth2.provider.RequestTokenFactory.java
public static OAuth2Request createOAuth2Request(Map<String, String> requestParameters, String clientId, Collection<? extends GrantedAuthority> authorities, boolean approved, Collection<String> scope, Set<String> resourceIds, String redirectUri, Set<String> responseTypes, Map<String, Serializable> extensionProperties) { return new OAuth2Request(requestParameters, clientId, authorities, approved, scope == null ? null : new LinkedHashSet<String>(scope), resourceIds, redirectUri, responseTypes, extensionProperties);/* w ww . j a v a2 s. c om*/ }
From source file:Main.java
/** * Makes an intersection betwwen both of the given lists.<br/> * The result contains unique values.//from w ww .j a v a 2 s. com * @param list1 the first list. * @param list2 the second list. * @param <T> * @return the intersection between the two lists. */ public static <T> List<T> intersection(List<T> list1, List<T> list2) { List<T> list = new ArrayList<T>(new LinkedHashSet<T>(list1)); Iterator<T> iterator = list.iterator(); while (iterator.hasNext()) { if (!list2.contains(iterator.next())) { iterator.remove(); } } return list; }
From source file:de.mpg.imeji.logic.search.util.CollectionUtils.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public static Collection intersection(final Collection a, final Collection b) { ArrayList list = new ArrayList(); Map mapa = getCardinalityMap(a); Map mapb = getCardinalityMap(b); Set elts = new LinkedHashSet(a); elts.addAll(b);/*from w w w . ja v a 2 s. c om*/ Iterator it = elts.iterator(); while (it.hasNext()) { Object obj = it.next(); for (int i = 0, m = Math.min(getFreq(obj, mapa), getFreq(obj, mapb)); i < m; i++) { list.add(obj); } } return list; }
From source file:SetOps.java
/** * // www . ja va 2s.c om * @param <T> * @param s1 * @param s2 * @return the (asymmetric) set difference of s1 and s2. (For example, the * set difference of s1 minus s2 is the set containing all of the * elements found in s1 but not in s2.) */ public static <T> Set<T> difference(Set<T> s1, Set<T> s2) { Set<T> difference = new LinkedHashSet<T>(s1); difference.removeAll(s2); return difference; }
From source file:oauth2.authentication.tokens.RequestTokenFactory.java
public static OAuth2Request createOAuth2Request(Map<String, String> requestParameters, String clientId, Collection<? extends GrantedAuthority> authorities, boolean approved, Collection<String> scope, Set<String> resourceIds, String redirectUri, Set<String> responseTypes, Map<String, Serializable> extensionProperties) { return new OAuth2Request(requestParameters, clientId, authorities, approved, scope == null ? null : new LinkedHashSet<>(scope), resourceIds, redirectUri, responseTypes, extensionProperties);//from w w w . java 2 s . com }
From source file:fi.hsl.parkandride.ActiveProfileAppender.java
public ActiveProfileAppender(String... profilesToAppend) { this.profilesToAppend = new LinkedHashSet<>(Arrays.asList(profilesToAppend)); }
From source file:com.amazon.utils.ListUtils.java
/** * Remove duplicate items from the given list. Return the result as a new list and don't modify * the original list./*from w w w . j ava 2s .c o m*/ * * @param list List to remove duplicates from. * @param <T> Item type. * @return A new list that contains the items of the original list without any duplicates. */ public static <T> List<T> removeDuplicates(List<T> list) { return new ArrayList<>(new LinkedHashSet<>(list)); }