Tabnine Logo
Collections.reverse
Code IndexAdd Tabnine to your IDE (free)

How to use
reverse
method
in
java.util.Collections

Best Java code snippets using java.util.Collections.reverse (Showing top 20 results out of 21,618)

Refine searchRefine arrow

  • List.add
  • List.size
  • List.get
  • Collections.sort
  • ArrayList.<init>
origin: jenkinsci/jenkins

/**
 * Reverses a collection so that it can be easily walked in reverse order.
 * @since 1.525
 */
public static <T> Iterable<T> reverse(Collection<T> collection) {
  List<T> list = new ArrayList<T>(collection);
  Collections.reverse(list);
  return list;
}
origin: JakeWharton/butterknife

Type(ResourceMethod... methods) {
 List<ResourceMethod> methodList = new ArrayList<>(methods.length);
 Collections.addAll(methodList, methods);
 Collections.sort(methodList);
 Collections.reverse(methodList);
 this.methods = ImmutableList.copyOf(methodList);
}
origin: stackoverflow.com

 Collections.sort(testList);
Collections.reverse(testList);
origin: ysc/QuestionAnsweringSystem

public List<CandidateAnswer> getTopNCandidateAnswer(int topN) {
  //按CandidateAnswer的分值排序,返回topN
  List<CandidateAnswer> result = new ArrayList<>();
  Collections.sort(candidateAnswers);
  Collections.reverse(candidateAnswers);
  int len = candidateAnswers.size();
  if (topN > len) {
    topN = len;
  }
  for (int i = 0; i < candidateAnswers.size(); i++) {
    result.add(candidateAnswers.get(i));
  }
  return result;
}
origin: google/guava

@Override
public Iterable<E> order(List<E> insertionOrder) {
 List<E> list = new ArrayList<E>();
 for (E e : delegate.order(insertionOrder)) {
  list.add(e);
 }
 Collections.reverse(list);
 return list;
}
origin: konsoletyper/teavm

private static String commonSuperClass(ClassReaderSource classSource, String a, String b) {
  if (a.equals(b)) {
    return a;
  }
  List<String> firstPath = pathToRoot(classSource, a);
  List<String> secondPath = pathToRoot(classSource, b);
  Collections.reverse(firstPath);
  Collections.reverse(secondPath);
  int min = Math.min(firstPath.size(), secondPath.size());
  for (int i = 1; i < min; ++i) {
    if (!firstPath.get(i).equals(secondPath.get(i))) {
      return firstPath.get(i - 1);
    }
  }
  return firstPath.get(0);
}
origin: stanfordnlp/CoreNLP

public static List<Mention> getOrderedAntecedents(
  Mention m,
  int antecedentSentence,
  int mPosition,
  List<List<Mention>> orderedMentionsBySentence,
  Dictionaries dict) {
 List<Mention> orderedAntecedents = new ArrayList<>();
 // ordering antecedents
 if (antecedentSentence == m.sentNum) {   // same sentence
  orderedAntecedents.addAll(orderedMentionsBySentence.get(m.sentNum).subList(0, mPosition));
  if(dict.relativePronouns.contains(m.spanToString())) Collections.reverse(orderedAntecedents);
  else {
   orderedAntecedents = sortMentionsByClause(orderedAntecedents, m);
  }
 } else {    // previous sentence
  orderedAntecedents.addAll(orderedMentionsBySentence.get(antecedentSentence));
 }
 return orderedAntecedents;
}
origin: spring-projects/spring-framework

AnnotationAttributes result = new AnnotationAttributes(attributesList.get(0));
List<String> annotationTypes = new ArrayList<>(attributesMap.keySet());
Collections.reverse(annotationTypes);
    Set<String> metaAnns = metaAnnotationMap.get(currentAnnotationType);
    if (metaAnns != null && metaAnns.contains(annotationName)) {
      AnnotationAttributes currentAttributes = currentAttributesList.get(0);
      for (String overridableAttributeName : overridableAttributeNames) {
        Object value = currentAttributes.get(overridableAttributeName);
origin: CalebFenton/simplify

private void replaceFieldGet() {
  List<Integer> getAddresses = new LinkedList<>();
  for (int address : addresses) {
    if (canReplaceFieldGet(address)) {
      getAddresses.add(address);
    }
  }
  if (0 == getAddresses.size()) {
    return;
  }
  madeChanges = true;
  unreflectedFieldCount += getAddresses.size();
  Collections.reverse(getAddresses);
  for (int address : getAddresses) {
    BuilderInstruction replacement = buildFieldGetReplacement(address);
    removeMoveResultIfNecessary(address);
    manipulator.replaceInstruction(address, replacement);
  }
}
origin: google/guava

void calculateNextPermutation() {
 int j = findNextJ();
 if (j == -1) {
  nextPermutation = null;
  return;
 }
 int l = findNextL(j);
 Collections.swap(nextPermutation, j, l);
 int n = nextPermutation.size();
 Collections.reverse(nextPermutation.subList(j + 1, n));
}
origin: opentripplanner/OpenTripPlanner

rides.add(ride);
Collections.reverse(rides);
rides.get(0).accessStats = new Stats();
rides.get(0).accessDist = 0;
  transit.add(segment);
  stats.add(segment.walkTime);
  if(segment.waitStats != null) stats.add(segment.waitStats);
origin: stanfordnlp/CoreNLP

/**
 * Returns the current stack as a list
 */
public List<T> asList() {
 List<T> result = Generics.newArrayList(size);
 TreeShapedStack<T> current = this;
 for (int index = 0; index < size; ++index) {
  result.add(current.data);
  current = current.pop();
 }
 Collections.reverse(result);
 return result;
}
origin: stanfordnlp/CoreNLP

/**
 * Removes all entries from c except for the top {@code num}.
 */
public static <E extends Comparable<E>> void retainTopKeyComparable(Counter<E> c, int num) {
 int numToPurge = c.size() - num;
 if (numToPurge <= 0) {
  return;
 }
 List<E> l = Counters.toSortedListKeyComparable(c);
 Collections.reverse(l);
 for (int i = 0; i < numToPurge; i++) {
  c.remove(l.get(i));
 }
}
origin: apache/incubator-dubbo

  _writeReplace.setAccessible(true);
List primitiveFields = new ArrayList();
List compoundFields = new ArrayList();
        || (field.getType().getName().startsWith("java.lang.")
        && !field.getType().equals(Object.class)))
      primitiveFields.add(field);
    else
      compoundFields.add(field);
List fields = new ArrayList();
fields.addAll(primitiveFields);
fields.addAll(compoundFields);
Collections.reverse(fields);
_fields = new Field[fields.size()];
fields.toArray(_fields);
origin: square/javapoet

 /** Returns all enclosing classes in this, outermost first. */
 private List<ClassName> enclosingClasses() {
  List<ClassName> result = new ArrayList<>();
  for (ClassName c = this; c != null; c = c.enclosingClassName) {
   result.add(c);
  }
  Collections.reverse(result);
  return result;
 }
}
origin: spring-cloud/spring-cloud-gateway

