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.elasticsearch.indices.recovery.RecoveryResponse.java

@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    int size = in.readVInt();
    phase1FileNames = Lists.newArrayListWithCapacity(size);
    for (int i = 0; i < size; i++) {
        phase1FileNames.add(in.readString());
    }//from   ww w . ja  va 2 s .  com
    size = in.readVInt();
    phase1FileSizes = Lists.newArrayListWithCapacity(size);
    for (int i = 0; i < size; i++) {
        phase1FileSizes.add(in.readVLong());
    }

    size = in.readVInt();
    phase1ExistingFileNames = Lists.newArrayListWithCapacity(size);
    for (int i = 0; i < size; i++) {
        phase1ExistingFileNames.add(in.readString());
    }
    size = in.readVInt();
    phase1ExistingFileSizes = Lists.newArrayListWithCapacity(size);
    for (int i = 0; i < size; i++) {
        phase1ExistingFileSizes.add(in.readVLong());
    }

    phase1TotalSize = in.readVLong();
    phase1ExistingTotalSize = in.readVLong();
    phase1Time = in.readVLong();
    phase1ThrottlingWaitTime = in.readVLong();
    startTime = in.readVLong();
    phase2Operations = in.readVInt();
    phase2Time = in.readVLong();
    phase3Operations = in.readVInt();
    phase3Time = in.readVLong();
}

From source file:com.cinchapi.common.process.Processes.java

/**
 * Create a {@link ProcessBuilder} that, on the appropriate platforms,
 * sources the standard interactive profile for the user (i.e.
 * ~/.bash_profile) and supports the use of the pipe (|) redirection on
 * platforms that allow it./*from w  w w.  j a v  a  2  s  .c  om*/
 * 
 * @param commands a string array containing the program and its arguments
 * @return a {@link ProcessBuilder}
 */
public static ProcessBuilder getBuilderWithPipeSupport(String... commands) {
    if (!Platform.isWindows()) {
        List<String> listCommands = Lists.newArrayListWithCapacity(commands.length + 2);
        // Need to invoke a shell in which the commands can be run. That
        // shell will properly interpret the pipe(|).
        listCommands.add("/bin/sh");
        listCommands.add("-c");
        for (String command : commands) {
            listCommands.add(command);
        }
        return getBuilder(listCommands.toArray(commands));
    } else {
        return getBuilder(commands);
    }
}

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

private Map<String, Object> formatExpanded(MultipleCurrencyAmount value, ValueSpecification valueSpec) {
    Map<String, Object> resultsMap = Maps.newHashMap();
    CurrencyAmount[] currencyAmounts = value.getCurrencyAmounts();
    List<List<String>> results = Lists.newArrayListWithCapacity(currencyAmounts.length);
    for (CurrencyAmount currencyAmount : currencyAmounts) {
        String formattedValue = _doubleFormatter.formatCell(currencyAmount.getAmount(), valueSpec, null);
        List<String> rowResults = ImmutableList.of(currencyAmount.getCurrency().getCode(), formattedValue);
        results.add(rowResults);/*from  ww w  .j  a  v a 2  s .c  om*/
    }
    resultsMap.put(DATA, results);
    resultsMap.put(LABELS, ImmutableList.of(CURRENCY, AMOUNT));
    return resultsMap;
}

From source file:org.gradoop.model.impl.functions.epgm.PropertyGetter.java

@Override
public List<PropertyValue> execute(EL entity) throws Exception {
    List<PropertyValue> propertyValueList = Lists.newArrayListWithCapacity(propertyKeys.size());

    for (String propertyKey : propertyKeys) {
        if (entity.hasProperty(propertyKey)) {
            propertyValueList.add(entity.getPropertyValue(propertyKey));
        } else {//from  ww w .j  a va 2 s. c  om
            propertyValueList.add(PropertyValue.NULL_VALUE);
        }
    }
    return propertyValueList;
}

From source file:org.terasology.entitySystem.metadata.core.ByteTypeHandler.java

public List<Byte> deserializeList(EntityData.Value value) {
    if (value.hasBytes()) {
        List<Byte> result = Lists.newArrayListWithCapacity(value.getBytes().size());
        for (byte b : value.getBytes().toByteArray()) {
            result.add(b);/*from ww  w.ja  v  a  2 s .  c o  m*/
        }
        return result;
    }
    return null;
}

From source file:org.terasology.entitySystem.metadata.extension.BlockFamilyTypeHandler.java

public List<BlockFamily> deserializeList(EntityData.Value value) {
    List<BlockFamily> result = Lists.newArrayListWithCapacity(value.getStringCount());
    for (String item : value.getStringList()) {
        result.add(BlockManager.getInstance().getBlockFamily(item));
    }//  ww  w . j a v  a2 s.c  o  m
    return result;
}

From source file:com.github.explainable.benchmark.preparedstmt.SqlExecTemplate.java

SqlExec next(RandomSampler sampler) {
    List<Term> args = Lists.newArrayListWithCapacity(argValues.size());
    for (List<Term> candidates : argValues) {
        args.add(sampler.choice(candidates));
    }/*from   w ww .jav a  2  s  . com*/

    return SqlExec.create(statementName, args);
}

From source file:org.apache.impala.analysis.FunctionArgs.java

@Override
public void analyze(Analyzer analyzer) throws AnalysisException {
    ArrayList<Type> argTypes = Lists.newArrayListWithCapacity(argTypeDefs_.size());
    for (TypeDef typeDef : argTypeDefs_) {
        typeDef.analyze(analyzer);/*w w w  .j ava2  s . c o  m*/
        argTypes.add(typeDef.getType());
    }
    argTypes_ = argTypes;
}

From source file:net.myrrix.online.som.Node.java

void addAssignedID(Pair<Double, Long> assignedID) {
    if (assignedIDs == null) {
        assignedIDs = Lists.newArrayListWithCapacity(1);
    }
    assignedIDs.add(assignedID);
}

From source file:org.apache.giraph.utils.PairList.java

/**
 * Initialize the inner state, with a known size. Must be called before
 * {@code add()} is called.//from ww  w. ja va 2 s.  c o m
 *
 * @param size Number of pairs which will be added to the list
 */
public void initialize(int size) {
    firstList = Lists.newArrayListWithCapacity(size);
    secondList = Lists.newArrayListWithCapacity(size);
}