public interface CharComparator
char values.
This is a @FunctionalInterface even though it isn't declared as one,
so that it can be used in Java 6+.
| Modifier and Type | Method and Description |
|---|---|
int |
compare(char c1,
char c2)
Compares
c1 and c2. |
int compare(char c1,
char c2)
c1 and c2. Returns a negative value to indicate
that c1 < c2, 0 to indicate that c1 == c2, and a positive
value to indicate that c1 > c2.
Implementations of this method must maintain the following invariants:
s(compare(x, y)) == -s(compare(y, x))
s(compare(x, y)) == s(compare(y, z)) →
s(compare(x, y)) == s(compare(x, z)) (transitivity)
compare(x, y) == 0 →
s(compare(x, z)) == s(compare(y, z)) ∀ z
where s(x) is defined as follows:
x < 0: -1
x == 0: 0
x > 0: 1
c1 - the first char to comparec2 - the second char to comparec1 is less than, equal to, or greater than c2,
respectivelyCopyright © 2021. All rights reserved.