-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Primitive Comparator.comparing(keyExtractor), like standrad Comparator #313
base: master
Are you sure you want to change the base?
Conversation
Mmmmhh no this will generate a copy of all functions in each generated file. |
That is the intention. java.util.Comparator define 5 'comparing' static functions: static <T, U extends Comparable<U>> Comparator<T> comparing(Function<T, U> keyExtractor);
static <T, U> Comparator<T> comparing(Function<T, U> keyExtractor, Comparator<U> keyComparator);
static <T> Comparator<T> comparingInt(ToIntFunction<T> keyExtractor);
static <T> Comparator<T> comparingLong(ToLongFunction<T> keyExtractor);
static <T> Comparator<T> comparingDouble(ToDoubleFunction<T> keyExtractor); These methods create a comparator that extract comparable/obj/int/long/double from the T instances and compare them. I want to provide 5 such functions for each primitive comparator: IntComparator comparingObj(Int2ObjFunction<Comparable> keyExtractor);
IntComparator comparingObj(Int2ObjFunction<U> keyExtractor, Comparator<U> keyComparator);
IntComparator comparingInt(Int2IntFunction keyExtractor);
IntComparator comparingLong(Int2LongFunction keyExtractor);
IntComparator comparingDouble(Int2DoubleFunction keyExtractor);
ShortComparator comparingObj(Short2ObjFunction<Comparable> keyExtractor);
ShortComparator comparingObj(Short2ObjFunction<U> keyExtractor, Comparator<U> keyComparator);
ShortComparator comparingInt(Short2IntFunction keyExtractor);
... |
@vigna what you think? |
It seems Ok, but I'm in the middle of a deadline and unfortunately I don't have any bandwidth left. I'll be able to check this in a couple of weeks... |
Ok, but is it necessary to name it comparingObj? Can't it just be named comparing? Or some ambiguity arises? |
And, it would be nice to have a few unit tests covering the code. |
d1fd26e
to
c031bae
Compare
@vigna Renamed |
#312