List of usage examples for com.google.common.collect Lists reverse
@CheckReturnValue public static <T> List<T> reverse(List<T> list)
From source file:org.obeonetwork.dsl.uml2.design.services.internal.SemanticElementsSwitch.java
public Collection<EObject> getSemanticElements(EObject cur) { semantics = Lists.newArrayList();//w w w . j av a2 s. c o m doSwitch(cur); /* * We are reversing as we want the first specific before. */ return Lists.reverse(semantics); }
From source file:org.apache.jackrabbit.oak.spi.commit.MoveTracker.java
public void addMove(@Nonnull String sourcePath, @Nonnull String destPath) { // calculate original source path String originalSource = sourcePath; for (MoveEntry me : Lists.reverse(entries)) { if (Text.isDescendantOrEqual(me.destPath, sourcePath)) { String relPath = PathUtils.relativize(me.destPath, sourcePath); if (!relPath.isEmpty()) { originalSource = me.sourcePath + '/' + relPath; } else { originalSource = me.sourcePath; }//w w w . java 2 s . c o m break; } } entries.add(new MoveEntry(originalSource, destPath)); }
From source file:org.gitools.plugins.mutex.sort.MutualExclusiveMatrixViewSorter.java
public static void sortByMutualExclusion(final Heatmap heatmap, String pattern, Set<String> values, boolean regExChecked, boolean applyToColumns, IProgressMonitor monitor, boolean showProgress) { HeatmapLayer layer = heatmap.getLayers().getTopLayer(); HeatmapDimension rows = heatmap.getRows(); HeatmapDimension columns = heatmap.getColumns(); if (applyToColumns) { rows = heatmap.getColumns();/*from w w w .j a v a 2 s . c o m*/ columns = heatmap.getRows(); } AggregationFunction function = new AggregationFunction(layer, NonNullCountAggregator.INSTANCE, columns, layer.getEventFunction()); IdentifiersPredicate<String> annotationResolver = new IdentifiersPredicate<String>(rows, values, pattern, rows.getAnnotations()); rows.sort(new MutualExclusiveComparator(heatmap, layer, rows, annotationResolver, function, monitor)); monitor.begin("Sorting rows...", values.size()); PropertyChangeListener[] listeners = columns.getPropertyChangeListeners(); if (!showProgress) { // Remove listeners to avoid heatmap refresh at each iteration for (PropertyChangeListener listener : listeners) { columns.removePropertyChangeListener(listener); } } IMatrixPosition position = heatmap.newPosition(); for (String row : Lists.reverse(Lists.newArrayList(rows))) { monitor.worked(1); if (monitor.isCancelled()) { break; } position.set(rows, row); if (!annotationResolver.apply(row, position)) { continue; } columns.sort(new MutualExclusiveSingleValueComparator(position, layer, columns, SortDirection.DESCENDING, layer.getEventFunction())); } if (!showProgress) { for (PropertyChangeListener listener : listeners) { columns.addPropertyChangeListener(listener); } // Force to fire the events columns.show(columns.toList()); } }
From source file:com.google.devtools.j2objc.gen.ObjectiveCSegmentedHeaderGenerator.java
@Override protected void generateFileHeader() { println("#include \"J2ObjC_header.h\""); newline();/*www. j a v a2s . c o m*/ printf("#pragma push_macro(\"INCLUDE_ALL_%s\")\n", varPrefix); printf("#ifdef RESTRICT_%s\n", varPrefix); printf("#define INCLUDE_ALL_%s 0\n", varPrefix); println("#else"); printf("#define INCLUDE_ALL_%s 1\n", varPrefix); println("#endif"); printf("#undef RESTRICT_%s\n", varPrefix); for (GeneratedType type : Lists.reverse(getOrderedTypes())) { printLocalIncludes(type); } pushIgnoreDeprecatedDeclarationsPragma(); // Print OCNI blocks Collection<String> nativeBlocks = getGenerationUnit().getNativeHeaderBlocks(); if (!nativeBlocks.isEmpty()) { // Use a normal header guard for OCNI code outside of a type declaration. printf("\n#ifndef %s_H\n", varPrefix); printf("#define %s_H\n", varPrefix); for (String code : nativeBlocks) { print(code); } printf("\n#endif // %s_H\n", varPrefix); } }
From source file:io.prestosql.sql.gen.CoalesceCodeGenerator.java
@Override public BytecodeNode generateExpression(Signature signature, BytecodeGeneratorContext generatorContext, Type returnType, List<RowExpression> arguments) { List<BytecodeNode> operands = new ArrayList<>(); for (RowExpression expression : arguments) { operands.add(generatorContext.generate(expression)); }// w w w . j a v a 2 s.co m Variable wasNull = generatorContext.wasNull(); BytecodeNode nullValue = new BytecodeBlock().append(wasNull.set(constantTrue())) .pushJavaDefault(returnType.getJavaType()); // reverse list because current if statement builder doesn't support if/else so we need to build the if statements bottom up for (BytecodeNode operand : Lists.reverse(operands)) { IfStatement ifStatement = new IfStatement(); ifStatement.condition().append(operand).append(wasNull); // if value was null, pop the null value, clear the null flag, and process the next operand ifStatement.ifTrue().pop(returnType.getJavaType()).append(wasNull.set(constantFalse())) .append(nullValue); nullValue = ifStatement; } return nullValue; }
From source file:com.gdf.managedBean.ManageNotificationBean.java
/** * Initialize Notifications for the connected person *//* w w w . j av a 2s. c o m*/ public void findNotifications() { this.notificationsList = null; this.allNotificationsList = null; Long id = SessionBean.getUserId(); switch (SessionBean.getUserCategory()) { case Tenderer.userCategory: this.notificationsList = Lists.reverse(this.nb.findUnreadTendererNotification(id)); this.allNotificationsList = Lists.reverse(this.nb.findAllTendererNotification(id)); break; case Contractor.userCategory: this.notificationsList = Lists.reverse(this.nb.findUnreadContractorNotification(id)); this.allNotificationsList = Lists.reverse(this.nb.findAllContractorNotification(id)); break; case Moderator.userCategory: this.notificationsList = Lists.reverse(this.nb.findUnreadModeratorNotification(id)); this.allNotificationsList = Lists.reverse(this.nb.findAllModeratorNotification(id)); break; default: break; } // Update unread Notification existence this.unreadNotifications = this.notificationsList.size() > 0; }
From source file:org.gradoop.model.impl.algorithms.fsm.gspan.pojos.DFSCode.java
/** * determines vertex times of the rightmost DFS path * @return vertex times//from w ww. j ava2s. c o m */ public List<Integer> getRightMostPathVertexTimes() { Integer lastFromTime = null; Integer lastToTime = null; List<Integer> rightMostPath = null; for (DFSStep step : Lists.reverse(steps)) { if (step.isForward() || lastToTime == null && step.isLoop()) { int fromTime = step.getFromTime(); int toTime = step.getToTime(); if (lastToTime == null) { // graph consists of a single loop if (toTime == 0) { rightMostPath = Lists.newArrayList(toTime); } else { rightMostPath = Lists.newArrayList(toTime, fromTime); } } else if (lastFromTime == toTime) { rightMostPath.add(fromTime); } if (fromTime == 0) { break; } lastFromTime = fromTime; lastToTime = toTime; } } return rightMostPath; }
From source file:com.spotify.heroic.aggregation.Chain.java
@Override public AggregationInstance apply(final AggregationContext context) { ListIterator<Aggregation> it = chain.listIterator(chain.size()); AggregationContext current = context; final ImmutableSet.Builder<String> tags = ImmutableSet.builder(); final ImmutableList.Builder<AggregationInstance> chain = ImmutableList.builder(); while (it.hasPrevious()) { final AggregationInstance instance = it.previous().apply(current); tags.addAll(instance.requiredTags()); current = current.withRequiredTags(tags.build()); chain.add(instance);// ww w . j a v a 2 s . com } return ChainInstance.fromList(Lists.reverse(chain.build())); }
From source file:com.facebook.presto.sql.gen.CoalesceCodeGenerator.java
@Override public ByteCodeNode generateExpression(Signature signature, ByteCodeGeneratorContext generatorContext, Type returnType, List<RowExpression> arguments) { List<ByteCodeNode> operands = new ArrayList<>(); for (RowExpression expression : arguments) { operands.add(generatorContext.generate(expression)); }//w w w . ja v a 2 s .co m Variable wasNull = generatorContext.wasNull(); ByteCodeNode nullValue = new ByteCodeBlock().append(wasNull.set(constantTrue())) .pushJavaDefault(returnType.getJavaType()); // reverse list because current if statement builder doesn't support if/else so we need to build the if statements bottom up for (ByteCodeNode operand : Lists.reverse(operands)) { IfStatement ifStatement = new IfStatement(); ifStatement.condition().append(operand).append(wasNull); // if value was null, pop the null value, clear the null flag, and process the next operand ifStatement.ifTrue().pop(returnType.getJavaType()).append(wasNull.set(constantFalse())) .append(nullValue); nullValue = ifStatement; } return nullValue; }
From source file:com.google.javascript.jscomp.MoveFunctionDeclarations.java
@Override public void process(Node externs, Node root) { NodeTraversal.traverse(compiler, root, this); for (Entry<JSModule, List<Node>> entry : functions.entrySet()) { JSModule module = entry.getKey(); Node addingRoot = compiler.getNodeForCodeInsertion(module); for (Node n : Lists.reverse(entry.getValue())) { addingRoot.addChildToFront(n); }/*w w w .jav a 2 s . com*/ } }