List of usage examples for com.google.common.collect Lists newLinkedList
@GwtCompatible(serializable = true) public static <E> LinkedList<E> newLinkedList()
From source file:org.eclipse.recommenders.utils.rcp.ast.BindingUtils.java
public static List<ITypeName> toTypeNames(final ITypeBinding[] interfaces) { final List<ITypeName> res = Lists.newLinkedList(); for (final ITypeBinding b : interfaces) { final Optional<ITypeName> opt = toTypeName(b); if (opt.isPresent()) { res.add(opt.get());// w w w. j a va2 s .com } } return res; }
From source file:io.atomix.core.set.impl.DistributedSetProxy.java
@Override public CompletableFuture<Boolean> prepare(TransactionLog<SetUpdate<String>> transactionLog) { Map<PartitionId, List<SetUpdate<String>>> updatesGroupedBySet = Maps.newIdentityHashMap(); transactionLog.records().forEach(update -> { updatesGroupedBySet//from w ww . j a v a2s.com .computeIfAbsent(getProxyClient().getPartitionId(update.element()), k -> Lists.newLinkedList()) .add(update); }); Map<PartitionId, TransactionLog<SetUpdate<String>>> transactionsBySet = Maps.transformValues( updatesGroupedBySet, list -> new TransactionLog<>(transactionLog.transactionId(), transactionLog.version(), list)); return Futures .allOf(transactionsBySet.entrySet().stream() .map(e -> getProxyClient().applyOn(e.getKey(), service -> service.prepare(e.getValue())) .thenApply(v -> v == PrepareResult.OK || v == PrepareResult.PARTIAL_FAILURE)) .collect(Collectors.toList())) .thenApply(list -> list.stream().reduce(Boolean::logicalAnd).orElse(true)); }
From source file:models.feeds.NodeUpdates.java
@Override public void getData(Map<String, String> params, Request request, Session session, User user, RenderArgs renderArgs) {/*w w w. j a v a 2s . c om*/ Integer start = 0; Integer count = 30; ObjectId nodeId = MongoEntity.toId(params.get("id")); List<NodeContent> newNodes = null; try { BasicDBObject query = new BasicDBObject("ids", nodeId); DBCursor iobj = Activity.dbcol.find(query).sort(sort).skip(start).limit(count); List<Activity> lll = MongoDB.transform(iobj, MongoDB.getSelf().toActivity()); if (!lll.isEmpty()) { List<ObjectId> nodeIds = Lists.newLinkedList(); for (Activity ac : reverse(lll)) nodeIds.add(ac.getOid()); newNodes = NodeContent.load(nodeIds, user); } } catch (Exception ex) { Logger.info("NodeUpdates"); ex.printStackTrace(); Logger.info(ex.toString()); } renderArgs.put(dataName, newNodes); }
From source file:com.android.tools.idea.wizard.ImportSourceModulePath.java
public ImportSourceModulePath(@Nullable VirtualFile importSource, @NotNull NewModuleWizardState wizardState, @NotNull WizardContext context, @Nullable Icon sidePanelIcon, @Nullable TemplateWizardStep.UpdateListener listener) { myWizardState = wizardState;/*from www . j a va2s .c o m*/ myContext = context; List<ModuleWizardStep> steps = Lists.newLinkedList(); ImportSourceLocationStep locationStep = new ImportSourceLocationStep(context, importSource, wizardState, sidePanelIcon, listener); steps.add(locationStep); for (ModuleImporter importer : ModuleImporter.getAllImporters(myContext)) { steps.addAll(importer.createWizardSteps()); } mySteps = steps; }
From source file:org.eclipse.sirius.ui.business.api.dialect.HierarchyLabelProvider.java
@Override public String getText(Object element) { if (element instanceof EObject && handles((EObject) element)) { LinkedList<String> segments = Lists.newLinkedList(); for (EObject current = (EObject) element; current != null; current = current.eContainer()) { segments.addFirst(getLabel(current)); }//w w w . j ava 2 s. c o m return Joiner.on(getDelimiter()).join(segments); } return wrappedProvider != null ? wrappedProvider.getText(element) : super.getText(element); }
From source file:org.richfaces.tests.metamer.ftest.extension.configurator.use.UsesConfigurator.java
private List<Config> createConfig(Uses annotation, Object testInstance) { UseWithField[] value = annotation.value(); if (value == null) { throw new IllegalArgumentException("The Uses annotation should contain at least one UseWithField."); }/*from w ww . j a v a 2s. c o m*/ UseWithFieldConfigurator useWithFieldConfigurator = new UseWithFieldConfigurator(); List<List<Config>> result = Lists.newLinkedList(); for (UseWithField useWithField : value) { result.add(useWithFieldConfigurator.createConfig(useWithField, testInstance)); } return ConfiguratorUtils.mergeAllConfigsToOne(result).get(0); }
From source file:voldemort.examples.LoadGeneratorExample.java
@Override public void run() { long startTime = System.currentTimeMillis(); List<Future> futures = Lists.newLinkedList(); for (int i = 0; i < numberOfPuts; i++) { Future future = executorService .submit(new PutJob(client, "knut" + String.valueOf(i), "toto" + String.valueOf(i))); futures.add(future);//from w w w. j av a 2 s . c om } // for (int i = 0; i < numberOfPuts; i++) { // version = client.get("knut" + i); // } // dont take any more new tasks executorService.shutdown(); try { for (Future f : futures) { f.get(); } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } long stopTime = System.currentTimeMillis(); System.out.println("Time to put " + numberOfPuts + " values: " + (stopTime - startTime) + "ms"); }
From source file:presto.android.gui.GraphUtil.java
public void findBackwardReachableNodes(NNode start, Set<NNode> reachableNodes) { LinkedList<NNode> worklist = Lists.newLinkedList(); worklist.add(start);//from www . j a v a 2 s .c o m reachableNodes.add(start); while (!worklist.isEmpty()) { NNode n = worklist.remove(); for (Iterator<NNode> iter = n.getPredecessors(); iter.hasNext();) { NNode s = iter.next(); if (reachableNodes.contains(s)) { continue; } if (verbose) { System.out.println("[findReachableNodes] Edge: " + n + " --> " + s); } if (s instanceof NOpNode) { if (!(start instanceof NOpNode)) { reachableNodes.add(s); } } else { worklist.add(s); reachableNodes.add(s); } } } }
From source file:com.github.autermann.matlab.MatlabRequest.java
/** * Creates a new <code>MLRequest</code> instance for the given function * name. This constructor will assume//from w ww .j a v a 2 s.co m * you are only expecting/requesting a single result value - use * {@link #MLRequest(String, int)} or * {@link #setResultCount(int)} if you wish for more. * * @param function the name of the function to execute */ public MatlabRequest(String function) { checkArgument(function != null && !function.isEmpty()); this.function = function; this.results = Maps.newLinkedHashMap(); this.parameters = Lists.newLinkedList(); }
From source file:rabbit.data.internal.xml.DataStore.java
@Override public List<File> getDataFiles(LocalDate start, LocalDate end) { List<File> result = Lists.newLinkedList(); IPath[] storagePaths = XmlPlugin.getDefault().getStoragePaths(); for (IPath path : storagePaths) { result.addAll(getDataFiles(start, end, path)); }// w w w . j av a 2 s . c o m return result; }