Example usage for com.google.common.collect Lists newArrayListWithCapacity

List of usage examples for com.google.common.collect Lists newArrayListWithCapacity

Introduction

In this page you can find the example usage for com.google.common.collect Lists newArrayListWithCapacity.

Prototype

@GwtCompatible(serializable = true)
public static <E> ArrayList<E> newArrayListWithCapacity(int initialArraySize) 

Source Link

Document

Creates an ArrayList instance backed by an array with the specified initial size; simply delegates to ArrayList#ArrayList(int) .

Usage

From source file:org.terasology.entitySystem.metadata.AbstractTypeHandler.java

public List<T> deserializeList(EntityData.Value value) {
    List<T> result = Lists.newArrayListWithCapacity(value.getValueCount());
    for (EntityData.Value item : value.getValueList()) {
        result.add(deserialize(item));/*from  www .  j ava  2s . c  o  m*/
    }
    return result;
}

From source file:co.cask.cdap.common.collect.FirstNCollector.java

public FirstNCollector(int n) {
    Preconditions.checkArgument(n > 0, "n must be greater than 0");
    this.maxCount = n;
    this.elements = Lists.newArrayListWithCapacity(n);
}

From source file:de.weltraumschaf.registermachine.vm.VariablePool.java

/**
 * Dedicated constructor.// w ww  .ja  v  a 2s.  c  o  m
 *
 * @param size initial capacity
 */
public VariablePool(final int size) {
    super();
    values = Lists.newArrayListWithCapacity(size);
}

From source file:org.atlasapi.persistence.system.AToZUriSource.java

private List<String> build() {
    List<String> modifiableUris = Lists.newArrayListWithCapacity(27);
    for (char c = 'z'; c >= 'a'; c--) {
        modifiableUris.add(prefix + c + suffix);
    }/*from w  w  w  .j a  va 2  s  .co  m*/
    if (includeZeroDashNine) {
        modifiableUris.add(prefix + "0-9" + suffix);
    }
    return Collections.unmodifiableList(modifiableUris);
}

From source file:org.apache.tez.mapreduce.grouper.GroupedSplitContainer.java

public GroupedSplitContainer(int numSplits, String wrappedInputFormatName, String[] locations, String rack) {
    this.wrappedSplits = Lists.newArrayListWithCapacity(numSplits);
    this.wrappedInputFormatName = wrappedInputFormatName;
    this.locations = locations;
    this.rack = rack;
}

From source file:com.netflix.atlas.client.util.ValidCharacters.java

/**
 * Create a new list of metrics where all metrics are using the valid character set.
 *///from ww  w  .  j  a  v a 2 s  .  c o  m
public static List<Metric> toValidValues(List<Metric> metrics) {
    List<Metric> fixedMetrics = Lists.newArrayListWithCapacity(metrics.size());
    for (Metric m : metrics) {
        fixedMetrics.add(toValidValue(m));
    }
    return fixedMetrics;
}

From source file:org.carrot2.clustering.stc.ClusterCandidate.java

ClusterCandidate(int[] phraseIndices, BitSet documents, int cardinality, float score) {
    assert documents.cardinality() == cardinality;

    phrases = Lists.newArrayListWithCapacity(1);
    phrases.add(phraseIndices);/* w  w w  . j a  v a2s  .co m*/

    this.documents = documents;
    this.score = score;
    this.cardinality = cardinality;
}

From source file:com.android.tools.idea.ui.properties.expressions.list.MapExpression.java

@NotNull
@Override/*w  w  w  .  j  ava2  s.  c o m*/
public final List<? extends D> get() {
    List<D> mappedList = Lists.newArrayListWithCapacity(mySourceList.size());
    for (S srcElement : mySourceList) {
        mappedList.add(transform(srcElement));
    }
    return mappedList;
}

From source file:com.opengamma.web.analytics.formatting.CurrencyPairsFormatter.java

private Map<String, Object> formatExpanded(CurrencyPairs currencyPairs) {
    Set<CurrencyPair> pairs = currencyPairs.getPairs();
    List<String> pairNames = Lists.newArrayListWithCapacity(pairs.size());
    for (CurrencyPair pair : pairs) {
        pairNames.add(pair.getName());/*from  w w  w. j ava2  s  . c  o m*/
    }
    Collections.sort(pairNames);
    return ImmutableMap.of(DATA, pairNames, LABEL, CURRENCY_PAIRS);
}

From source file:com.twitter.graphjet.algorithms.counting.moment.TopSecondDegreeByCountMomentRecsGenerator.java

private static List<RecommendationInfo> getRecommendationsFromNodes(
        TopSecondDegreeByCountRequestForMoment request, PriorityQueue<NodeInfo> topNodes) {
    List<RecommendationInfo> outputResults = Lists.newArrayListWithCapacity(topNodes.size());
    int maxNumSocialProofs = request.getMaxNumSocialProofs();

    while (!topNodes.isEmpty()) {
        NodeInfo nodeInfo = topNodes.poll();

        Map<Byte, LongList> topSocialProofs = GeneratorHelper.pickTopSocialProofs(nodeInfo.getSocialProofs(),
                maxNumSocialProofs);/*from   www. j a  v  a 2 s .c o  m*/

        MomentRecommendationInfo momentRecs = new MomentRecommendationInfo(nodeInfo.getValue(),
                nodeInfo.getWeight(), topSocialProofs);
        outputResults.add(momentRecs);
    }
    Collections.reverse(outputResults);
    return outputResults;
}