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:org.gradoop.flink.algorithms.fsm.transactional.tle.canonicalization.CanonicalLabeler.java
/** * Creates a canonical subgraph graph label * * @param embedding subgraph//from w ww.j a v a2 s .com * * @return canonical label */ public String label(Embedding embedding) { Map<Integer, String> vertices = embedding.getVertices(); Map<Integer, FSMEdge> edges = embedding.getEdges(); Map<Integer, Map<Integer, Set<Integer>>> adjacencyMatrix = createAdjacencyMatrix(vertices, edges); List<String> adjacencyListLabels = Lists.newArrayListWithCapacity(vertices.size()); // for each vertex for (Map.Entry<Integer, String> vertex : vertices.entrySet()) { int vertexId = vertex.getKey(); String adjacencyListLabel = vertex.getValue() + LIST_START; Map<Integer, Set<Integer>> adjacencyList = adjacencyMatrix.get(vertexId); List<String> entryLabels = Lists.newArrayListWithCapacity(adjacencyList.size()); // for each adjacent vertex for (Map.Entry<Integer, Set<Integer>> entry : adjacencyList.entrySet()) { int adjacentVertexId = entry.getKey(); String entryLabel = vertices.get(adjacentVertexId); // for each edge Set<Integer> incidentEdgeIds = entry.getValue(); if (incidentEdgeIds.size() == 1) { FSMEdge incidentEdge = edges.get(incidentEdgeIds.iterator().next()); entryLabel += format(incidentEdge, vertexId); } else { List<String> incidentEdges = Lists.newArrayListWithExpectedSize(incidentEdgeIds.size()); for (int incidentEdgeId : incidentEdgeIds) { incidentEdges.add(format(edges.get(incidentEdgeId), vertexId)); } Collections.sort(incidentEdges); entryLabel += StringUtils.join(incidentEdges, ""); } entryLabels.add(entryLabel); } Collections.sort(entryLabels); adjacencyListLabel += StringUtils.join(entryLabels, NEW_ENTRY); adjacencyListLabels.add(adjacencyListLabel); } Collections.sort(adjacencyListLabels); return StringUtils.join(adjacencyListLabels, NEW_LIST); }
From source file:com.google.jstestdriver.model.JstdTestCase.java
public JstdTestCase updatePlugins(List<FileInfo> plugins) { final List<FileInfo> combined = Lists.newArrayListWithExpectedSize(plugins.size() + this.plugins.size()); combined.addAll(this.plugins); combined.addAll(plugins);//w w w. ja va 2 s. c om return new JstdTestCase(dependencies, tests, combined, id); }
From source file:org.zanata.service.LocaleService.java
static Object buildLocaleDetailsListEntity(List<HLocale> locales, Map<LocaleId, String> localeAliases) { List<LocaleDetails> localeDetails = Lists.newArrayListWithExpectedSize(locales.size()); for (HLocale hLocale : locales) { LocaleId id = hLocale.getLocaleId(); String alias = localeAliases.get(id); localeDetails.add(convertHLocaleToDTO(hLocale, alias)); }//from w w w. j a v a 2 s. c om return new GenericEntity<List<LocaleDetails>>(localeDetails) { }; }
From source file:ru.runa.wfe.commons.logic.CommonLogic.java
protected <T extends SecuredObject> List<T> filterSecuredObject(User user, List<T> securedObjects, Permission permission) {//from w w w . j av a 2 s. com boolean[] allowedArray = permissionDao.isAllowed(user, permission, securedObjects); List<T> securedObjectList = Lists.newArrayListWithExpectedSize(securedObjects.size()); for (int i = 0; i < allowedArray.length; i++) { if (allowedArray[i]) { securedObjectList.add(securedObjects.get(i)); } } return securedObjectList; }
From source file:org.openqa.selenium.android.events.WebViewAction.java
/** * Add KeyEvents to the queue to move the cursor to the rightmost position in the text area. * //from ww w . j av a 2s . c o m * @param textAreaValue the already present in the editable area * @param webview the current webview */ private static void moveCursorToRightMostPosition(String textAreaValue, WebView webview) { List<KeyEvent> events = Lists.newArrayListWithExpectedSize(2); long downTime = SystemClock.uptimeMillis(); events.add(new KeyEvent(downTime, SystemClock.uptimeMillis(), KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_RIGHT, 0)); events.add(new KeyEvent(downTime, SystemClock.uptimeMillis(), KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DPAD_RIGHT, textAreaValue.length())); dispatchEvents(webview, events); }
From source file:com.android.tools.idea.navigator.nodes.AndroidSourceTypeNode.java
private Collection<AbstractTreeNode> annotateWithSourceProvider( Collection<AbstractTreeNode> directoryChildren) { List<AbstractTreeNode> children = Lists.newArrayListWithExpectedSize(directoryChildren.size()); for (AbstractTreeNode child : directoryChildren) { if (child instanceof PsiDirectoryNode) { PsiDirectory directory = ((PsiDirectoryNode) child).getValue(); children.add(new AndroidPsiDirectoryNode(myProject, directory, getSettings(), findSourceProvider(directory.getVirtualFile()))); } else if (child instanceof PsiFileNode) { PsiFile file = ((PsiFileNode) child).getValue(); children.add(new AndroidPsiFileNode(myProject, file, getSettings(), findSourceProvider(file.getVirtualFile()))); } else {/*from ww w . j av a 2 s .c o m*/ children.add(child); } } return children; }
From source file:org.jbpm.console.ng.ht.client.editors.quicknewuser.QuickNewUserPresenter.java
public List<Group> getSelectedGroups() { List<Group> selectedGroups = Lists.newArrayListWithExpectedSize(view.getGroupsList().getValue().length()); for (int i = 0; i < view.getGroupsList().getItemCount(); i++) { if (view.getGroupsList().isItemSelected(i)) { selectedGroups.add(new Group(view.getGroupsList().getValue(i))); }// w w w. jav a 2s . c om } return selectedGroups; }
From source file:additionalpipes.pipes.PipeStructureTeleport.java
public List<Pipe<?>> getAllConnectedPipes() { List<Pipe<?>> result = Lists.newArrayListWithExpectedSize(6); for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = container.getTile(o); if (tile instanceof TileGenericPipe) { result.add(((TileGenericPipe) tile).pipe); }/*from w w w . j a v a2s . co m*/ } result.addAll(logic.<PipeStructureTeleport>getConnectedPipes(null)); return result; }
From source file:com.arpnetworking.metrics.mad.parsers.ProtobufToRecordParser.java
private void processEntries(final ImmutableMap.Builder<String, Metric> metrics, final List<ClientV1.MetricEntry> entries, final MetricType metricType) { for (final ClientV1.MetricEntry metricEntry : entries) { final DefaultMetric.Builder metricBuilder = new DefaultMetric.Builder().setType(metricType); final List<Quantity> quantities = Lists.newArrayListWithExpectedSize(metricEntry.getSamplesCount()); for (final ClientV1.DoubleQuantity quantity : metricEntry.getSamplesList()) { quantities.add(new Quantity.Builder().setUnit(baseUnit(quantity.getUnit())) .setValue(quantity.getValue()).build()); }/*from w w w . j av a 2 s.c o m*/ metricBuilder.setValues(quantities); metrics.put(metricEntry.getName(), metricBuilder.build()); } }
From source file:org.axdt.flex4.debugger.model.FlexValue.java
public IVariable[] getVariables() throws DebugException { try {/*from ww w. j a v a 2 s . co m*/ if (value == null) return EMPTY_VARIABLES; if (cachedMembers == null) { switch (value.getType()) { case VariableType.MOVIECLIP: case VariableType.OBJECT: case VariableType.FUNCTION: Variable[] members = value.getMembers(thread.getSession()); if (members == null) return EMPTY_VARIABLES; List<IVariable> result = Lists.newArrayListWithExpectedSize(members.length); for (int i = 0; i < members.length; i++) { if (members[i].isAttributeSet(VariableAttribute.IS_STATIC)) continue; result.add(new FlexVariable(thread, members[i])); } cachedMembers = result.toArray(new IVariable[result.size()]); break; default: cachedMembers = EMPTY_VARIABLES; } } return cachedMembers; } catch (PlayerDebugException e) { throw debugError(e); } }