Closed barakugav closed 4 months ago
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.
@vigna Renamed comparingObj
to comparing
and added a few tests
https://github.com/vigna/fastutil/issues/312