public interface IntComparator
QuickSort.sort
)
to allow precise control over the sort order.
The purpose of this function is to allow non-trivial ordering of ints which depend on some external data. For example when ints are some identifiers (pseudo-references) of actual data.
Modifier and Type | Method and Description |
---|---|
int |
compare(int i1,
int i2)
Compares its two arguments for order.
|
static <K extends Comparable<? super K>> |
comparing(IntFunction<? 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> IntComparator |
comparing(IntFunction<? 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 IntComparator |
comparingDouble(IntToDoubleFunction keyExtractor)
Accepts a function that extracts a double sort key, and returns
a comparator that compares by an extracted double sort key.
|
static IntComparator |
comparingInt(IntUnaryOperator keyExtractor)
Accepts a function that extracts an int sort key, and returns
a comparator that compares by an extracted int sort key.
|
static IntComparator |
comparingLong(IntToLongFunction keyExtractor)
Accepts a function that extracts a long sort key, and returns
a comparator that compares by an extracted long sort key.
|
default IntComparator |
reversed()
Returns a comparator that imposes the reverse ordering of this comparator.
|
default IntComparator |
thenComparing(IntComparator other)
Returns a lexicographic-order comparator with another comparator.
|
default <K extends Comparable<? super K>> |
thenComparing(IntFunction<? extends K> keyExtractor)
Returns a lexicographic-order comparator with a function that extracts a comparable sort key.
|
default <K> IntComparator |
thenComparing(IntFunction<? 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 IntComparator |
thenComparingDouble(IntToDoubleFunction keyExtractor)
Returns a lexicographic-order comparator with a function that extracts a double sort key.
|
default IntComparator |
thenComparingInt(IntUnaryOperator keyExtractor)
Returns a lexicographic-order comparator with a function that extracts an int sort key.
|
default IntComparator |
thenComparingLong(IntToLongFunction keyExtractor)
Returns a lexicographic-order comparator with a function that extracts a long sort key.
|
int compare(int i1, int i2)
i1
- the first int to be compared.i2
- the second int to be compared.default IntComparator reversed()
default IntComparator thenComparing(IntComparator 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 ints that are equal.NullPointerException
- if the argument is null.default <K> IntComparator thenComparing(IntFunction<? 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>> IntComparator thenComparing(IntFunction<? 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 IntComparator thenComparingInt(IntUnaryOperator 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 IntComparator thenComparingLong(IntToLongFunction 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 IntComparator thenComparingDouble(IntToDoubleFunction 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> IntComparator comparing(IntFunction<? 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>> IntComparator comparing(IntFunction<? 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 IntComparator comparingInt(IntUnaryOperator 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 IntComparator comparingLong(IntToLongFunction 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 IntComparator comparingDouble(IntToDoubleFunction 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.