public final class Ord<A>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static Ord<java.math.BigDecimal> |
bigdecimalOrd
An order instance for the
BigDecimal type. |
static Ord<java.math.BigInteger> |
bigintOrd
An order instance for the
BigInteger type. |
static Ord<java.lang.Boolean> |
booleanOrd
An order instance for the
boolean type. |
static Ord<java.lang.Byte> |
byteOrd
An order instance for the
byte type. |
static Ord<java.lang.Character> |
charOrd
An order instance for the
char type. |
static Ord<java.lang.Double> |
doubleOrd
An order instance for the
double type. |
static Ord<java.lang.Float> |
floatOrd
An order instance for the
float type. |
static Ord<java.lang.Integer> |
intOrd
An order instance for the
int type. |
static Ord<java.lang.Long> |
longOrd
An order instance for the
long type. |
F<A,F<A,A>> |
max
A function that returns the greater of its two arguments.
|
F<A,F<A,A>> |
min
A function that returns the lesser of its two arguments.
|
static Ord<Natural> |
naturalOrd
An order instance for the
Natural type. |
static Ord<Ordering> |
orderingOrd
An order instance for the
Ordering type. |
static Ord<java.lang.Short> |
shortOrd
An order instance for the
short type. |
static Ord<java.lang.StringBuffer> |
stringBufferOrd
An order instance for the
StringBuffer type. |
static Ord<java.lang.StringBuilder> |
stringBuilderOrd
An order instance for the
StringBuffer type. |
static Ord<java.lang.String> |
stringOrd
An order instance for the
String type. |
static Ord<Unit> |
unitOrd
An order instance for the
Unit type. |
Modifier and Type | Method and Description |
---|---|
static <A> Ord<Array<A>> |
arrayOrd(Ord<A> oa)
An order instance for the
Array type. |
static <A extends java.lang.Comparable<A>> |
comparableOrd()
An order instance for the
Comparable interface. |
F<A,F<A,Ordering>> |
compare()
First-class ordering.
|
Ordering |
compare(A a1,
A a2)
Returns an ordering for the given arguments.
|
<B> Ord<B> |
contramap(F<B,A> f)
Maps the given function across this ord as a contra-variant functor.
|
static <A,B> Ord<Either<A,B>> |
eitherOrd(Ord<A> oa,
Ord<B> ob)
An order instance for the
Either type. |
boolean |
eq(A a1,
A a2)
Returns
true if the given arguments are equal, false otherwise. |
Equal<A> |
equal()
Returns an
Equal for this order. |
static <A> Ord<A> |
hashEqualsOrd()
An order instance that uses
Object.hashCode() and Object.equals(java.lang.Object) for computing
the order and equality. |
static <A> Ord<A> |
hashOrd()
An order instance that uses
Object.hashCode() for computing the order and equality,
thus objects returning the same hashCode are considered to be equals (check hashEqualsOrd()
for an additional check on Object.equals(Object) ). |
F<A,java.lang.Boolean> |
isGreaterThan(A a)
Returns a function that returns true if its argument is greater than than the argument to this method.
|
boolean |
isGreaterThan(A a1,
A a2)
Returns
true if the first given argument is greater than the second given
argument, false otherwise. |
F<A,java.lang.Boolean> |
isLessThan(A a)
Returns a function that returns true if its argument is less than the argument to this method.
|
boolean |
isLessThan(A a1,
A a2)
Returns
true if the first given argument is less than the second given argument,
false otherwise. |
boolean |
isLessThanOrEqualTo(A a1,
A a2)
Returns
true if the first given argument is less than or equal to the second given argument,
false otherwise. |
static <A> Ord<List<A>> |
listOrd(Ord<A> oa)
An order instance for the
List type. |
A |
max(A a1,
A a2)
Returns the greater of its two arguments.
|
Semigroup<A> |
maxSemigroup() |
A |
min(A a1,
A a2)
Returns the lesser of its two arguments.
|
Semigroup<A> |
minSemigroup() |
static <A> Ord<NonEmptyList<A>> |
nonEmptyListOrd(Ord<A> oa)
An order instance for the
NonEmptyList type. |
static <A> Ord<Option<A>> |
optionOrd(Ord<A> oa)
An order instance for the
Option type. |
static <A> Ord<A> |
ord(F<A,F<A,Ordering>> f)
Returns an order instance that uses the given equality test and ordering function.
|
static <A> Ord<P1<A>> |
p1Ord(Ord<A> oa)
An order instance for a product-1.
|
static <A,B> Ord<P2<A,B>> |
p2Ord(Ord<A> oa,
Ord<B> ob)
An order instance for a product-2, with the first factor considered most significant.
|
static <A,B> Ord<P2<A,B>> |
p2Ord1(Ord<A> oa) |
static <A,B> Ord<P2<A,B>> |
p2Ord2(Ord<B> ob) |
static <A,B,C> Ord<P3<A,B,C>> |
p3Ord(Ord<A> oa,
Ord<B> ob,
Ord<C> oc)
An order instance for a product-3, with the first factor considered most significant.
|
Ord<A> |
reverse() |
static <A> Ord<Set<A>> |
setOrd(Ord<A> oa)
An order instance for the
Set type. |
static <A> Ord<Stream<A>> |
streamOrd(Ord<A> oa)
An order instance for the
Stream type. |
java.util.Comparator<A> |
toComparator() |
static <A,B> Ord<Validation<A,B>> |
validationOrd(Ord<A> oa,
Ord<B> ob)
An order instance for the
Validation type. |
public static final Ord<java.lang.Boolean> booleanOrd
boolean
type.public static final Ord<java.lang.Byte> byteOrd
byte
type.public static final Ord<java.lang.Character> charOrd
char
type.public static final Ord<java.lang.Double> doubleOrd
double
type.public static final Ord<java.lang.Float> floatOrd
float
type.public static final Ord<java.lang.Integer> intOrd
int
type.public static final Ord<java.math.BigInteger> bigintOrd
BigInteger
type.public static final Ord<java.math.BigDecimal> bigdecimalOrd
BigDecimal
type.public static final Ord<java.lang.Long> longOrd
long
type.public static final Ord<java.lang.Short> shortOrd
short
type.public static final Ord<java.lang.String> stringOrd
String
type.public static final Ord<java.lang.StringBuffer> stringBufferOrd
StringBuffer
type.public static final Ord<java.lang.StringBuilder> stringBuilderOrd
StringBuffer
type.public F<A,F<A,Ordering>> compare()
public Ordering compare(A a1, A a2)
a1
- An instance to compare for ordering to another.a2
- An instance to compare for ordering to another.public boolean eq(A a1, A a2)
true
if the given arguments are equal, false
otherwise.a1
- An instance to compare for equality to another.a2
- An instance to compare for equality to another.true
if the given arguments are equal, false
otherwise.public <B> Ord<B> contramap(F<B,A> f)
f
- The function to map.public boolean isLessThan(A a1, A a2)
true
if the first given argument is less than the second given argument,
false
otherwise.a1
- An instance to compare for ordering to another.a2
- An instance to compare for ordering to another.true
if the first given argument is less than the second given argument,
false
otherwise.public boolean isLessThanOrEqualTo(A a1, A a2)
true
if the first given argument is less than or equal to the second given argument,
false
otherwise.a1
- An instance to compare for ordering to another.a2
- An instance to compare for ordering to another.true
if the first given argument is less than or equal to the second given argument,
false
otherwise.public boolean isGreaterThan(A a1, A a2)
true
if the first given argument is greater than the second given
argument, false
otherwise.a1
- An instance to compare for ordering to another.a2
- An instance to compare for ordering to another.true
if the first given argument is greater than the second given
argument, false
otherwise.public F<A,java.lang.Boolean> isLessThan(A a)
a
- A value to compare against.public F<A,java.lang.Boolean> isGreaterThan(A a)
a
- A value to compare against.public A max(A a1, A a2)
a1
- A value to compare with another.a2
- A value to compare with another.public A min(A a1, A a2)
a1
- A value to compare with another.a2
- A value to compare with another.public static <A> Ord<A> ord(F<A,F<A,Ordering>> f)
f
- The order function.public static <A> Ord<Option<A>> optionOrd(Ord<A> oa)
Option
type.oa
- Order across the element of the option.Option
type.public static <A,B> Ord<Either<A,B>> eitherOrd(Ord<A> oa, Ord<B> ob)
Either
type.public static <A,B> Ord<Validation<A,B>> validationOrd(Ord<A> oa, Ord<B> ob)
Validation
type.oa
- Order across the failing side of Validation
.ob
- Order across the succeeding side of Validation
.Validation
type.public static <A> Ord<List<A>> listOrd(Ord<A> oa)
List
type.oa
- Order across the elements of the list.List
type.public static <A> Ord<NonEmptyList<A>> nonEmptyListOrd(Ord<A> oa)
NonEmptyList
type.oa
- Order across the elements of the non-empty list.NonEmptyList
type.public static <A> Ord<Stream<A>> streamOrd(Ord<A> oa)
Stream
type.oa
- Order across the elements of the stream.Stream
type.public static <A> Ord<Array<A>> arrayOrd(Ord<A> oa)
Array
type.oa
- Order across the elements of the array.Array
type.public static <A> Ord<Set<A>> setOrd(Ord<A> oa)
Set
type.oa
- Order across the elements of the set.Set
type.public static <A> Ord<P1<A>> p1Ord(Ord<A> oa)
oa
- Order across the produced type.public static <A,B> Ord<P2<A,B>> p2Ord(Ord<A> oa, Ord<B> ob)
oa
- An order instance for the first factor.ob
- An order instance for the second factor.public static <A,B,C> Ord<P3<A,B,C>> p3Ord(Ord<A> oa, Ord<B> ob, Ord<C> oc)
oa
- An order instance for the first factor.ob
- An order instance for the second factor.oc
- An order instance for the third factor.public static <A extends java.lang.Comparable<A>> Ord<A> comparableOrd()
Comparable
interface.Comparable
interface.public static <A> Ord<A> hashOrd()
Object.hashCode()
for computing the order and equality,
thus objects returning the same hashCode are considered to be equals (check hashEqualsOrd()
for an additional check on Object.equals(Object)
).Object.hashCode()
.hashEqualsOrd()
public static <A> Ord<A> hashEqualsOrd()
Object.hashCode()
and Object.equals(java.lang.Object)
for computing
the order and equality. First the hashCode is compared, if this is equal, objects are compared
using Object.equals(java.lang.Object)
.Object.hashCode()
and Object.equals(java.lang.Object)
.public java.util.Comparator<A> toComparator()