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:com.android.tools.idea.lint.AndroidLintInvalidUsesTagAttributeInspection.java

@NotNull
@Override//  w  ww .  j a v  a2 s .  c om
public AndroidLintQuickFix[] getQuickFixes(@NotNull PsiElement startElement, @NotNull PsiElement endElement,
        @NotNull String message) {
    final XmlAttribute attribute = PsiTreeUtil.getParentOfType(startElement, XmlAttribute.class);
    XmlAttributeValue attributeValue = attribute == null ? null : attribute.getValueElement();
    if (attributeValue != null && attributeValue.getTextLength() != 0) {
        String value = StringUtil.unquoteString(attributeValue.getText());
        String regexp = "(" + value + ")";
        String[] suggestions = AndroidAutoDetector.getAllowedAutomotiveAppTypes();
        List<AndroidLintQuickFix> fixes = Lists.newArrayListWithExpectedSize(suggestions.length);
        for (String suggestion : suggestions) {
            fixes.add(new ReplaceStringQuickFix("Replace with \"" + suggestion + "\"", regexp, suggestion));
        }
        return fixes.toArray(new AndroidLintQuickFix[fixes.size()]);
    } else {
        return AndroidLintQuickFix.EMPTY_ARRAY;
    }
}

From source file:edu.umich.robot.soar.WaypointsIL.java

@Override
public void update() {
    List<String> seen = Lists.newArrayListWithExpectedSize(waypointMap.size());

    for (Waypoint waypoint : waypoints) {
        logger.trace("Saw waypoint " + waypoint);
        seen.add(waypoint.getId());/*  w ww  .  j a  v  a  2  s .com*/

        PointDataIL pointData = waypointMap.get(waypoint.getId());
        if (pointData == null)
            pointData = createNewPointData(waypoint);

        logger.trace("Updating waypoint point data.");
        pointData.update();

        waypointMap.put(waypoint.getId(), pointData);
    }

    for (Iterator<Entry<String, PointDataIL>> iter = waypointMap.entrySet().iterator(); iter.hasNext();) {
        Entry<String, PointDataIL> entry = iter.next();
        if (!seen.contains(entry.getKey())) {
            logger.debug("Removing waypoint " + entry.getKey());
            entry.getValue().getRoot().DestroyWME();
            iter.remove();
        }
    }
    logger.trace("Update done.");
}

From source file:uk.co.flax.biosolr.ontology.documents.DocumentIndexer.java

public DocumentIndexer(String configFilepath) throws IOException, StorageEngineException {
    this.config = readConfig(configFilepath);
    this.storageEngines = Lists.newArrayListWithExpectedSize(config.getStorage().getEngineTypes().size());
    initialiseStorageEngines(config.getStorage());
}

From source file:com.android.tools.idea.navigator.nodes.ExternalBuildFilesGroupNode.java

@NotNull
@Override/*w  w  w . j a  v  a  2s.c o m*/
public Collection<? extends AbstractTreeNode> getChildren() {
    Map<VirtualFile, String> buildFiles = getBuildFilesWithModuleNames();
    List<PsiFileNode> children = Lists.newArrayListWithExpectedSize(buildFiles.size());

    for (Map.Entry<VirtualFile, String> buildFileWithModuleName : buildFiles.entrySet()) {
        addPsiFile(children, buildFileWithModuleName.getKey(), buildFileWithModuleName.getValue());
    }

    return children;
}

From source file:org.apache.kylin.metrics.lib.impl.BlockingReservoir.java

public BlockingReservoir(int minReportSize, int maxReportSize, int MAX_REPORT_TIME) {
    this.MAX_REPORT_SIZE = maxReportSize;
    this.MIN_REPORT_SIZE = minReportSize;
    this.MAX_REPORT_TIME = MAX_REPORT_TIME * 60 * 1000L;

    this.recordsQueue = new LinkedBlockingQueue<>();
    this.listeners = Lists.newArrayList();

    this.records = Lists.newArrayListWithExpectedSize(MAX_REPORT_SIZE);

    scheduledReporter = new ThreadFactoryBuilder().setNameFormat("metrics-blocking-reservoir-scheduler-%d")
            .build().newThread(new ReporterRunnable());
}

From source file:org.summer.dsl.xbase.scoping.NestedTypeAwareImportNormalizerWithDotSeparator.java

