-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTotallyOrdered.java
47 lines (41 loc) · 990 Bytes
/
TotallyOrdered.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.github.vincentk.dedekind.sets.ordered;
import com.github.vincentk.dedekind.sets.Cardinality;
import com.github.vincentk.dedekind.sets.binary.relation.homogeneous.TotalOrder;
/**
* Set with a total order.
*
* @param <C> cardinality
* @param <T> implementation type
*
* @see https://en.wikipedia.org/wiki/Partially_ordered_set#Derived_notions
*/
public interface TotallyOrdered<
E extends TotallyOrdered.Oe<E>,
C extends Cardinality,
T extends TotallyOrdered<E, C, T>
>
extends Lattice<E, C, T>{
interface Oe<T extends Oe<T>>
extends
Lattice.Le<T>, TotalOrder<T>
{
@Override
default boolean leq(T that) {
return compareTo(that) <= 0;
}
@SuppressWarnings("unchecked")
@Override
default T join(T that) {
return leq(that) ? that : (T) this;
}
@Override
default T upperBound(T that) {
return join(that);
}
@SuppressWarnings("unchecked")
@Override
default T meet(T that) {
return leq(that) ? (T) this : that;
}
}
}