List of usage examples for com.google.common.collect Sets newHashSetWithExpectedSize
public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize)
From source file:com.android.builder.internal.MergedNdkConfig.java
public void append(@NonNull NdkConfig ndkConfig) { // override/* ww w .j a v a 2 s . c o m*/ if (ndkConfig.getModuleName() != null) { moduleName = ndkConfig.getModuleName(); } if (ndkConfig.getStl() != null) { stl = ndkConfig.getStl(); } // append if (ndkConfig.getAbiFilters() != null) { if (abiFilters == null) { abiFilters = Sets.newHashSetWithExpectedSize(ndkConfig.getAbiFilters().size()); } else { abiFilters.clear(); } abiFilters.addAll(ndkConfig.getAbiFilters()); } if (cFlags == null) { cFlags = ndkConfig.getcFlags(); } else if (ndkConfig.getcFlags() != null) { cFlags = cFlags + " " + ndkConfig.getcFlags(); } if (ndkConfig.getLdLibs() != null) { if (ldLibs == null) { ldLibs = Sets.newHashSetWithExpectedSize(ndkConfig.getLdLibs().size()); } else { ldLibs.clear(); } ldLibs.addAll(ndkConfig.getLdLibs()); } }
From source file:com.opengamma.engine.depgraph.NextFunctionStep.java
protected Set<FunctionExclusionGroup> getFunctionExclusion(final GraphBuildingContext context, final CompiledFunctionDefinition function) { final Set<FunctionExclusionGroup> parentExclusion = getTask().getFunctionExclusion(); if (parentExclusion != null) { final FunctionExclusionGroup functionExclusion = context.getFunctionExclusionGroups() .getExclusionGroup(function.getFunctionDefinition()); if (functionExclusion != null) { final Set<FunctionExclusionGroup> result = Sets .newHashSetWithExpectedSize(parentExclusion.size() + 1); result.addAll(parentExclusion); result.add(functionExclusion); return result; } else {/* w w w . j av a2 s .c o m*/ return parentExclusion; } } else { final FunctionExclusionGroups groups = context.getFunctionExclusionGroups(); if (groups != null) { final FunctionExclusionGroup functionExclusion = groups .getExclusionGroup(function.getFunctionDefinition()); if (functionExclusion != null) { return Collections.singleton(functionExclusion); } else { return null; } } else { return null; } } }
From source file:gg.uhc.uhc.modules.team.prefixes.PrefixColourPredicateConverter.java
@Override public PrefixColourPredicate convert(String value) { boolean exact = false; if (value.length() > 0 && value.charAt(0) == '=') { exact = true;/*from www.j a va2 s . co m*/ value = value.substring(1); } String[] parts = value.split("\\+"); if (parts.length == 0) throw new ValueConversionException("Must supply at least 1 formatting code to filter out"); Set<ChatColor> colours = Sets.newHashSetWithExpectedSize(parts.length); for (String part : parts) { colours.add(colourConverter.convert(part)); } return new PrefixColourPredicate(exact, colours); }
From source file:org.openscience.cdk.isomorphism.UniqueAtomMatches.java
/** * Create filter for the expected number of unique matches. The number * of matches can grow if required.//w ww . j a v a 2s .c o m * * @param expectedHits expected number of unique matches */ private UniqueAtomMatches(int expectedHits) { this.unique = Sets.newHashSetWithExpectedSize(expectedHits); }
From source file:net.derquinse.bocas.jersey.server.BocasResource.java
private static Set<ByteString> setFromQuery(@Nullable List<String> keys) { if (keys == null || keys.isEmpty()) { throw notFound(); }//from w ww . j a v a 2 s. c o m Set<ByteString> set = Sets.newHashSetWithExpectedSize(keys.size()); for (String k : keys) { try { set.add(ByteString.fromHexString(k)); } catch (RuntimeException e) { } } if (set.isEmpty()) { throw notFound(); } return set; }
From source file:net.derquinse.bocas.BucketGuavaCachingBocas.java
Set<ByteString> toKeySet(Set<BucketKey> internalKeys) { final Set<ByteString> set = Sets.newHashSetWithExpectedSize(internalKeys.size()); for (BucketKey key : internalKeys) { set.add(key.getKey());/* ww w. j a va 2 s . c om*/ } return set; }
From source file:org.cordovastudio.editors.designer.model.DeletionHandler.java
/** * Creates a new {@link DeletionHandler} * * @param deleted the deleted nodes//from w ww. jav a 2s . c om * @param moved nodes that were moved (e.g. deleted, but also inserted elsewhere) * @param layout the parent layout of the deleted nodes */ public DeletionHandler(@NotNull List<RadViewComponent> deleted, @NotNull List<RadViewComponent> moved, @NotNull RadViewComponent layout) { myDeleted = deleted; myChildren = layout.getChildren(); myNodeMap = Maps.newHashMapWithExpectedSize(myChildren.size()); for (RadViewComponent view : RadViewComponent.getViewComponents(myChildren)) { String id = view.getId(); if (id != null) { myNodeMap.put(id, view); } } myDeletedIds = Sets.newHashSetWithExpectedSize(myDeleted.size()); for (RadViewComponent node : myDeleted) { String id = node.getId(); if (id != null) { myDeletedIds.add(id); } } // Any widgets that remain (e.g. typically because they were moved) should // keep their incoming dependencies for (RadViewComponent node : moved) { String id = node.getId(); if (id != null) { myDeletedIds.remove(id); } } }
From source file:org.terasology.input.MouseInput.java
private MouseInput(InputType type, int id, String name, String displayName, String... alternateStrings) { this.type = type; this.id = id; this.name = name.toUpperCase(Locale.ENGLISH); this.displayName = displayName; this.identifiers = Sets.newHashSetWithExpectedSize(alternateStrings.length + 2); this.identifiers.add(name); this.identifiers.add(toString().toUpperCase(Locale.ENGLISH)); }
From source file:com.google.gerrit.server.account.AbstractRealm.java
@Override public Set<String> getEmailAddresses(IdentifiedUser user) { Collection<ExternalId> ids = user.state().getExternalIds(); Set<String> emails = Sets.newHashSetWithExpectedSize(ids.size()); for (ExternalId ext : ids) { if (!Strings.isNullOrEmpty(ext.email())) { emails.add(ext.email());//from w ww .j a v a2 s. co m } } return emails; }
From source file:jp.tricreo.schemagenerator.infrastructure.utils.CloneUtil.java
/** * ?? {@link Collection} ???{@link Object#clone() }?? * ??????? {@link HashSet} ?/*from www . j a v a 2 s . c o m*/ * * @param <E> ?? * @param collection ??? * @return {@link HashSet} */ public static <E extends Entity<E, ?>> HashSet<E> cloneEntityHashSet(Collection<E> collection) { HashSet<E> cloneCollection = Sets.newHashSetWithExpectedSize(collection.size()); for (E element : collection) { E cloneElement = element.clone(); cloneCollection.add(cloneElement); } return cloneCollection; }