List of usage examples for com.google.common.collect Lists reverse
@CheckReturnValue public static <T> List<T> reverse(List<T> list)
From source file:es.usc.citius.composit.core.composition.search.ComposIT.java
public ServiceMatchNetwork<E, T> searchComposition(Signature<E> request) { // Build the initial match graph network (first pass) ServiceMatchNetwork<E, T> network = discoverer.search(request); // Apply optimizations for (NetworkOptimizer<E, T> opt : optimizations) { network = opt.optimize(network); }/*from ww w . ja v a 2 s . c o m*/ Algorithms.Search<State<E>, HeuristicNode<State<E>, Double>>.Result searchResult = CompositSearch .create(network).search(); // Take the service operations from the optimal state path. We reverse the list because // the search was done backwards. List<State<E>> states = Lists.reverse(searchResult.getOptimalPath()); List<Set<Operation<E>>> optimalServiceOps = Lists.transform(states, new Function<State<E>, Set<Operation<E>>>() { @Override public Set<Operation<E>> apply(State<E> state) { return state.getStateOperations(); } }); // Generate a new ServiceMatchNetwork composition with the optimal services. // To build the composition, we use the information of the previous network to build the match relations // between services among the optimal services. ServiceMatchNetwork<E, T> composition = new DirectedAcyclicSMN<E, T>( new HashLeveledServices<E>(optimalServiceOps), network); return composition; }
From source file:org.gradle.model.internal.manage.schema.extract.DefaultModelSchemaExtractor.java
@Override public <T> ModelSchema<T> extract(ModelType<T> type, ModelSchemaCache cache) { DefaultModelSchemaExtractionContext<T> context = DefaultModelSchemaExtractionContext.root(type); List<DefaultModelSchemaExtractionContext<?>> validations = Lists.newArrayList(); Queue<DefaultModelSchemaExtractionContext<?>> unsatisfiedDependencies = new ArrayDeque<DefaultModelSchemaExtractionContext<?>>(); DefaultModelSchemaExtractionContext<?> extractionContext = context; validations.add(extractionContext);/*from w ww. j a v a 2 s .c om*/ while (extractionContext != null) { extractSchema(extractionContext, cache); Iterable<DefaultModelSchemaExtractionContext<?>> dependencies = extractionContext.getChildren(); Iterables.addAll(validations, dependencies); pushUnsatisfiedDependencies(dependencies, unsatisfiedDependencies, cache); extractionContext = unsatisfiedDependencies.poll(); } for (DefaultModelSchemaExtractionContext<?> validationContext : Lists.reverse(validations)) { // TODO - this will leave invalid types in the cache when it fails validate(validationContext, cache); } return context.getResult(); }
From source file:org.sosy_lab.cpachecker.cpa.predicate.counterexamples.AbstractNegatedPathCounterexampleFilter.java
@Override protected Optional<T> getCounterexampleRepresentation(CounterexampleInfo counterexample) throws InterruptedException { List<CFAEdge> edges = counterexample.getTargetPath().getInnerEdges(); int cutPoint = edges.size() - 1; // Position of last AssumeEdge in path for (CFAEdge edge : Lists.reverse(edges)) { if (edge instanceof AssumeEdge) { break; }/* w ww. j a v a 2s . c o m*/ cutPoint--; } if (cutPoint < 0) { // no AssumEdge in path, cannot use this filter return Optional.absent(); } AssumeEdge lastAssumeEdge = (AssumeEdge) edges.get(cutPoint); List<CFAEdge> prefix = edges.subList(0, cutPoint); PathFormula pf = pfmgr.makeEmptyPathFormula(); List<BooleanFormula> formulas = new ArrayList<>(prefix.size() + 1); try { for (CFAEdge edge : prefix) { pf = pfmgr.makeAnd(pf, edge); formulas.add(pf.getFormula()); pf = pfmgr.makeEmptyPathFormula(pf); } pf = pfmgr.makeAnd(pf, CFAUtils.getComplimentaryAssumeEdge(lastAssumeEdge)); formulas.add(pf.getFormula()); } catch (CPATransferException e) { logger.logUserException(Level.WARNING, e, "Failed to filter counterexample"); return Optional.absent(); } return getCounterexampleRepresentation(formulas); }
From source file:org.killbill.commons.skeleton.modules.JerseyBaseServerModule.java
public JerseyBaseServerModule( final Map<String, ArrayList<Entry<Class<? extends Filter>, Map<String, String>>>> filters, final Map<String, ArrayList<Entry<Class<? extends Filter>, Map<String, String>>>> filtersRegex, final Map<String, Class<? extends HttpServlet>> servlets, final Map<String, Class<? extends HttpServlet>> servletsRegex, final Map<String, Class<? extends HttpServlet>> jaxrsServlets, final Map<String, Class<? extends HttpServlet>> jaxrsServletsRegex, final String jaxrsUriPattern, final Collection<String> jaxrsResources, final List<String> jerseyFilters, final Map<String, String> jerseyParams) { super(filters, filtersRegex, servlets, servletsRegex, jaxrsServlets, jaxrsServletsRegex, jaxrsUriPattern, jaxrsResources);/*from w ww . j a v a2 s . c om*/ String manuallySpecifiedRequestFilters = Strings .nullToEmpty(jerseyParams.remove(JERSEY_CONTAINER_REQUEST_FILTERS)); String manuallySpecifiedResponseFilters = Strings .nullToEmpty(jerseyParams.remove(JERSEY_CONTAINER_RESPONSE_FILTERS)); if (!jerseyFilters.isEmpty()) { if (!manuallySpecifiedRequestFilters.isEmpty()) { manuallySpecifiedRequestFilters += ";"; } if (!manuallySpecifiedResponseFilters.isEmpty()) { manuallySpecifiedResponseFilters += ";"; } } final String containerRequestFilters = manuallySpecifiedRequestFilters + joiner.join(jerseyFilters); final String containerResponseFilters = manuallySpecifiedResponseFilters + joiner.join(Lists.reverse(jerseyFilters)); this.jerseyParams = new ImmutableMap.Builder<String, String>(); if (!containerRequestFilters.isEmpty()) { this.jerseyParams.put(JERSEY_CONTAINER_REQUEST_FILTERS, containerRequestFilters); } if (!containerResponseFilters.isEmpty()) { this.jerseyParams.put(JERSEY_CONTAINER_RESPONSE_FILTERS, containerResponseFilters); } // The LoggingFilter will log the body by default, which breaks StreamingOutput final String disableEntityLogging = Objects .firstNonNull(Strings.emptyToNull(jerseyParams.remove(JERSEY_DISABLE_ENTITYLOGGING)), "true"); this.jerseyParams.put(JERSEY_DISABLE_ENTITYLOGGING, disableEntityLogging).putAll(jerseyParams); }
From source file:pl.betoncraft.betonquest.Journal.java
/** * Retrieves the list of generated texts. * //from w ww .j av a 2 s . c o m * @return list of Strings - texts for every journal entry */ public List<String> getText() { return Lists.reverse(texts); }
From source file:org.polymap.rhei.batik.engine.DefaultBrowserNavigation.java
/** * Handle {@link PanelChangeEvent}.//w w w. ja va2 s . c o m * <p/> * Called after UI handlers have passed: <i>delay=500</i> */ @EventHandler(display = true, delay = 500) protected void onPanelChanged(List<PanelChangeEvent> evs) { log.debug("Events: " + evs.stream().map(ev -> ev.toString()).reduce("", (r, s) -> r + "\n\t\t" + s)); for (PanelChangeEvent ev : Lists.reverse(evs)) { PanelStatus newStatus = (PanelStatus) ev.getNewValue(); PanelStatus oldStatus = (PanelStatus) ev.getOldValue(); // newly created/opened panel if (newStatus == PanelStatus.VISIBLE && oldStatus == PanelStatus.INITIALIZED) { IPanel panel = ev.getPanel(); topPanelPath = new PanelPath(panel.site().path()); replaceState(panel.id().id(), ev.getPanel().site().title.get()); break; } // top panel closed (by UI or browser back button) if (newStatus == null) { topPanelPath = ev.getSource().path().removeLast(1); IPanel panel = appManager.getPanel(topPanelPath); replaceState(panel.id().id(), panel.site().title.get()); break; } } }
From source file:org.sonar.java.se.constraint.ConstraintManager.java
public SymbolicValue createBinarySymbolicValue(Tree syntaxNode, List<SymbolicValue> computedFrom) { SymbolicValue result;/*from ww w . jav a2s .c om*/ switch (syntaxNode.kind()) { case EQUAL_TO: result = createRelationalSymbolicValue(Kind.EQUAL, computedFrom); break; case NOT_EQUAL_TO: result = createRelationalSymbolicValue(Kind.NOT_EQUAL, computedFrom); break; case LESS_THAN: result = createRelationalSymbolicValue(Kind.LESS_THAN, computedFrom); break; case LESS_THAN_OR_EQUAL_TO: result = createRelationalSymbolicValue(Kind.GREATER_THAN_OR_EQUAL, Lists.reverse(computedFrom)); break; case GREATER_THAN: result = createRelationalSymbolicValue(Kind.LESS_THAN, Lists.reverse(computedFrom)); break; case GREATER_THAN_OR_EQUAL_TO: result = createRelationalSymbolicValue(Kind.GREATER_THAN_OR_EQUAL, computedFrom); break; case AND: case AND_ASSIGNMENT: result = new SymbolicValue.AndSymbolicValue(); result.computedFrom(computedFrom); break; case OR: case OR_ASSIGNMENT: result = new SymbolicValue.OrSymbolicValue(); result.computedFrom(computedFrom); break; case XOR: case XOR_ASSIGNMENT: result = new SymbolicValue.XorSymbolicValue(); result.computedFrom(computedFrom); break; default: result = createDefaultSymbolicValue(); result.computedFrom(computedFrom); } return result; }
From source file:com.twitter.graphjet.demo.TopHashtagsServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int k = 10;/*from w ww .j a v a 2 s. c o m*/ String p = request.getParameter("k"); if (p != null) { try { k = Integer.parseInt(p); } catch (NumberFormatException e) { // Just eat it, don't need to worry. } } PriorityQueue<NodeValueEntry> queue = new PriorityQueue<>(k); LongIterator iter = hashtags.keySet().iterator(); while (iter.hasNext()) { long hashtagHash = iter.nextLong(); int cnt = bigraph.getRightNodeDegree(hashtagHash); if (cnt == 1) continue; if (queue.size() < k) { queue.add(new NodeValueEntry(hashtagHash, cnt)); } else { NodeValueEntry peek = queue.peek(); if (cnt > peek.getValue()) { queue.poll(); queue.add(new NodeValueEntry(hashtagHash, cnt)); } } } if (queue.size() == 0) { response.getWriter().println("[]\n"); return; } NodeValueEntry e; List<String> entries = new ArrayList<>(queue.size()); while ((e = queue.poll()) != null) { // Note that we explicitly use id_str and treat the tweet id as a String. See: // https://dev.twitter.com/overview/api/twitter-ids-json-and-snowflake entries.add(String.format("{\"hashtag_str\": \"%s\", \"id\": %d, \"cnt\": %d}", hashtags.get(e.getNode()), e.getNode(), e.getValue())); } response.setStatus(HttpStatus.OK_200); response.getWriter().println("[\n" + JOINER.join(Lists.reverse(entries)) + "\n]"); }
From source file:com.twitter.graphjet.demo.TopUsersServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int k = 10;//from w w w . j av a2s. com String p = request.getParameter("k"); if (p != null) { try { k = Integer.parseInt(p); } catch (NumberFormatException e) { // Just eat it, don't need to worry. } } PriorityQueue<NodeValueEntry> queue = new PriorityQueue<>(k); LongIterator iter = users.keySet().iterator(); while (iter.hasNext()) { long user = iter.nextLong(); int cnt = bigraph.getLeftNodeDegree(user); if (cnt == 1) continue; if (queue.size() < k) { queue.add(new NodeValueEntry(user, cnt)); } else { NodeValueEntry peek = queue.peek(); // Break ties by preferring higher userid (i.e., more recent user) if (cnt > peek.getValue() || (cnt == peek.getValue() && user > peek.getNode())) { queue.poll(); queue.add(new NodeValueEntry(user, cnt)); } } } if (queue.size() == 0) { response.getWriter().println("[]\n"); return; } NodeValueEntry e; List<String> entries = new ArrayList<>(queue.size()); while ((e = queue.poll()) != null) { // Note that we explicitly use id_str and treat the tweet id as a String. See: // https://dev.twitter.com/overview/api/twitter-ids-json-and-snowflake entries.add(String.format("{\"id_str\": \"%d\", \"cnt\": %d}", e.getNode(), e.getValue())); } response.setStatus(HttpStatus.OK_200); response.getWriter().println("[\n" + JOINER.join(Lists.reverse(entries)) + "\n]"); }
From source file:c5db.log.InRamLog.java
@Override public synchronized long getLastConfigurationIndex() { for (LogEntry entry : Lists.reverse(log)) { if (entry.getQuorumConfiguration() != null) { return entry.getIndex(); }/*from w ww. j a v a 2s. c o m*/ } return 0; }