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.rendering.ModuleSetResourceRepository.java
private static List<ProjectResources> computeRepositories(@NotNull final AndroidFacet facet) { // List of module facets the given module depends on List<AndroidFacet> facets = AndroidUtils.getAllAndroidDependencies(facet.getModule(), true); // Android libraries (.aar libraries) the module, or any of the modules it depends on List<AndroidLibrary> libraries = Lists.newArrayList(); addAndroidLibraries(libraries, facet); for (AndroidFacet f : facets) { addAndroidLibraries(libraries, f); }//from w ww. j a v a2 s . c o m boolean includeLibraries = false; ProjectResources main = get(facet.getModule(), includeLibraries); if (facets.isEmpty() && libraries.isEmpty()) { return Collections.singletonList(main); } List<ProjectResources> resources = Lists.newArrayListWithExpectedSize(facets.size()); if (libraries != null) { // Pull out the unique directories, in case multiple modules point to the same .aar folder Set<File> files = Sets.newHashSetWithExpectedSize(facets.size()); Set<String> moduleNames = Sets.newHashSet(); for (AndroidFacet f : facets) { moduleNames.add(f.getModule().getName()); } for (AndroidLibrary library : libraries) { // We should only add .aar dependencies if they aren't already provided as modules. // For now, the way we associate them with each other is via the library name; // in the future the model will provide this for us String libraryName = null; String projectName = library.getProject(); if (projectName != null && !projectName.isEmpty()) { libraryName = projectName.substring(projectName.lastIndexOf(':') + 1); } else { // Pre 0.5 support: remove soon File folder = library.getFolder(); String name = folder.getName(); if (name.endsWith(DOT_AAR)) { libraryName = name.substring(0, name.length() - DOT_AAR.length()); } } if (libraryName != null && !moduleNames.contains(libraryName)) { File resFolder = library.getResFolder(); if (resFolder.exists()) { files.add(resFolder); // Don't add it again! moduleNames.add(libraryName); } } } for (File resFolder : files) { resources.add(FileProjectResourceRepository.get(resFolder)); } } for (AndroidFacet f : facets) { ProjectResources r = get(f.getModule(), includeLibraries); resources.add(r); } resources.add(main); return resources; }
From source file:com.cloudera.recordservice.hive.RecordServiceObjectInspector.java
public RecordServiceObjectInspector(StructTypeInfo rowTypeInfo) { List<String> fieldNames = rowTypeInfo.getAllStructFieldNames(); fields_ = Lists.newArrayListWithExpectedSize(fieldNames.size()); fieldsByName_ = Maps.newHashMap();//from w ww . jav a 2s .c o m for (int fieldIdx = 0; fieldIdx < fieldNames.size(); ++fieldIdx) { final String name = fieldNames.get(fieldIdx); final TypeInfo fieldInfo = rowTypeInfo.getAllStructFieldTypeInfos().get(fieldIdx); RecordServiceStructField fieldImpl = new RecordServiceStructField(name, getFieldObjectInspector(fieldInfo), fieldIdx); fields_.add(fieldImpl); fieldsByName_.put(name.toLowerCase(), fieldImpl); } }
From source file:eu.interedition.collatex.cli.URLWitness.java
public URLWitness read(Function<String, Iterable<String>> tokenizer, Function<String, String> normalizer, Charset charset, XPathExpression tokenXPath) throws IOException, XPathExpressionException, SAXException { InputStream stream = null;//from w w w. j a va 2s.co m try { stream = url.openStream(); if (tokenXPath != null) { final DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); final Document document = documentBuilder.parse(stream); document.normalizeDocument(); final NodeList tokenNodes = (NodeList) tokenXPath.evaluate(document, XPathConstants.NODESET); final List<Token> tokens = Lists.newArrayListWithExpectedSize(tokenNodes.getLength()); for (int nc = 0; nc < tokenNodes.getLength(); nc++) { final Node tokenNode = tokenNodes.item(nc); final String tokenText = tokenNode.getTextContent(); tokens.add(new NodeToken(this, tokenText, normalizer.apply(tokenText), tokenNode)); } setTokens(tokens); } else { final List<Token> tokens = Lists.newLinkedList(); for (String tokenText : tokenizer .apply(CharStreams.toString(new InputStreamReader(stream, charset)))) { tokens.add(new SimpleToken(this, tokenText, normalizer.apply(tokenText))); } setTokens(tokens); } } catch (ParserConfigurationException e) { throw new SAXException(e); } finally { Closeables.close(stream, false); } return this; }
From source file:net.awairo.mcmod.spawnchecker.presetmode.spawncheck.SkeletalWorldSpawnCheck.java
/** * Constructor./*from w w w. jav a 2s . c o m*/ */ protected SkeletalWorldSpawnCheck(ModeBase<?> mode) { this.mode = mode; color = mode.commonColor(); cache = CachedSupplier.of(SpawnPointMarker.supplier()); markers = Lists.newArrayListWithExpectedSize(consts.defaultSpawnCheckerMarkerListSize); currentWorld = game.theWorld; }
From source file:com.facebook.buck.artifact_cache.MultiArtifactCache.java
private static ListenableFuture<Void> storeToCaches(ImmutableList<ArtifactCache> caches, ArtifactInfo info, BorrowablePath output) {//from w w w . j av a 2 s .co m // TODO(cjhopman): support BorrowablePath with multiple writable caches. if (caches.size() != 1) { output = BorrowablePath.notBorrowablePath(output.getPath()); } List<ListenableFuture<Void>> storeFutures = Lists.newArrayListWithExpectedSize(caches.size()); for (ArtifactCache artifactCache : caches) { storeFutures.add(artifactCache.store(info, output)); } // Aggregate future to ensure all store operations have completed. return Futures.transform(Futures.allAsList(storeFutures), Functions.<Void>constant(null)); }
From source file:io.hops.metadata.ndb.dalimpl.hdfs.GroupClusterj.java
static List<Group> convertAndRelease(HopsSession session, Collection<GroupDTO> dtos) throws StorageException { List<Group> groups = Lists.newArrayListWithExpectedSize(dtos.size()); for (GroupDTO dto : dtos) { groups.add(new Group(dto.getId(), dto.getName())); session.release(dto);/* w w w. java2 s . c om*/ } return groups; }
From source file:org.impressivecode.depress.mg.po.PeopleOrganizationMetricProcessor.java
public List<PeopleOrganizationMetric> buildMetric() { List<PeopleOrganizationMetric> metricData = Lists.newArrayListWithExpectedSize(changeData.size()); for (Entry<String, ChangeData> change : changeData.entrySet()) { assertChangeData(change.getValue()); metricData.add(computeMetric(change.getValue())); }//from w w w .j a v a2 s . c o m return metricData; }
From source file:com.google.idea.blaze.base.lang.buildfile.psi.util.PsiUtils.java
@Nullable public static <T extends PsiElement> T findLastChildOfClassRecursive(PsiElement parent, Class<T> psiClass) { List<T> holder = Lists.newArrayListWithExpectedSize(1); Processor<T> getFirst = t -> { holder.add(t);/* w ww .j ava 2s .co m*/ return false; }; processChildrenOfType(parent, getFirst, psiClass, true); return holder.isEmpty() ? null : holder.get(0); }
From source file:de.learnlib.algorithms.baselinelstar.ObservationTable.java
@Nonnull public List<Word<I>> getShortPrefixLabels() { List<Word<I>> labels = Lists.newArrayListWithExpectedSize(shortPrefixRows.size()); for (ObservationTableRow<I> row : shortPrefixRows) { labels.add(row.getLabel());//from ww w .j av a 2 s . c om } return labels; }
From source file:alluxio.hadoop.mapreduce.KeyValueOutputCommitter.java
private List<AlluxioURI> getTaskTemporaryStores(TaskAttemptContext taskContext) throws IOException { AlluxioURI taskOutputURI = KeyValueOutputFormat.getTaskOutputURI(taskContext); Path taskOutputPath = new Path(taskOutputURI.toString()); FileSystem fs = taskOutputPath.getFileSystem(taskContext.getConfiguration()); FileStatus[] subDirs = fs.listStatus(taskOutputPath); List<AlluxioURI> temporaryStores = Lists.newArrayListWithExpectedSize(subDirs.length); for (FileStatus subDir : subDirs) { temporaryStores.add(taskOutputURI.join(subDir.getPath().getName())); }/*from w w w . j a va 2 s .c o m*/ return temporaryStores; }