-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPreOrder.java
47 lines (42 loc) · 1.01 KB
/
PreOrder.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.binary.relation.homogeneous;
/**
* @param <T>
*
* Notably, a {@link PreOrder} is not required to be symmetric.
*
* @see https://en.wikipedia.org/wiki/Preorder
*/
public interface PreOrder<T> {
/**
* @param that
* @return true exactly if this <= that
*/
boolean leq(T that);
public interface Directed<T>
extends PreOrder<T> {
/**
* @param that
* @return an upper bound value F such that this <= F and that <= F
*/
T upperBound(T that);
}
/**
* A pre-order which is guaranteed by the implementor to be anti-symmetric.
*
* I.e. a <= b && b <= a => a == b
*
* @param <T>
*
* @see https://en.wikipedia.org/wiki/Partially_ordered_set#Partial_orders
*/
public interface AntiSymmetric<T extends AntiSymmetric<T>>
extends
PreOrder<T>, Identity<T>
{
@SuppressWarnings("unchecked")
@Override
default boolean eq(T that) {
return leq(that) && that.leq((T) this);
}
}
}