public interface LongComparator
QuickSort.sort
)
to allow precise control over the sort order.
The purpose of this function is to allow non-trivial ordering of longs which depend on some external data. For example when longs are some identifiers (pseudo-references) of actual data.
Modifier and Type | Method and Description |
---|---|
int |
compare(long i1,
long i2)
Compares its two arguments for order.
|
static <K extends Comparable<? super K>> |
comparing(LongFunction<? extends K> keyExtractor)
Accepts a function that extracts a comparable sort, and returns
a comparator that compares by an extracted comparable sort key.
|
static <K> LongComparator |
comparing(LongFunction<? extends K> keyExtractor,
Comparator<? super K> keyComparator)
Accepts a function that extracts a sort key and a sort key comparator, and returns
a comparator that compares by an extracted sort key using the specified sort key comparator.
|
static LongComparator |
comparingDouble(LongToDoubleFunction keyExtractor)
Accepts a function that extracts a double sort key, and returns
a comparator that compares by an extracted double sort key.
|
static LongComparator |
comparingInt(LongToIntFunction keyExtractor)
Accepts a function that extracts an int sort key, and returns
a comparator that compares by an extracted int sort key.
|
static LongComparator |
comparingLong(LongUnaryOperator keyExtractor)
Accepts a function that extracts a long sort key, and returns
a comparator that compares by an extracted long sort key.
|
default LongComparator |
reversed()
Returns a comparator that imposes the reverse ordering of this comparator.
|
default LongComparator |
thenComparing(LongComparator other)
Returns a lexicographic-order comparator with another comparator.
|
default <K extends Comparable<? super K>> |
thenComparing(LongFunction<? extends K> keyExtractor)
Returns a lexicographic-order comparator with a function that extracts a comparable sort key.
|
default <K> LongComparator |
thenComparing(LongFunction<? extends K> keyExtractor,
Comparator<? super K> keyComparator)
Returns a lexicographic-order comparator with a function that extracts
a sort key to be compared with the given sort key comparator.
|
default LongComparator |
thenComparingDouble(LongToDoubleFunction keyExtractor)
Returns a lexicographic-order comparator with a function that extracts a double sort key.
|
default LongComparator |
thenComparingInt(LongToIntFunction keyExtractor)
Returns a lexicographic-order comparator with a function that extracts an int sort key.
|
default LongComparator |
thenComparingLong(LongUnaryOperator keyExtractor)
Returns a lexicographic-order comparator with a function that extracts a long sort key.
|
int compare(long i1, long i2)
i1
- the first long to be compared.i2
- the second long to be compared.default LongComparator reversed()
default LongComparator thenComparing(LongComparator other)
compare(i1, i2) == 0
,
then other comparator is used to determine the order.
The returned comparator is serializable if the specified comparator is also serializable.
other
- the other comparator to be used when this comparator compares two longs that are equal.NullPointerException
- if the argument is null.default <K> LongComparator thenComparing(LongFunction<? extends K> keyExtractor, Comparator<? super K> keyComparator)
This default implementation delegates to
expression.thenComparing
(comparing
(keyExtractor, keyComparator))
K
- the type of the sort key.keyExtractor
- the function used to extract the sort key.keyComparator
- the comparator used to compare the sort key.NullPointerException
- if either argument is null.default <K extends Comparable<? super K>> LongComparator thenComparing(LongFunction<? extends K> keyExtractor)
This default implementation delegates to
expression.thenComparing
(comparing
(keyExtractor))
K
- the type of the comparable sort key.keyExtractor
- the function used to extract the comparable sort key.NullPointerException
- if the argument is null.default LongComparator thenComparingInt(LongToIntFunction keyExtractor)
This default implementation delegates to
expression.thenComparing
(comparing
(keyExtractor))
keyExtractor
- the function used to extract the int sort key.NullPointerException
- if the argument is null.default LongComparator thenComparingLong(LongUnaryOperator keyExtractor)
This default implementation delegates to
expression.thenComparing
(comparing
(keyExtractor))
keyExtractor
- the function used to extract the long sort key.NullPointerException
- if the argument is null.default LongComparator thenComparingDouble(LongToDoubleFunction keyExtractor)
This default implementation delegates to
expression.thenComparing
(comparing
(keyExtractor))
keyExtractor
- the function used to extract the double sort key.NullPointerException
- if the argument is null.static <K> LongComparator comparing(LongFunction<? extends K> keyExtractor, Comparator<? super K> keyComparator)
The returned comparator is serializable if the specified function and comparator are both serializable.
K
- the type of the sort key.keyExtractor
- the function used to extract the sort key.keyComparator
- the comparator used to compare the sort key.NullPointerException
- if either argument is null.static <K extends Comparable<? super K>> LongComparator comparing(LongFunction<? extends K> keyExtractor)
The returned comparator is serializable if the specified function is also serializable.
K
- the type of the comparable sort key.keyExtractor
- the function used to extract the comparable sort key.NullPointerException
- if the argument is null.static LongComparator comparingInt(LongToIntFunction keyExtractor)
The returned comparator is serializable if the specified function is also serializable.
keyExtractor
- the function used to extract the int sort key.NullPointerException
- if the argument is null.static LongComparator comparingLong(LongUnaryOperator keyExtractor)
The returned comparator is serializable if the specified function is also serializable.
keyExtractor
- the function used to extract the long sort key.NullPointerException
- if the argument is null.static LongComparator comparingDouble(LongToDoubleFunction keyExtractor)
The returned comparator is serializable if the specified function is also serializable.
keyExtractor
- the function used to extract the double sort key.NullPointerException
- if the argument is null.Copyright © 2002–2025 Devexperts LLC. All rights reserved.