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

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

Introduction

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

Prototype

@GwtCompatible(serializable = true)
public static <E> ArrayList<E> newArrayListWithExpectedSize(int estimatedSize) 

Source Link

Document

Creates an ArrayList instance to hold estimatedSize elements, plus an unspecified amount of padding; you almost certainly mean to call #newArrayListWithCapacity (see that method for further advice on usage).

Usage

From source file:org.eclipse.viatra.query.patternlanguage.emf.scoping.EMFPatternLanguageImportNamespaceProvider.java

@Override
protected List<ImportNormalizer> getImportedNamespaceResolvers(XImportSection importSection,
        boolean ignoreCase) {
    List<ImportNormalizer> parentNormalizers = super.getImportedNamespaceResolvers(importSection, ignoreCase);
    List<PatternImport> patternImportDeclarations;
    if (importSection instanceof VQLImportSection) {
        patternImportDeclarations = ((VQLImportSection) importSection).getPatternImport();
    } else {// ww w  . j av a2s .c  o  m
        patternImportDeclarations = Lists.newArrayList();
    }
    List<ImportNormalizer> result = Lists
            .newArrayListWithExpectedSize(patternImportDeclarations.size() + parentNormalizers.size());
    for (PatternImport imp : patternImportDeclarations) {
        ImportNormalizer resolver = createImportedNamespaceResolver(
                PatternLanguageHelper.getFullyQualifiedName(imp.getPattern()), ignoreCase);
        if (resolver != null) {
            result.add(resolver);
        }
    }
    result.addAll(parentNormalizers);
    return result;
}

From source file:com.google.devtools.depan.collapse.model.CollapseData.java

/**
 * Provide a copy of the children nodes with full {@link CollapseData},
 * even for nodes without children.  It is safe to manipulate the result.
 * //ww  w  .j  a  v a2s. co  m
 * @return a new {@link Collection} of {@link CollapseData}.
 */
public static Collection<CollapseData> buildChildrenData(CollapseData data) {

    if (null == data) {
        return CollapseData.EMPTY_LIST;
    }

    Collection<GraphNode> childrenNodes = data.getChildrenNodes();
    int size = childrenNodes.size();
    Collection<CollapseData> result = Lists.newArrayListWithExpectedSize(size);
    for (GraphNode node : childrenNodes) {
        result.add(loadCollapseData(data, node));
    }

    return result;
}

From source file:com.android.builder.profile.ProcessRecorderFactory.java

public static void publishInitialRecords(@NonNull List<Recorder.Property> properties) {

    List<Recorder.Property> propertyList = Lists.newArrayListWithExpectedSize(6 + properties.size());

    propertyList.add(new Recorder.Property("build_id", UUID.randomUUID().toString()));
    propertyList.add(new Recorder.Property("os_name", System.getProperty("os.name")));
    propertyList.add(new Recorder.Property("os_version", System.getProperty("os.version")));
    propertyList.add(new Recorder.Property("java_version", System.getProperty("java.version")));
    propertyList.add(new Recorder.Property("java_vm_version", System.getProperty("java.vm.version")));
    propertyList.add(new Recorder.Property("max_memory", Long.toString(Runtime.getRuntime().maxMemory())));
    propertyList.addAll(properties);//  w  w  w.  ja v  a2s  .  c  o m

    ThreadRecorder.get().record(ExecutionType.INITIAL_METADATA, Recorder.EmptyBlock, propertyList);
}

From source file:com.cloudera.exhibit.hive.WithinUDF.java

private Object getResult(Obs obs) {
    if (obs.descriptor().size() == 1) {
        return HiveUtils.asHiveType(obs.get(0));
    } else {/*from   www.  ja v a  2 s. c o  m*/
        List<Object> values = Lists.newArrayListWithExpectedSize(obs.descriptor().size());
        for (int i = 0; i < obs.descriptor().size(); i++) {
            values.add(HiveUtils.asHiveType(obs.get(i)));
        }
        return values;
    }
}

From source file:com.yahoo.yqlplus.engine.internal.source.IndexedMethod.java