/**
 * The X-Forwarded-For header contains a comma separated list of IP addresses. This
 * method parses those IP addresses into a list. If no X-Forwarded-For header is
 * found, an empty list is returned. If multiple X-Forwarded-For headers are found, an
 * empty list is returned out of caution.
 * @return The parsed values of the X-Forwarded-Header.
 */
@Override
public InetSocketAddress resolve(ServerWebExchange exchange) {
  List<String> xForwardedValues = extractXForwardedValues(exchange);
  Collections.reverse(xForwardedValues);
  if (!xForwardedValues.isEmpty()) {
    int index = Math.min(xForwardedValues.size(), maxTrustedIndex) - 1;
    return new InetSocketAddress(xForwardedValues.get(index), 0);
  }
  return defaultRemoteIpResolver.resolve(exchange);
}
origin: stackoverflow.com

 ArrayList aList = new ArrayList();
//Add elements to ArrayList object
aList.add("1");
aList.add("2");
aList.add("3");
aList.add("4");
aList.add("5");
Collections.reverse(aList);
System.out.println("After Reverse Order, ArrayList Contains : " + aList);
origin: stanfordnlp/CoreNLP

 Map<Integer, CorefCluster> corefClusters,
 Dictionaries dict) {
List<Mention> orderedAntecedents = new ArrayList<>();
  orderedAntecedents = sortMentionsForPronoun(orderedAntecedents, m1, true);
 if(dict.relativePronouns.contains(m1.spanToString())) Collections.reverse(orderedAntecedents);
} else {    // previous sentence
 orderedAntecedents.addAll(orderedMentionsBySentence.get(antecedentSentence));
origin: spring-projects/spring-framework

List<ContextConfigurationAttributes> reversedList = new ArrayList<>(list);
Collections.reverse(reversedList);
Class<?> declaringClass = reversedList.get(0).getDeclaringClass();
origin: stanfordnlp/CoreNLP

/**
 * A List of the keys in c, sorted from highest count to lowest.
 *
 * @return A List of the keys in c, sorted from highest count to lowest.
 */
public static <E extends Comparable<E>> List<E> toSortedListKeyComparable(Counter<E> c) {
 List<E> l = new ArrayList<>(c.keySet());
 Comparator<E> comp = toComparatorWithKeys(c);
 Collections.sort(l, comp);
 Collections.reverse(l);
 return l;
}
java.utilCollectionsreverse

Javadoc

Modifies the specified List by reversing the order of the elements.

Popular methods of Collections

  • emptyList
    Returns the empty list (immutable). This list is serializable.This example illustrates the type-safe
  • sort
  • singletonList
    Returns an immutable list containing only the specified object. The returned list is serializable.
  • unmodifiableList
    Returns an unmodifiable view of the specified list. This method allows modules to provide users with
  • emptyMap
    Returns the empty map (immutable). This map is serializable.This example illustrates the type-safe w
  • emptySet
    Returns the empty set (immutable). This set is serializable. Unlike the like-named field, this metho
  • unmodifiableMap
    Returns an unmodifiable view of the specified map. This method allows modules to provide users with
  • singleton
    Returns an immutable set containing only the specified object. The returned set is serializable.
  • unmodifiableSet
    Returns an unmodifiable view of the specified set. This method allows modules to provide users with
  • singletonMap
    Returns an immutable map, mapping only the specified key to the specified value. The returned map is
  • addAll
    Adds all of the specified elements to the specified collection. Elements to be added may be specifie
  • unmodifiableCollection
    Returns an unmodifiable view of the specified collection. This method allows modules to provide user
  • addAll,
  • unmodifiableCollection,
  • shuffle,
  • enumeration,
  • list,
  • synchronizedMap,
  • synchronizedList,
  • reverseOrder,
  • emptyIterator

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (Timer)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • findViewById (Activity)
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now