List of usage examples for com.google.common.collect Sets newHashSetWithExpectedSize
public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize)
From source file:co.cask.cdap.data2.registry.internal.pair.OrderedPair.java
public Set<SECOND> getSecond(Set<MDSKey> mdsKeys) { Set<SECOND> secondSet = Sets.newHashSetWithExpectedSize(mdsKeys.size()); for (MDSKey mdsKey : mdsKeys) { MDSKey.Splitter splitter = mdsKey.split(); splitter.skipString(); // prefix keyMaker1.skipKey(splitter);/*from w ww.j av a 2 s . c o m*/ secondSet.add(this.keyMaker2.getElement(splitter)); } return secondSet; }
From source file:com.vmware.appfactory.taskqueue.tasks.state.builder.TafBuilder.java
protected TafBuilder(Class<? extends API> resultClass) { this.resultClass = resultClass; this.resultClassGetters = BeanMaps.newBeanGetters(resultClass); this.resultClassSetters = BeanMaps.newBeanSetters(resultClass); this.changeEvents = Sets.newHashSetWithExpectedSize(resultClassGetters.size()); }
From source file:org.elasticsearch.indices.recovery.RecoveryCleanFilesRequest.java
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); recoveryId = in.readLong();//from w w w . ja v a 2 s .c o m shardId = ShardId.readShardId(in); int size = in.readVInt(); snapshotFiles = Sets.newHashSetWithExpectedSize(size); for (int i = 0; i < size; i++) { snapshotFiles.add(in.readString()); } }
From source file:com.android.tools.idea.editors.strings.StringsWriteUtils.java
/** * Sets the value of an attribute for resource items. If SdkConstants.ATTR_NAME is set to null or "", the items are deleted. * * @param attribute The attribute whose value we wish to change * @param value The desired attribute value * @param items The resource items/*from w w w. j av a 2s . c o m*/ * @return True if the value was successfully set, false otherwise */ public static boolean setAttributeForItems(@NotNull Project project, @NotNull final String attribute, @Nullable final String value, @NotNull List<ResourceItem> items) { if (items.isEmpty()) { return false; } final List<XmlTag> tags = Lists.newArrayListWithExpectedSize(items.size()); final Set<PsiFile> files = Sets.newHashSetWithExpectedSize(items.size()); for (ResourceItem item : items) { XmlTag tag = LocalResourceRepository.getItemTag(project, item); if (tag == null) { return false; } tags.add(tag); files.add(tag.getContainingFile()); } final boolean deleteTag = attribute.equals(SdkConstants.ATTR_NAME) && (value == null || value.isEmpty()); new WriteCommandAction.Simple(project, "Setting attribute " + attribute, files.toArray(new PsiFile[files.size()])) { @Override public void run() { for (XmlTag tag : tags) { if (deleteTag) { tag.delete(); } else { // XmlTagImpl handles a null value by deleting the attribute, which is our desired behavior //noinspection ConstantConditions tag.setAttribute(attribute, value); } } } }.execute(); return true; }
From source file:org.gradoop.flink.model.impl.functions.epgm.GraphVerticesEdges.java
private Set<Edge> getEmptyEdgeSet() { return Sets.newHashSetWithExpectedSize(0); }
From source file:org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.AbstractCompositeExclusion.java
@Override protected boolean doExcludesSameModulesAs(AbstractModuleExclusion other) { AbstractCompositeExclusion spec = (AbstractCompositeExclusion) other; Collection<AbstractModuleExclusion> thisFilters = getFilters(); Collection<AbstractModuleExclusion> otherFilters = spec.getFilters(); // To make the comparison faster, we compute the sets of specs that exist in this exclusion, but not in the other // and the set of specs that exist in the other and not in this one. Then we only need to check if the missing // from one set have an equivalent in the missing of the other set, which is much faster than checking all of them Set<AbstractModuleExclusion> miss1 = Sets.newHashSetWithExpectedSize(thisFilters.size()); Set<AbstractModuleExclusion> miss2 = Sets.newHashSetWithExpectedSize(otherFilters.size()); for (AbstractModuleExclusion exclusion : thisFilters) { if (!otherFilters.contains(exclusion)) { miss1.add(exclusion);// w ww. ja va2 s .co m } } for (AbstractModuleExclusion otherFilter : otherFilters) { if (!thisFilters.contains(otherFilter)) { miss2.add(otherFilter); } } return (miss1.isEmpty() && miss2.isEmpty()) || (implies(miss1, miss2) && implies(miss2, miss1)); }
From source file:com.android.build.gradle.internal.dsl.Splits.java
/** * Returns the list of Density filters used for multi-apk. * * null value is allowed, indicating the need to generate an apk with all densities. * * @return a set of filters./*from w ww.ja v a 2 s . c o m*/ */ @NonNull public Set<String> getDensityFilters() { Density[] values = Density.values(); Set<String> fullList = Sets.newHashSetWithExpectedSize(values.length - 1); for (Density value : values) { if (value != Density.NODPI) { fullList.add(value.getResourceValue()); } } return density.getApplicableFilters(fullList); }
From source file:org.sonatype.nexus.orient.entity.FieldCopier.java
@SuppressWarnings("unchecked") public static Set copy(final Set<?> source) { Set target = Sets.newHashSetWithExpectedSize(source.size()); for (Object value : source) { value = maybeCopy(value);//from w ww. ja v a 2s .c o m target.add(value); } return target; }
From source file:org.spongepowered.common.data.processor.common.BreakablePlaceableUtils.java
public static Optional<Set<BlockType>> get(ItemStack stack, String nbtKey) { NBTTagCompound tag = stack.getTagCompound(); if (tag == null) { return Optional.empty(); }//ww w . j a v a2 s .c om NBTTagList blockIds = tag.getTagList(nbtKey, NbtDataUtil.TAG_STRING); if (blockIds.hasNoTags()) { return Optional.empty(); } Set<BlockType> blockTypes = Sets.newHashSetWithExpectedSize(blockIds.tagCount()); for (int i = 0; i < blockIds.tagCount(); i++) { Optional<BlockType> blockType = SpongeImpl.getGame().getRegistry().getType(BlockType.class, blockIds.getStringTagAt(i)); if (blockType.isPresent()) { blockTypes.add(blockType.get()); } } return Optional.of(blockTypes); }
From source file:com.opengamma.engine.function.MarketDataAliasingFunction.java
@Override public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) { final Collection<ComputedValue> values = inputs.getAllValues(); final Object value = values.isEmpty() ? MissingInput.MISSING_MARKET_DATA : Iterables.getOnlyElement(values).getValue(); final Set<ComputedValue> result = Sets.newHashSetWithExpectedSize(desiredValues.size()); for (ValueRequirement desiredValueReq : desiredValues) { final ValueSpecification desiredValue = new ValueSpecification(desiredValueReq.getValueName(), target.toSpecification(), desiredValueReq.getConstraints()); result.add(new ComputedValue(desiredValue, value)); }/*from w w w .j a v a 2s.c o m*/ return result; }