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.romeikat.datamessie.core.base.util.CollectionUtil.java
public List<Long> createLongList(Integer min, final int max) { final List<Long> result = Lists.newArrayListWithExpectedSize(max); if (min == null) { min = 0;//from w w w. j a v a 2 s . c om } for (long l = min; l < max; l++) { result.add(l); } return result; }
From source file:org.gradoop.model.impl.algorithms.fsm.gspan.GSpan.java
/** * Creates the gSpan mining representation of a graph transaction from an * existing encoded subgraph./*w w w .ja va 2 s . c o m*/ * * @param subgraph encodes subgraph * @return graph transaction */ private static GSpanGraph createGSpanGraph(DFSCode subgraph) { // turn DFS edges into gSpan edges List<DFSStep> steps = subgraph.getSteps(); List<AdjacencyList> adjacencyLists = Lists.newArrayList(); List<GSpanEdge> edges = Lists.newArrayListWithExpectedSize(steps.size()); createAdjacencyListsAndEdges(steps, adjacencyLists, edges); return createGSpanGraph(adjacencyLists, edges); }
From source file:org.terasology.rendering.world.ChunkMeshUpdateManager.java
public List<RenderableChunk> availableChunksForUpdate() { List<RenderableChunk> result = Lists.newArrayListWithExpectedSize(chunksComplete.size()); chunksComplete.drainTo(result);//www . j ava2s.c o m chunksProcessing.removeAll(result); return result; }
From source file:com.android.tools.idea.navigator.nodes.AndroidBuildScriptsGroupNode.java
@Override @NotNull//w w w.j a v a2 s .co m public Collection<? extends AbstractTreeNode> getChildren() { Map<VirtualFile, String> scripts = getBuildScriptsWithQualifiers(); List<PsiFileNode> children = Lists.newArrayListWithExpectedSize(scripts.size()); for (Map.Entry<VirtualFile, String> scriptWithQualifier : scripts.entrySet()) { addPsiFile(children, scriptWithQualifier.getKey(), scriptWithQualifier.getValue()); } return children; }
From source file:defrac.intellij.gotoDeclaration.GotoDeclarationHandlerBase.java
@Nullable @Override//from ww w . j ava 2 s .c o m public PsiElement[] getGotoDeclarationTargets(@Nullable final PsiElement element, final int offset, final Editor editor) { if (element == null) { return EMPTY_ARRAY; } if (onlyInDefracModule && DefracFacet.getInstance(element) == null) { return EMPTY_ARRAY; } final PsiLiteralExpression literal = PsiTreeUtil.getParentOfType(element, PsiLiteralExpression.class, /*strict=*/false); if (literal == null) { return EMPTY_ARRAY; } final PsiAnnotation annotation = PsiTreeUtil.getParentOfType(literal, PsiAnnotation.class, /*strict=*/false); if (!isDefracAnnotation(annotation)) { return EMPTY_ARRAY; } final PsiReference[] references = literal.getReferences(); final ArrayList<PsiPolyVariantReference> defracReferences = Lists .newArrayListWithExpectedSize(references.length); for (final PsiReference reference : references) { if (isDefracReference(reference)) { if (!reference.getRangeInElement().contains(offset)) { continue; } defracReferences.add((PsiPolyVariantReference) reference); } } final ArrayList<PsiElement> result = Lists.newArrayListWithExpectedSize(defracReferences.size()); for (final PsiPolyVariantReference reference : defracReferences) { final ResolveResult[] resolveResults = reference.multiResolve(false); for (final PsiElement resolveResult : PsiUtil.mapElements(resolveResults)) { if (resolveResult == null) { continue; } result.add(resolveResult); } } return result.toArray(new PsiElement[result.size()]); }
From source file:org.xpect.ui.services.XtResourceValidator.java
public List<Issue> validateDelegate(Resource resource, CheckMode mode, CancelIndicator indicator, Configuration fileConfig) { List<Issue> issues = delegate.validate(resource, mode, indicator); List<Issue> result = Lists.newArrayListWithExpectedSize(issues.size()); for (Issue issue : issues) if (issue != null) result.add(issue);/*from w w w .j a v a2s.co m*/ return result; }
From source file:cpw.mods.fml.common.network.ModListResponsePacket.java
@Override public FMLPacket consumePacket(byte[] data) { ByteArrayDataInput dat = ByteStreams.newDataInput(data); int versionListSize = dat.readInt(); modVersions = Maps.newHashMapWithExpectedSize(versionListSize); for (int i = 0; i < versionListSize; i++) { String modName = dat.readUTF(); String modVersion = dat.readUTF(); modVersions.put(modName, modVersion); }/*from w w w . jav a 2 s . c o m*/ int missingModSize = dat.readInt(); missingMods = Lists.newArrayListWithExpectedSize(missingModSize); for (int i = 0; i < missingModSize; i++) { missingMods.add(dat.readUTF()); } return this; }
From source file:org.eclipse.xtext.ui.containers.WorkspaceProjectsStateHelper.java
public List<String> initVisibleHandles(String handle) { try {/*from w ww .j av a 2 s .c o m*/ IProject project = getWorkspaceRoot().getProject(handle); if (isAccessibleXtextProject(project)) { try { IProject[] referencedProjects = project.getReferencedProjects(); List<String> result = Lists.newArrayListWithExpectedSize(referencedProjects.length); result.add(handle); for (IProject referencedProject : referencedProjects) { if (isAccessibleXtextProject(referencedProject)) { result.add(referencedProject.getName()); } } return result; } catch (CoreException e) { log.error(e.getMessage(), e); } } } catch (IllegalArgumentException e) { if (log.isDebugEnabled()) log.debug("Cannot init visible handles for containerHandle '" + handle + "'", e); } return Collections.emptyList(); }
From source file:com.romeikat.datamessie.core.base.service.DownloadService.java
public List<DocumentWithDownloads> getDocumentsWithDownloads(final SharedSessionContract ssc, final long sourceId, final Set<String> urls) { final List<DocumentWithDownloads> documentsWithDownloads = Lists.newArrayListWithExpectedSize(urls.size()); final Set<Long> processedDocumentIds = Sets.newHashSetWithExpectedSize(urls.size()); for (final String url : urls) { final DocumentWithDownloads documentWithDownloads = getDocumentWithDownloads(ssc, sourceId, url); if (documentWithDownloads == null) { continue; }//from w ww . j av a 2s.c om final long documentId = documentWithDownloads.getDocumentId(); if (processedDocumentIds.contains(documentId)) { continue; } processedDocumentIds.add(documentId); documentsWithDownloads.add(documentWithDownloads); } return documentsWithDownloads; }
From source file:ru.runa.wf.logic.bot.UpdatePermissionsTaskHandler.java
@Override public Map<String, Object> handle(User user, VariableProvider variableProvider, WfTask task) throws Exception { boolean allowed = true; if (settings.isConditionExists()) { String conditionVar = variableProvider.getValue(String.class, settings.getConditionVarName()); if (!settings.getConditionVarValue().equals(conditionVar)) { allowed = false;/* w ww. j av a 2s . c o m*/ } } if (allowed) { Set<Executor> executors = Sets.newHashSet(); for (String swimlaneInitializer : settings.getSwimlaneInitializers()) { executors.addAll(SwimlaneInitializerHelper.evaluate(swimlaneInitializer, variableProvider)); } List<Collection<Permission>> allPermissions = Lists.newArrayListWithExpectedSize(executors.size()); SecuredObject securedObject = Delegates.getExecutionService().getProcess(user, task.getProcessId()); List<Long> executorIds = Lists.newArrayList(); for (Executor executor : executors) { List<Permission> oldPermissions = Delegates.getAuthorizationService().getIssuedPermissions(user, executor, securedObject); allPermissions .add(getNewPermissions(oldPermissions, settings.getPermissions(), settings.getMethod())); executorIds.add(executor.getId()); } Delegates.getAuthorizationService().setPermissions(user, executorIds, allPermissions, securedObject); } return null; }