Example usage for java.util Collections reverseOrder

List of usage examples for java.util Collections reverseOrder

Introduction

In this page you can find the example usage for java.util Collections reverseOrder.

Prototype

@SuppressWarnings("unchecked")
public static <T> Comparator<T> reverseOrder() 

Source Link

Document

Returns a comparator that imposes the reverse of the natural ordering on a collection of objects that implement the Comparable interface.

Usage

From source file:Main.java

public static void main(String[] args) {
    TreeSet<Integer> tree = new TreeSet<Integer>(Collections.reverseOrder());

    tree.add(12);//from  w ww.  ja  v a2  s .  c  om
    tree.add(13);
    tree.add(14);
    tree.add(15);
    tree.add(16);
    tree.add(17);

    // using comparator
    System.out.println(tree.comparator());

}

From source file:Main.java

public static void main(String[] args) {
    TreeMap<Integer, String> db = new TreeMap<Integer, String>(Collections.reverseOrder());
    db.put(1000, "1000");
    db.put(1011, "1011");
    db.put(1102, "1102");
    db.put(2023, "2023");
    db.put(2034, "2034");

    System.out.println(db);//w ww .  j  a  va2 s .  co m
}

From source file:Main.java

public static void main(String args[]) {

    PriorityQueue<Integer> prq = new PriorityQueue<Integer>(10, Collections.reverseOrder());

    for (int i = 0; i < 10; i++) {
        prq.add(i);/*from w  w  w.  ja  va 2  s. c  o m*/
    }
    System.out.println(prq);
}

From source file:Main.java

public static void main(String args[]) {

    PriorityQueue<Integer> prq = new PriorityQueue<Integer>(10, Collections.reverseOrder());

    for (int i = 0; i < 10; i++) {
        prq.add(i);/*from  w ww .j a  v  a 2  s  .  c  o m*/
    }

    PriorityQueue<Integer> p = new PriorityQueue<Integer>(prq);

    System.out.println(prq);
}

From source file:Main.java

public static void main(String... args) {
    List<String> names = Arrays.asList("XML", "Java", "HTML", "CSS");
    names.sort(Collections.reverseOrder());
    System.out.println(names);/*from   w ww.  j a v  a2  s.co m*/
}

From source file:Comp.java

public static void main(String args[]) throws Exception {
    String elements[] = { "Irish Setter", "Poodle", "English Setter", "Gordon Setter", "Pug" };
    Set set = new TreeSet(Collections.reverseOrder());
    for (int i = 0, n = elements.length; i < n; i++) {
        set.add(elements[i]);//from  w w w  . j a v a  2s .c  o m
    }
    System.out.println(set);
    System.out.println(((TreeSet) set).comparator());
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    Comparator comp = Collections.reverseOrder();
    String[] a = new String[] { "a", "b", "c" };
    Arrays.sort(a, comp);//  w  w w. j  a v a  2 s . co  m
    for (int i = 0, n = a.length; i < n; i++) {
        System.out.println(a[i]);
    }
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    String elements[] = { "A", "C", "D", "G", "F" };
    Set set = new TreeSet(Collections.reverseOrder());
    for (int i = 0, n = elements.length; i < n; i++) {
        set.add(elements[i]);//  w ww.  jav a2  s.  c o m
    }
    System.out.println(set);
    System.out.println(((TreeSet) set).comparator());
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    String elements[] = { "A", "C", "D", "G", "F" };
    TreeSet<String> set = new TreeSet<String>(Collections.reverseOrder());
    for (int i = 0, n = elements.length; i < n; i++) {
        set.add(elements[i]);/*www .  ja v a2 s .co  m*/
    }
    System.out.println(set);
    System.out.println(((TreeSet) set).comparator());
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    String elements[] = { "A", "C", "D", "G", "F" };
    Set set = new TreeSet(Collections.reverseOrder());
    for (int i = 0, n = elements.length; i < n; i++) {
        set.add(elements[i]);/*w w w  . j a v  a 2 s  .c o  m*/
    }
    System.out.println(set);
}