Example usage for com.google.common.collect Sets newHashSetWithExpectedSize

List of usage examples for com.google.common.collect Sets newHashSetWithExpectedSize

Introduction

In this page you can find the example usage for com.google.common.collect Sets newHashSetWithExpectedSize.

Prototype

public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize) 

Source Link

Document

Creates a HashSet instance, with a high enough initial table size that it should hold expectedSize elements without resizing.

Usage

From source file:eu.project.ttc.engines.TermClassifier.java

@Override
public void collectionProcessComplete() throws AnalysisEngineProcessException {
    TermIndex termIndex = this.termIndexResource.getTermIndex();
    LOGGER.info("Classifying term index {} on property {}", termIndex.getName(), classifyingProperty.name());

    List<Term> terms = Lists.newArrayList(termIndex.getTerms());
    Collections.sort(terms, classifyingProperty.getComparator(termIndex, true));
    Set<Term> added = Sets.newHashSetWithExpectedSize(terms.size());

    for (Term t : terms) {
        if (added.contains(t))
            continue;
        else {//from  ww w . j a va2  s.  com
            Set<Term> classTerms = Sets.newHashSet();
            classTerms.add(t);
            for (VariationPath path : t.getVariationPaths(10)) {
                if (added.contains(path.getVariant()))
                    continue;
                else {
                    added.add(path.getVariant());
                    classTerms.add(path.getVariant());
                }
            }
            termIndex.classifyTerms(t, classTerms);

        }
    }

    LOGGER.info("Number of term classes: {} (nbTerms: {})", termIndex.getTermClasses().size(),
            termIndex.getTerms().size());
}

From source file:org.ow2.authzforce.core.pdp.api.DefaultHashCollectionFactory.java

@Override
public <E> Set<E> newUpdatableSet(final int expectedSize) {
    return Sets.newHashSetWithExpectedSize(expectedSize);
}

From source file:org.jage.platform.config.xml.ConfigUtils.java

private static Set<String> toSet(final ConfigTags[] tags) {
    final Set<String> set = Sets.newHashSetWithExpectedSize(tags.length);
    for (final ConfigTags tag : tags) {
        set.add(tag.toString());/*from  ww  w .  j  a  v  a  2  s.c o  m*/
    }
    return set;
}

From source file:org.apache.flink.runtime.io.network.partition.consumer.UnionInputGate.java

public UnionInputGate(InputGate... inputGates) {
    this.inputGates = checkNotNull(inputGates);
    checkArgument(inputGates.length > 1, "Union input gate should union at least two input gates.");

    this.inputGateToIndexOffsetMap = Maps.newHashMapWithExpectedSize(inputGates.length);
    this.inputGatesWithRemainingData = Sets.newHashSetWithExpectedSize(inputGates.length);

    int currentNumberOfInputChannels = 0;

    for (InputGate inputGate : inputGates) {
        // The offset to use for buffer or event instances received from this input gate.
        inputGateToIndexOffsetMap.put(checkNotNull(inputGate), currentNumberOfInputChannels);
        inputGatesWithRemainingData.add(inputGate);

        currentNumberOfInputChannels += inputGate.getNumberOfInputChannels();

        // Register the union gate as a listener for all input gates
        inputGate.registerListener(this);
    }// w  w w  .  j  a v a 2 s  .co  m

    this.totalNumberOfInputChannels = currentNumberOfInputChannels;
}

From source file:com.technophobia.substeps.report.ExecutionStats.java

private Set<TestCounterSet> getAllStatsForTags(Set<String> tags) {

    Set<TestCounterSet> testStats = Sets.newHashSetWithExpectedSize(tags.size() + 1);
    testStats.add(totals);/*ww  w. jav  a  2  s  . c o  m*/
    for (String tag : tags) {
        testStats.add(getOrCreateStatsForTag(tag));
    }
    return testStats;
}

From source file:com.google.javascript.jscomp.NameBasedDefinitionProvider.java

public NameBasedDefinitionProvider(AbstractCompiler compiler, boolean allowComplexFunctionDefs) {
    this.compiler = compiler;
    this.allowComplexFunctionDefs = allowComplexFunctionDefs;
    int numInputs = compiler.getNumberOfInputs();
    // Estimates below were generated by experimentation with large Google projects.
    this.definitionsByName = LinkedHashMultimap.create(numInputs * 15, 1);
    int estimatedDefinitionSites = numInputs * 22;
    this.definitionSitesByDefinitionSiteNode = Maps.newLinkedHashMapWithExpectedSize(estimatedDefinitionSites);
    this.definitionSitesByScopeNode = HashMultimap.create(estimatedDefinitionSites, 1);
    this.definitionNodes = Sets.newHashSetWithExpectedSize(estimatedDefinitionSites);
}

From source file:org.spongepowered.common.data.builder.manipulator.mutable.item.PlaceableDataBuilder.java

@Override
public Optional<PlaceableData> build(DataView container) throws InvalidDataException {
    if (container.contains(Keys.PLACEABLE_BLOCKS.getQuery())) {
        List<String> blockIds = container.getStringList(Keys.PLACEABLE_BLOCKS.getQuery()).get();
        Set<BlockType> blockTypes = Sets.newHashSetWithExpectedSize(blockIds.size());
        for (String blockId : blockIds) {
            blockTypes.add(Sponge.getGame().getRegistry().getType(BlockType.class, blockId).get());
        }/*from w w  w  .jav  a 2  s .co m*/
        return Optional.of(new SpongePlaceableData(blockTypes));
    }
    return Optional.empty();
}

From source file:org.spongepowered.common.data.builder.manipulator.mutable.item.BreakableDataBuilder.java

@Override
public Optional<BreakableData> build(DataView container) throws InvalidDataException {
    if (container.contains(Keys.BREAKABLE_BLOCK_TYPES.getQuery())) {
        List<String> blockIds = container.getStringList(Keys.BREAKABLE_BLOCK_TYPES.getQuery()).get();
        Set<BlockType> blockTypes = Sets.newHashSetWithExpectedSize(blockIds.size());
        for (String blockId : blockIds) {
            blockTypes.add(Sponge.getGame().getRegistry().getType(BlockType.class, blockId).get());
        }/*w  w  w. j av  a  2 s . com*/
        return Optional.of(new SpongeBreakableData(blockTypes));
    }
    return Optional.empty();
}

From source file:net.automatalib.util.automata.cover.IncrementalTransitionCoverIterator.java

private void initialize() {

    final S init = automaton.getInitialState();
    final Record<S, I> initRec = new Record<>(init, Word.epsilon(),
            Sets.newHashSetWithExpectedSize(inputs.size()));
    reach.put(init, initRec);//from  w  w  w.ja v a 2  s.c  om
    bfsQueue.add(initRec);

    Covers.buildReachFromTransitionCover(reach, bfsQueue, automaton, oldCover,
            (s, as) -> new Record<>(s, as, Sets.newHashSetWithExpectedSize(inputs.size())), (w) -> {
            });
}

From source file:com.android.build.gradle.internal.dsl.NdkOptions.java

@NonNull
public NdkOptions setAbiFilters(Collection<String> filters) {
    if (filters != null) {
        if (abiFilters == null) {
            abiFilters = Sets.newHashSetWithExpectedSize(filters.size());
        } else {//  ww w.  ja  v  a 2 s  .c  o  m
            abiFilters.clear();
        }
        for (String filter : filters) {
            abiFilters.add(filter);
        }
    } else {
        abiFilters = null;
    }
    return this;
}