Open barakugav opened 10 months ago
The standard java.util.Comparator provide few static methods to create a Comparator from an key extractor function:
static <T, U extends Comparable<U>> Comparator<T> comparing(Function<T, U> keyExtractor); static <T, U extends Comparable<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);
I find these functions very useful.
Will this be a nice additions to the primitive comparators in fastutil as well? For example in IntComparator. If so, I will be willing to add it :)
Ok but you need to understand the macro system and write a generic implementation...
The standard java.util.Comparator provide few static methods to create a Comparator from an key extractor function:
I find these functions very useful.
Will this be a nice additions to the primitive comparators in fastutil as well? For example in IntComparator. If so, I will be willing to add it :)