List of usage examples for com.google.common.collect Lists newArrayListWithCapacity
@GwtCompatible(serializable = true) public static <E> ArrayList<E> newArrayListWithCapacity(int initialArraySize)
From source file:org.lanternpowered.server.world.gen.flat.FlatGeneratorType.java
/** * Creates the default settings of the flat generator. * //from w ww . j a v a2 s. com * @return the default settings */ public static FlatGeneratorSettings getDefaultSettings() { final List<FlatLayer> layers = Lists.newArrayListWithCapacity(3); layers.add(new FlatLayer(BlockTypes.BEDROCK, 1)); layers.add(new FlatLayer(BlockTypes.DIRT, 2)); layers.add(new FlatLayer(BlockTypes.GRASS, 1)); return new FlatGeneratorSettings(BiomeTypes.PLAINS, layers); }
From source file:com.palantir.atlasdb.http.AtlasDbHttpClients.java
/** * Constructs a list, corresponding to the iteration order of the supplied endpoints, of dynamic proxies for the * specified type, using the supplied SSL factory if it is present. *//*from w ww . j a v a 2 s.c o m*/ public static <T> List<T> createProxies(Optional<SSLSocketFactory> sslSocketFactory, Collection<String> endpointUris, Class<T> type) { List<T> ret = Lists.newArrayListWithCapacity(endpointUris.size()); for (String uri : endpointUris) { ret.add(createProxy(sslSocketFactory, uri, type)); } return ret; }
From source file:net.conquiris.qs.QueryConstructor.java
/** * Returns the descriptor for a query token constructor. * @param constructor Constructor to use. * @return The constructor descriptor./*from w w w . j av a2s. c o m*/ * @throws IllegalArgumentException if the constructor if not valid for a descriptor. */ static QueryConstructor of(Constructor<?> constructor) { checkNotNull(constructor); checkArgument(Modifier.isPublic(constructor.getModifiers()), "Not a public constructor"); Class<?>[] types = constructor.getParameterTypes(); int n = types.length; checkArgument(n > 0, "Constructor with no arguments"); List<Class<? extends Token>> list = Lists.newArrayListWithCapacity(n); Kind k = Kind.SINGLE; for (int i = 0; i < n; i++) { Class<?> type = types[i]; if (i < (n - 1) || !(constructor.isVarArgs() && type.isArray())) { list.add(checkType(type)); } else { // Last argument is vararg list.add(checkType(type.getComponentType())); k = Kind.ARRAY; } } // TODO return null; }
From source file:com.facebook.buck.test.XmlTestResultParser.java
private static TestCaseSummary doParse(String xml) throws IOException { Document doc = XmlDomParser.parse(new InputSource(new StringReader(xml)), /* namespaceAware */ true); Element root = doc.getDocumentElement(); Preconditions.checkState("testcase".equals(root.getTagName())); String testCaseName = root.getAttribute("name"); NodeList testElements = doc.getElementsByTagName("test"); List<TestResultSummary> testResults = Lists.newArrayListWithCapacity(testElements.getLength()); for (int i = 0; i < testElements.getLength(); i++) { Element node = (Element) testElements.item(i); String testName = node.getAttribute("name"); long time = Long.parseLong(node.getAttribute("time")); String typeString = node.getAttribute("type"); ResultType type = ResultType.valueOf(typeString); String message;//from ww w.j av a 2s . co m String stacktrace; if (type == ResultType.SUCCESS) { message = null; stacktrace = null; } else { message = node.getAttribute("message"); stacktrace = node.getAttribute("stacktrace"); } NodeList stdoutElements = node.getElementsByTagName("stdout"); String stdOut; if (stdoutElements.getLength() == 1) { stdOut = stdoutElements.item(0).getTextContent(); } else { stdOut = null; } NodeList stderrElements = node.getElementsByTagName("stderr"); String stdErr; if (stderrElements.getLength() == 1) { stdErr = stderrElements.item(0).getTextContent(); } else { stdErr = null; } TestResultSummary testResult = new TestResultSummary(testCaseName, testName, type, time, message, stacktrace, stdOut, stdErr); testResults.add(testResult); } return new TestCaseSummary(testCaseName, testResults); }
From source file:com.ngdata.hbaseindexer.indexer.SolrUpdateCollector.java
/** * Instantiate with an expected initial capacity of added and deleted documents. *///w ww . j a v a2 s. co m public SolrUpdateCollector(int initialSize) { documentsToAdd = Maps.newHashMapWithExpectedSize(initialSize); idsToDelete = Lists.newArrayListWithCapacity(initialSize); deleteQueries = Lists.newArrayList(); }
From source file:com.zimbra.cs.index.ZimbraScoreDoc.java
public static List<ZimbraScoreDoc> listFromLuceneScoreDocs(ScoreDoc[] luceneScoreDocs) { if (luceneScoreDocs == null) { return Lists.newArrayListWithCapacity(0); }//from w w w. ja v a 2 s . c o m List<ZimbraScoreDoc> docs = Lists.newArrayListWithCapacity(luceneScoreDocs.length); for (ScoreDoc luceneDoc : luceneScoreDocs) { docs.add(ZimbraScoreDoc.create(luceneDoc)); } return docs; }
From source file:org.gradle.plugin.management.internal.PluginRequestsSerializer.java
@Override public PluginRequests read(Decoder decoder) throws Exception { int requestCount = decoder.readSmallInt(); if (requestCount == 0) { return DefaultPluginRequests.EMPTY; }//from w w w.ja v a2s. c o m List<PluginRequestInternal> requests = Lists.newArrayListWithCapacity(requestCount); for (int i = 0; i < requestCount; i++) { PluginId pluginId = DefaultPluginId.unvalidated(decoder.readString()); String version = decoder.readNullableString(); boolean apply = decoder.readBoolean(); String decodedLineNumber = decoder.readNullableString(); Integer lineNumber = decodedLineNumber == null ? null : Integer.valueOf(decodedLineNumber); String scriptDisplayName = decoder.readString(); requests.add(i, new DefaultPluginRequest(pluginId, version, apply, lineNumber, scriptDisplayName, null)); } return new DefaultPluginRequests(requests); }
From source file:net.sourceforge.cilib.util.selection.arrangement.RingBasedArrangement.java
@Override public Iterable<T> arrange(Iterable<T> elements) { List<T> tmp = Lists.newArrayList(elements); List<T> result = Lists.newArrayListWithCapacity(tmp.size()); int position = 0; for (T entry : elements) { if (this.marker.equals(entry)) { break; }//from w w w. j a v a2 s . co m position++; } for (int i = 0; i < tmp.size(); ++i) { result.add(tmp.get((position + 1 + i) % tmp.size())); } return result; }
From source file:com.theoriginalbit.moarperipherals.common.tile.firework.QueueBuffer.java
public QueueBuffer(String name, int size) { inventory = Lists.newArrayListWithCapacity(size); invName = name; maxSize = size; }
From source file:com.opengamma.web.analytics.formatting.FudgeMsgFormatter.java
FudgeMsgFormatter() { super(FudgeMsg.class); addFormatter(new Formatter<FudgeMsg>(Format.EXPANDED) { @Override// w ww .j ava2 s. co m Map<String, Object> format(FudgeMsg msg, ValueSpecification valueSpec, Object inlineKey) { int fieldCount = msg.getNumFields(); List<List<String>> matrix = Lists.newArrayListWithCapacity(fieldCount); List<String> yLabels = Lists.newArrayListWithCapacity(fieldCount); // Sorting fields to ensure a consistent order for display purposes. // This could change the meaning of the Fudge message so assumes no repeated fields. List<FudgeField> orderedFields = new ArrayList<FudgeField>(msg.getAllFields()); Collections.sort(orderedFields, s_nameComparator); for (FudgeField field : orderedFields) { List<String> row = Lists.newArrayListWithCapacity(2); row.add(field.getType().getJavaType().getSimpleName()); String displayValue; if (field.getValue() == null) { displayValue = ""; } else if (field.getValue() instanceof FudgeMsg) { displayValue = "Sub-message"; } else { displayValue = field.getValue().toString(); } row.add(displayValue); matrix.add(row); yLabels.add(field.getName()); } Map<String, Object> output = Maps.newHashMap(); output.put(LabelledMatrix2DFormatter.MATRIX, matrix); output.put(LabelledMatrix2DFormatter.X_LABELS, Lists.newArrayList("Name", "Type", "Value")); output.put(LabelledMatrix2DFormatter.Y_LABELS, yLabels); return output; } }); }