mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
API additions for compatibility with harmony's java.util package
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
package java.util;
|
||||
|
||||
public class Collections {
|
||||
|
||||
private Collections() { }
|
||||
|
||||
public static void shuffle(List list, Random random) {
|
||||
@ -84,6 +85,10 @@ public class Collections {
|
||||
return new IteratorEnumeration<T> (c.iterator());
|
||||
}
|
||||
|
||||
public static <T> Comparator<T> reverseOrder(Comparator<T> cmp) {
|
||||
return new ReverseComparator<T>(cmp);
|
||||
}
|
||||
|
||||
static class IteratorEnumeration<T> implements Enumeration<T> {
|
||||
private final Iterator<T> it;
|
||||
|
||||
@ -379,4 +384,20 @@ public class Collections {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ReverseComparator<T> implements Comparator<T> {
|
||||
|
||||
Comparator<T> cmp;
|
||||
|
||||
public ReverseComparator(Comparator<T> cmp) {
|
||||
this.cmp = cmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
return - cmp.compare(o1, o2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user