List of usage examples for com.google.common.collect Lists newArrayListWithExpectedSize
@GwtCompatible(serializable = true) public static <E> ArrayList<E> newArrayListWithExpectedSize(int estimatedSize)
From source file:com.android.tools.idea.jps.output.parser.aapt.ReadOnlyDocument.java
/** * Creates a new {@link ReadOnlyDocument} for the given file. * * @param file the file whose text will be stored in the document. UTF-8 charset is used to decode the contents of the file. * @throws java.io.IOException if an error occurs while reading the file. *//*from w w w .j a v a2 s.c o m*/ @SuppressWarnings("IOResourceOpenedButNotSafelyClosed") ReadOnlyDocument(@NotNull File file) throws IOException { myContents = Files.toString(file, Charsets.UTF_8); myOffsets = Lists.newArrayListWithExpectedSize(myContents.length() / 30); myOffsets.add(0); for (int i = 0; i < myContents.length(); i++) { char c = myContents.charAt(i); if (c == '\n') { myOffsets.add(i + 1); } } }
From source file:com.facebook.presto.cassandra.CassandraThriftClient.java
private static List<CfSplit> tokenListToSplits(List<String> splitTokens, int splitSize) { List<CfSplit> splits = Lists.newArrayListWithExpectedSize(splitTokens.size() - 1); for (int index = 0; index < splitTokens.size() - 1; index++) { splits.add(new CfSplit(splitTokens.get(index), splitTokens.get(index + 1), splitSize)); }//from ww w. j a va2s. co m return splits; }
From source file:com.carmatech.maven.model.MergerTestUtils.java
public static List<File> getSourceFiles(final String... filePaths) { final List<File> sourceFiles = Lists.newArrayListWithExpectedSize(filePaths.length); for (final String filePath : filePaths) { sourceFiles.add(new File(filePath)); }/*w ww . j a v a2 s.co m*/ return sourceFiles; }
From source file:org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse.java
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); int size = in.readVInt(); indexTemplates = Lists.newArrayListWithExpectedSize(size); for (int i = 0; i < size; i++) { indexTemplates.add(0, IndexTemplateMetaData.Builder.readFrom(in)); }/*from w w w . java2 s . c o m*/ }
From source file:com.technophobia.substeps.runner.builder.ExecutionNodeTreeBuilder.java
public RootNode buildExecutionNodeTree(String description) { List<FeatureNode> features = Lists.newArrayListWithExpectedSize(parameters.getFeatureFileList().size()); for (final FeatureFile featureFile : parameters.getFeatureFileList()) { FeatureNode featureNode = featureNodeBuilder.build(featureFile); if (featureNode != null) { features.add(featureNode);/*from www . j a va2 s . co m*/ } } String env = System.getProperty("environment", "localhost"); return new RootNode(description, features, env, NewSubstepsExecutionConfig.getTags(config), NewSubstepsExecutionConfig.getNonFatalTags(config)); }
From source file:com.android.tools.idea.wizard.ChooseFromFileListDialog.java
private static ListModel getListModel(List<File> files) { ArrayList<FileListItem> items = Lists.newArrayListWithExpectedSize(files.size()); for (File f : files) { items.add(new FileListItem(f)); }// w ww .ja v a 2 s. co m Collections.sort(items); return JBList.createDefaultListModel(ArrayUtil.toObjectArray(items)); }
From source file:com.griddynamics.jagger.agent.model.JmxMetricGroup.java
public ArrayList<JmxMetric> getJmxMetrics() { if (metrics != null) { return metrics; }//from w ww .j a va 2s . c o m metrics = Lists.newArrayListWithExpectedSize(attributes.length); for (int i = 0; i < attributes.length; ++i) { metrics.add(new JmxMetric( new MonitoringParameterImpl(objectName.getCanonicalName() + ATTRIBUTE_DELIMETER + attributes[i], MonitoringParameterLevel.SUT, false), objectName, attributes[i])); } return metrics; }
From source file:com.cloudera.oryx.kmeans.common.pmml.KMeansPMML.java
public static Centers toCenters(ClusteringModel cm) { int dims = cm.getClusteringFields().size(); boolean sparse = cm.getMiningSchema().getMiningFields().size() * 2 < dims; List<RealVector> vecs = Lists.newArrayListWithExpectedSize(cm.getClusters().size()); for (Cluster c : cm.getClusters()) { vecs.add(createCenter(c.getArray(), sparse, dims)); }// w w w .j av a 2 s. c o m return new Centers(vecs); }
From source file:com.android.tools.idea.navigator.nodes.NonAndroidModuleNode.java
@NotNull @Override// www . j a va 2s. c o m public Collection<AbstractTreeNode> getChildren() { Set<NonAndroidSourceType> sourceTypes = getNonEmptySourceTypes(getValue()); List<AbstractTreeNode> nodes = Lists.newArrayListWithExpectedSize(sourceTypes.size()); for (NonAndroidSourceType type : sourceTypes) { nodes.add(new NonAndroidSourceTypeNode(myProject, getValue(), getSettings(), type)); } return nodes; }
From source file:com.textocat.textokit.postagger.opennlp.POSTokenEventStream.java
public static Event[] generateEvents(Annotation spanAnno, BeamSearchContextGenerator<Token> contextGen) { JCas jCas;//from w ww .j a va 2 s . c om try { jCas = spanAnno.getCAS().getJCas(); } catch (CASException e) { throw new IllegalStateException(e); } List<Token> tokens = new ArrayList<>(JCasUtil.selectCovered(jCas, Token.class, spanAnno)); Map<Token, Word> token2WordIndex = MorphCasUtils.getToken2WordIndex(jCas, spanAnno); List<String> tags = Lists.newArrayListWithExpectedSize(tokens.size()); for (Token tok : tokens) { Word word = token2WordIndex.get(tok); String tokStr = tok.getCoveredText(); if (word == null) { if (tok instanceof NUM || tok instanceof W) { throw new IllegalStateException( String.format("Token %s in %s does not have corresponding Word annotation", toPrettyString(tok), getDocumentUri(jCas))); } String tag = PunctuationUtils.getPunctuationTag(tokStr); tags.add(tag); } else { Wordform wf = MorphCasUtils.requireOnlyWordform(word); String tag = wf.getPos(); tags.add(String.valueOf(tag)); } } return generateEvents(spanAnno, tokens.toArray(new Token[tokens.size()]), tags.toArray(new String[tags.size()]), contextGen); }