protected OperatorNode<PhysicalExprOperator> createInvocation(Location location,
        OperatorNode<PhysicalExprOperator> source, ContextPlanner planner,
        OperatorNode<PhysicalExprOperator> key, List<OperatorNode<PhysicalExprOperator>> moreArguments) {
    List<OperatorNode<PhysicalExprOperator>> callArgs = Lists.newArrayListWithExpectedSize(2);
    callArgs.add(source);//from w  w w  .j  a  v a 2 s.  c  o  m
    callArgs.add(OperatorNode.create(PhysicalExprOperator.CURRENT_CONTEXT));
    if (indexDescriptor != null) {
        callArgs.add(key);
    }
    callArgs.addAll(moreArguments);
    OperatorNode<PhysicalExprOperator> invocation = OperatorNode.create(location,
            invoker.getReturnType().isPromise() ? PhysicalExprOperator.ASYNC_INVOKE
                    : PhysicalExprOperator.INVOKE,
            invoker, callArgs);
    if (minimumBudget > 0 || maximumBudget > 0) {
        OperatorNode<PhysicalExprOperator> ms = planner.constant(TimeUnit.MILLISECONDS);
        OperatorNode<PhysicalExprOperator> subContext = OperatorNode.create(PhysicalExprOperator.TIMEOUT_GUARD,
                planner.constant(minimumBudget), ms, planner.constant(maximumBudget), ms);
        return OperatorNode.create(PhysicalExprOperator.WITH_CONTEXT, subContext,
                OperatorNode.create(PhysicalExprOperator.ENFORCE_TIMEOUT, invocation));
    }
    return invocation;
}

From source file:org.apache.phoenix.hive.mapreduce.PhoenixResultWritable.java

public PhoenixResultWritable(Configuration config, List<ColumnInfo> columnMetadataList) throws IOException {
    this(config);
    this.columnMetadataList = columnMetadataList;
    valueList = Lists.newArrayListWithExpectedSize(columnMetadataList.size());
}

From source file:org.apache.phoenix.hive.objectinspector.PhoenixListObjectInspector.java

@Override
public List<?> getList(Object data) {
    if (data == null) {
        return null;
    }//from w  ww . j  a  v a2  s  . c  om

    PhoenixArray array = (PhoenixArray) data;
    int valueLength = array.getDimensions();
    List<Object> valueList = Lists.newArrayListWithExpectedSize(valueLength);

    for (int i = 0; i < valueLength; i++) {
        valueList.add(array.getElement(i));
    }

    return valueList;
}

From source file:com.android.tools.idea.gradle.project.build.invoker.messages.GradleBuildTreeStructure.java

@Override
public ErrorTreeElement[] getChildElements(Object element) {
    if (element instanceof ErrorTreeElement && element.getClass().getName().contains("MyRootElement")) {
        List<ErrorTreeElement> messages = Lists.newArrayListWithExpectedSize(myMessages.size());
        for (ErrorTreeElement message : myMessages) {
            if (canShow(message)) {
                messages.add(message);/*from  ww w . j  a v a2s  . c  o  m*/
            }
        }
        return messages.toArray(new ErrorTreeElement[messages.size()]);
    }
    if (element instanceof GroupingElement) {
        List<NavigatableMessageElement> children = myGroupNameToMessagesMap
                .get(((GroupingElement) element).getName());
        List<ErrorTreeElement> messages = Lists.newArrayListWithExpectedSize(children.size());
        for (NavigatableMessageElement message : children) {
            if (canShow(message)) {
                messages.add(message);
            }
        }
        return messages.toArray(new ErrorTreeElement[messages.size()]);
    }
    return ErrorTreeElement.EMPTY_ARRAY;
}

From source file:com.carmatech.maven.model.ParallelMerger.java

private List<Future<PropertiesConfiguration>> parallelToProperties(final List<File> sourceFiles) {
    final List<Future<PropertiesConfiguration>> futures = Lists
            .newArrayListWithExpectedSize(sourceFiles.size());
    for (final File sourceFile : sourceFiles) {
        futures.add(threadPool.submit(new Callable<PropertiesConfiguration>() {
            @Override/*from   ww w  .j av  a2 s .c  o m*/
            public PropertiesConfiguration call() throws Exception {
                return toProperties(sourceFile);
            }
        }));
    }
    return futures;
}

From source file:com.android.tools.idea.ui.properties.AbstractProperty.java

public final void addConstraint(@NotNull Constraint<T> constraint) {
    if (myConstraints == null) {
        myConstraints = Lists.newArrayListWithExpectedSize(1);
    }/*from w ww.  j a v  a  2  s.c om*/
    myConstraints.add(constraint);
    set(get()); // Refresh value, may be constrained now
}