diff options
| author | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-02-15 03:59:57 +0000 |
|---|---|---|
| committer | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-02-15 03:59:57 +0000 |
| commit | 75af6a50fe8e6c51781ce465f25987e5a531d30b (patch) | |
| tree | a50576b5ec7a46b8047189b60ad1a2b5cbaafc1a /libjava/java/util/Collections.java | |
| parent | e063cb39ffe4039e959613f39af6c5fe1d59409c (diff) | |
| download | gcc-75af6a50fe8e6c51781ce465f25987e5a531d30b.tar.gz | |
* java/util/TreeSet.java (clone): Call TreeMap.clone(), not
Object.clone().
* java/util/Collections.java (ReverseComparator): New static class.
(reverseOrder): Return static instance of ReverseComparator.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39705 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/util/Collections.java')
| -rw-r--r-- | libjava/java/util/Collections.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/libjava/java/util/Collections.java b/libjava/java/util/Collections.java index 9035e670a86..74efdec65bf 100644 --- a/libjava/java/util/Collections.java +++ b/libjava/java/util/Collections.java @@ -447,7 +447,6 @@ public class Collections // Create a minimal implementation of List return new AbstractList() { - public int size() { return n; @@ -487,22 +486,25 @@ public class Collections } } + static class ReverseComparator implements Comparator, Serializable + { + public int compare(Object a, Object b) + { + return -((Comparable) a).compareTo(b); + } + } + + static ReverseComparator rcInstance = new ReverseComparator(); + /** * Get a comparator that implements the reverse of natural ordering. This is * intended to make it easy to sort into reverse order, by simply passing * Collections.reverseOrder() to the sort method. The return value of this * method is Serializable. */ - // The return value isn't Serializable, because the spec is broken. public static Comparator reverseOrder() { - return new Comparator() - { - public int compare(Object a, Object b) - { - return -((Comparable) a).compareTo(b); - } - }; + return rcInstance; } /** |
