Navigable & RedBlackTreeSet
This commit is contained in:
@@ -34,4 +34,26 @@ public interface COMPARATOR extends Comparator<CLASS_TYPE>
|
||||
Objects.requireNonNull(c);
|
||||
return (K, V) -> c.compare(KEY_TO_OBJ(K), KEY_TO_OBJ(V));
|
||||
}
|
||||
|
||||
public default COMPARATOR reversed() {
|
||||
return new Reversed(this);
|
||||
}
|
||||
|
||||
static class Reversed implements COMPARATOR
|
||||
{
|
||||
COMPARATOR original;
|
||||
|
||||
public Reversed(COMPARATOR original) {
|
||||
this.original = original;
|
||||
}
|
||||
|
||||
public int compare(KEY_TYPE o1, KEY_TYPE o2) {
|
||||
return original.compare(o2, o1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR reversed() {
|
||||
return original;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user