We have a collection of objects, each object has an integer ID and a timestamp. We want to be able to search for duplicates and update the collection based on the ID.
But we also want to be able to take a "slice" of the collection, for instance finding every object with a timestamp after a given time. So we also want to sort on the timestamp.
We're using a TreeMap, which at first seemed to give us what we wanted. But because the TreeMap (and everything deriving from SortedSet) only uses compareTo() and ignores the equals() method, we find that searching for duplicates based on ID doesn't work. Our compareTo() method tries to allow for both conditions (searching on ID OR timestamp) but ultimately is large and ugly and doesn't actually work. :)
This collection could grow very large, so of course we want as fast as possible searching / sorting / inserting.