How can I use tailSet() and headSet() for a NavigableSet<MyType>? And also implement own rules which elements would qualify for a tailset or headset?
Like:
class MyType {
String name;
String number;
}
Now if I have a type(“daniel”, “12”), I want to have all elements which are alphabetically before daniel, and number > 12. This would be my headset. The opposite would be the tailset.
(of course the comparisions do not make any sense, but you get what I’m trying to do).
Either let
MyTypeimplementComparableor use aNavigableSetwhich let you provide a separateComparatorlikeTreeSet.