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:com.zimbra.client.ZFilterRules.java

public List<FilterRule> toJAXB() {
    List<FilterRule> list = Lists.newArrayListWithCapacity(rules.size());
    for (ZFilterRule rule : rules) {
        list.add(rule.toJAXB());//from w  w  w. java  2  s.com
    }
    return list;
}

From source file:org.gradoop.flink.model.impl.layouts.gve.GVEGraphLayoutFactory.java

@Override
public GVELayout fromDataSets(DataSet<Vertex> vertices) {
    return fromDataSets(vertices, createEdgeDataSet(Lists.newArrayListWithCapacity(0)));
}

From source file:co.cask.cdap.template.etl.common.TransformExecutor.java

public TransformExecutor(List<Transformation> transforms, List<StageMetrics> transformMetrics) {
    int numTransforms = transforms.size();
    Preconditions.checkArgument(numTransforms == transformMetrics.size());
    this.transforms = Lists.newArrayListWithCapacity(numTransforms);
    this.emitters = Lists.newArrayListWithCapacity(numTransforms);
    for (int i = 0; i < numTransforms; i++) {
        StageMetrics stageMetrics = transformMetrics.get(i);
        this.transforms.add(new TrackedTransform(transforms.get(i), stageMetrics));
        this.emitters.add(new DefaultEmitter(stageMetrics));
    }//from  www  .j  a va 2  s  . com
}

From source file:com.cloudera.fts.pig.ProjectedProtobufTupleFactory.java

public ProjectedProtobufTupleFactory(Message protoInstance, RequiredFieldList requiredFieldList) {

    List<FieldDescriptor> protoFields = protoInstance.getDescriptorForType().getFields();
    protoConv = new ProtobufToPig();

    if (requiredFieldList != null) {
        List<RequiredField> tupleFields = requiredFieldList.getFields();
        requiredFields = Lists.newArrayListWithCapacity(tupleFields.size());

        // should we handle nested projections?
        for (RequiredField f : tupleFields) {
            requiredFields.add(protoFields.get(f.getIndex()));
        }//from   w  w w  . jav  a2  s.co m
    } else {
        requiredFields = protoFields;
    }
}

From source file:org.gradle.model.internal.manage.schema.extract.ModelSchemaExtractionContext.java

private ModelSchemaExtractionContext(ModelSchemaExtractionContext<?> parent, ModelType<T> type,
        String description, Action<? super ModelSchema<T>> validator) {
    this.parent = parent;
    this.type = type;
    this.description = description;
    this.validators = Lists.newArrayListWithCapacity(2);
    if (validator != null) {
        validators.add(validator);// w  w  w .  j ava 2 s .  co  m
    }
}

From source file:org.gradoop.model.impl.algorithms.fsm.gspan.encoders.functions.Dictionary.java

@Override
public void reduce(Iterable<WithCount<String>> iterable, Collector<List<String>> collector) throws Exception {

    List<WithCount<String>> list = Lists.newArrayList();

    for (WithCount<String> labelCount : iterable) {
        list.add(labelCount);//from  w  ww.j  a  v a2  s.  c o m
    }

    Collections.sort(list, new LabelFrequencyComparator());

    List<String> intStringDictionary = Lists.newArrayListWithCapacity(list.size());

    for (WithCount<String> entry : list) {
        intStringDictionary.add(entry.getObject());
    }

    collector.collect(intStringDictionary);
}

From source file:com.google.gerrit.server.git.DestinationList.java

public String asText(String label) {
    Set<Branch.NameKey> dests = destinations.get(label);
    if (dests == null) {
        return null;
    }//from   w ww.  java2  s  .co m
    List<Row> rows = Lists.newArrayListWithCapacity(dests.size());
    for (Branch.NameKey dest : sort(dests)) {
        rows.add(new Row(dest.get(), dest.getParentKey().get()));
    }
    return asText("Ref", "Project", rows);
}

From source file:org.summer.ss.core.linking.LinkingProxyAwareResource.java

void clearEncodeURIs() {
    System.out.println("LinkingProxyAwareResource:" + getURI() + ", clearEncodeURIs!");
    uris = Lists.newArrayListWithCapacity(uris.size());
}

From source file:com.zhi.android.modules.welcome.WelcomeOption.java

public WelcomeOption(Context context) {
    final TypedArray a = context.obtainStyledAttributes(R.styleable.WelcomeOption);
    quitEnabled = a.getBoolean(R.styleable.WelcomeOption_welcomeQuitEnabled, true);
    swipeEnabled = a.getBoolean(R.styleable.WelcomeOption_welcomeSwipeEnabled, true);

    {//from w w w  . j  a v a  2 s  .  co m
        final int pages = a.getResourceId(R.styleable.WelcomeOption_welcomePages, 0);
        final TypedArray aa = context.getResources().obtainTypedArray(pages);
        final int pageCount = aa.length();
        pageOptions = Lists.newArrayListWithCapacity(pageCount);
        for (int i = 0; i < pageCount; i++) {
            pageOptions.add(new WelcomePageOption(context, aa.getResourceId(i, 0)));
        }
        aa.recycle();
    }

    if (swipeEnabled) {
        pageOptions.add(WelcomePageOption.NOE);
    }

    a.recycle();
}

From source file:at.molindo.esi4j.action.impl.DefaultSearchResponseWrapper.java

@Override
public synchronized List<SearchHitWrapper> getSearchHits() {
    if (_objects == null) {
        SearchHit[] hits = _response.getHits().hits();
        _objects = Lists.newArrayListWithCapacity(hits.length);
        for (int i = 0; i < hits.length; i++) {
            _objects.add(new DefaultSearchHitWrapper(hits[i], _reader));
        }//  w  ww .ja  v  a2 s  . com
    }
    return _objects;
}