Comparable<T> interface
can be used with TreeSet and TreeMap
int compareTo(Object)
equals() for such a class as
follows:
class Foo implements Comparable<Foo> {
private int value;
public boolean equals(Object other) {
if (other instanceof Foo) {
return (compareTo((Foo)other) == 0);
} else {
return false;
}
}
public int compareTo(Foo other) {
return value - other.value;
}
}