List of usage examples for com.google.common.collect Sets newHashSetWithExpectedSize
public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize)
From source file:com.arpnetworking.metrics.generator.name.NameSetGenerator.java
/** * Public constructor./*w w w. jav a2 s .c om*/ * * @param setSize Number of names in the set. * @param generator Generator used to create the name. */ public NameSetGenerator(final int setSize, final RandomGenerator generator) { final Set<String> names = Sets.newHashSetWithExpectedSize(setSize); _dataGenerator = new RandomDataGenerator(generator); while (names.size() < setSize) { names.add(_dataGenerator.nextHexString(16)); } _names = Lists.newArrayList(names); }
From source file:de.craftolution.craftoplugin4.services.storage.StorageManager.java
static Set<Storage> getAll() { Set<Storage> set = Sets.newHashSetWithExpectedSize(storageSet.size()); for (WeakReference<Storage> weakReference : storageSet) { Storage nullableStorage = weakReference.get(); if (nullableStorage != null) { set.add(nullableStorage);/*from www .ja v a 2 s. co m*/ } } return set; }
From source file:com.opengamma.engine.function.NoOpFunction.java
@Override public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) { final Set<ComputedValue> result = Sets.newHashSetWithExpectedSize(desiredValues.size()); for (ValueRequirement desiredValue : desiredValues) { result.add(new ComputedValue(new ValueSpecification(desiredValue.getValueName(), target.toSpecification(), desiredValue.getConstraints()), MissingOutput.SUPPRESSED)); }//from www.ja v a 2 s. c o m return result; }
From source file:org.terasology.logic.console.suggesters.CommandNameSuggester.java
@Override public Set<Name> suggest(EntityRef sender, Object... resolvedParameters) { Collection<ConsoleCommand> commands = console.getCommands(); Set<Name> suggestions = Sets.newHashSetWithExpectedSize(commands.size()); for (ConsoleCommand command : commands) { suggestions.add(command.getName()); }/*from ww w . j a va2s. c om*/ return suggestions; }
From source file:org.eclipse.xtext.common.types.impl.JvmAnnotationReferenceImplCustom.java
@Override public EList<JvmAnnotationValue> getValues() { EList<JvmAnnotationValue> explicitValues = getExplicitValues(); List<JvmOperation> operations = Lists.newArrayList(getAnnotation().getDeclaredOperations()); if (operations.size() <= explicitValues.size()) { return ECollections.unmodifiableEList(explicitValues); }/*from w w w.jav a 2 s .c o m*/ Set<JvmOperation> seenOperations = Sets.newHashSetWithExpectedSize(operations.size()); BasicEList<JvmAnnotationValue> result = new BasicEList<JvmAnnotationValue>(operations.size()); for (JvmAnnotationValue value : explicitValues) { seenOperations.add(value.getOperation()); result.add(value); } for (JvmOperation operation : operations) { if (seenOperations.add(operation)) { JvmAnnotationValue defaultValue = operation.getDefaultValue(); if (defaultValue != null) { result.add(defaultValue); } } } return ECollections.unmodifiableEList(result); }
From source file:com.android.build.gradle.internal.dsl.DensitySplitOptions.java
@Override protected Set<String> getDefaultValues() { Density[] values = Density.values(); Set<String> fullList = Sets.newHashSetWithExpectedSize(values.length - 2); for (Density value : values) { if (value != Density.NODPI && value != Density.ANYDPI && value.isRecommended()) { fullList.add(value.getResourceValue()); }/*from w w w . j av a 2s .c o m*/ } return fullList; }
From source file:com.creative.dao.entity.EntityTestFactory.java
public static Environment addFilesToEnvironment(Environment environment) { FileEnum[] files = FileEnum.values(); Set<File> fileSet = Sets.newHashSetWithExpectedSize(files.length); for (FileEnum fileEnum : files) { fileSet.add(createFile(fileEnum.name(), environment)); }//from w w w.j a va 2 s. c o m environment.setFileCollection(fileSet); return environment; }
From source file:org.gradle.api.internal.SetIterator.java
private SetIterator(Iterator<T> delegate) { this.delegate = delegate; if (delegate instanceof WithEstimatedSize) { seen = Sets.newHashSetWithExpectedSize(((WithEstimatedSize) delegate).estimatedSize()); } else {//from w ww . ja va 2 s. c o m seen = Sets.newHashSet(); } fetchNext(); }
From source file:net.automatalib.util.automata.conformance.WpMethodTestsIterator.java
@SuppressWarnings("unchecked") private static <I> Iterator<Word<I>>[] buildIterators(UniversalDeterministicAutomaton<?, I, ?, ?, ?> automaton, Collection<? extends I> inputs, int maxDepth) { final Set<Word<I>> stateCover = Sets.newHashSetWithExpectedSize(automaton.size()); final Set<Word<I>> transitionCover = Sets.newHashSetWithExpectedSize(automaton.size() * inputs.size()); Covers.cover(automaton, inputs, stateCover, transitionCover); final Iterable<Word<I>> characterizingSet; final Iterator<Word<I>> characterizingIter = CharacterizingSets.characterizingSetIterator(automaton, inputs);/*w w w . ja v a 2s.co m*/ // Special case: List of characterizing suffixes may be empty, // but in this case we still need to iterate over the prefixes! if (!characterizingIter.hasNext()) { characterizingSet = Collections.singletonList(Word.epsilon()); } else { characterizingSet = new ReusableIterator<>(characterizingIter); } // Phase 1: state cover * middle part * global suffixes final Iterator<Word<I>> firstIterator = new FirstPhaseIterator<>(stateCover, CollectionsUtil.allTuples(inputs, 0, maxDepth), characterizingSet); // Phase 2: transitions (not in state cover) * middle part * local suffixes transitionCover.removeAll(stateCover); final Iterator<Word<I>> secondIterator = new SecondPhaseIterator<>(automaton, inputs, transitionCover, CollectionsUtil.allTuples(inputs, 0, maxDepth)); return new Iterator[] { firstIterator, secondIterator }; }
From source file:org.gradoop.flink.algorithms.fsm.transactional.tle.functions.CategoryEdgeLabels.java
@Override public void flatMap(CCSGraph graph, Collector<CategoryCountableLabel> out) throws Exception { Set<String> edgeLabels = Sets.newHashSetWithExpectedSize(graph.getEdges().size()); for (FSMEdge edge : graph.getEdges().values()) { edgeLabels.add(edge.getLabel()); }//from w w w . j av a 2 s . c o m for (String label : edgeLabels) { reuseTuple.setCategory(graph.getCategory()); reuseTuple.setLabel(label); out.collect(reuseTuple); } }