Assuming that I constructed TreeSet with anonymous Comparator as follows:
private TreeSet<Counter> mySet =
new TreeSet<Counter>(
new Comparator<Counter>(){
@Override
public int compare(Counter c1, Counter c2) {
// some weird comparison logic here...
}
});
now I want to get a portion of the TreeSet equal or greater than someCounter as follows:
mySet.tailSet(someCounter);
How can I make the portion of the TreeSet returned by tailSet() be based on the original comparator mySet was constructed with and not to get just an ordered set ordered by natural order?
It already is based on the comparator you created the
TreeSetwith.