@Override
public QualifiedName deresolve(QualifiedName fullyQualifiedName) {
    if (hasWildCard()) {
        if (fullyQualifiedName.startsWith(getImportedNamespacePrefix())
                && fullyQualifiedName.getSegmentCount() != getImportedNamespacePrefix().getSegmentCount()) {
            return fullyQualifiedName.skipFirst(getImportedNamespacePrefix().getSegmentCount());
        }//from  w w  w .  ja  va  2  s. c om
    } else {
        if (fullyQualifiedName.equals(getImportedNamespacePrefix())) {
            return QualifiedName.create(fullyQualifiedName.getLastSegment());
        }
        if (fullyQualifiedName.startsWith(getImportedNamespacePrefix())) {
            return fullyQualifiedName.skipFirst(getImportedNamespacePrefix().getSegmentCount() - 1);
        }
        int segmentCount = fullyQualifiedName.getSegmentCount();
        List<String> segments = Lists.newArrayListWithExpectedSize(segmentCount);
        for (int i = 0; i < segmentCount; i++) {
            String segment = fullyQualifiedName.getSegment(i);
            segments.addAll(Strings.split(segment, '$'));
        }
        if (segments.size() > segmentCount) {
            QualifiedName withoutDollars = QualifiedName.create(segments);
            if (withoutDollars.startsWith(getImportedNamespacePrefix())) {
                return withoutDollars.skipFirst(getImportedNamespacePrefix().getSegmentCount() - 1);
            }
        }
    }
    return null;
}

From source file:com.cloudera.exhibit.avro.AvroExhibit.java

public static Exhibit create(GenericRecord record) {
    Schema schema = record.getSchema();
    ExhibitDescriptor desc = createDescriptor(schema);
    List<Object> attrValues = Lists.newArrayListWithExpectedSize(desc.attributes().size());
    for (int i = 0; i < desc.attributes().size(); i++) {
        Object val = record.get(desc.attributes().get(i).name);
        if (val != null && desc.attributes().get(i).type == ObsDescriptor.FieldType.STRING) {
            val = val.toString();
        }/*from  w  w  w. j a va 2  s  .  co m*/
        attrValues.add(val);
    }
    Map<String, Frame> frames = Maps.newHashMap();
    for (String frameName : desc.frames().keySet()) {
        List<GenericRecord> recs = Lists.newArrayList();
        List<GenericRecord> raw = (List<GenericRecord>) record.get(frameName);
        if (raw != null) {
            for (GenericRecord rawRec : raw) {
                recs.add(getInnerRecord(rawRec));
            }
        }
        frames.put(frameName, new AvroFrame(desc.frames().get(frameName), recs));
    }
    return new SimpleExhibit(new SimpleObs(desc.attributes(), attrValues), frames);
}

From source file:org.impressivecode.depress.matcher.commonmarker.MarkerInputTransformer.java

@Override
public List<MarkerDataType> transform(final DataTable inTable) {
    checkNotNull(this.minimalTableSpec, "Minimal DataTableSpec hat to be set");
    checkNotNull(this.inputTableSpec, "Input DataTableSpec hat to be set");
    checkNotNull(inTable, "InTable has to be set");
    List<MarkerDataType> markerData = Lists.newArrayListWithExpectedSize(1000);
    RowIterator iterator = inTable.iterator();
    while (iterator.hasNext()) {
        markerData.add(transformRow(iterator.next()));
    }//from  w  w  w .  ja  va 2s  .co  m
    return markerData;
}

From source file:com.android.tools.idea.navigator.nodes.NonAndroidSourceTypeNode.java

@NotNull
@Override/*  w ww  . j a  va2s . com*/
public Collection<? extends AbstractTreeNode> getChildren() {
    List<VirtualFile> sourceFolders = getSourceFolders();
    List<AbstractTreeNode> children = Lists.newArrayListWithExpectedSize(sourceFolders.size());

    PsiManager psiManager = PsiManager.getInstance(myProject);
    ProjectViewDirectoryHelper directoryHelper = ProjectViewDirectoryHelper.getInstance(myProject);
    for (VirtualFile file : sourceFolders) {
        PsiDirectory dir = psiManager.findDirectory(file);
        if (dir != null) {
            children.addAll(directoryHelper.getDirectoryChildren(dir, getSettings(), true));
        }
    }

    return children;
}

From source file:com.google.idea.blaze.base.lang.buildfile.psi.util.PsiUtils.java

@Nullable
public static <T extends PsiElement> T findFirstChildOfClassRecursive(PsiElement parent, Class<T> psiClass) {
    List<T> holder = Lists.newArrayListWithExpectedSize(1);
    Processor<T> getFirst = t -> {
        holder.add(t);//from   www.j  ava  2 s .  co m
        return false;
    };
    processChildrenOfType(parent, getFirst, psiClass);
    return holder.isEmpty() ? null : holder.get(0);
}