|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A PoComparable
is an object which can be
partially ordered. Given any two PoComparable x,
y
, the following are the possible cases and the rules under
which they apply:
1. Objects are equal
Mathematically, a partial ordering relationship must be antisymmetric, which means that:
x.equals(y)
implies (x.lessThan(y)
andx.greaterThan(y)
)
To simplify implementations, however, the contract of a
PoComparable
is weakened to state that:
x.equals(y)
implies (x.lessThan(y)
andx.greaterThan(y)
are undefined)
2. Objects are unequal but can be compared
If !x.equals(y)
then either
x.lessThan(y)
or x.greaterThan(y)
may be
true, but not both.
3. Objects are unrelated
If !x.equals(y)
, a third case is possible where
neither x.lessThan(y)
nor
x.greaterThan(y)
is true; this means that
x
and y
are unrelated. This distinguishes
a partial ordering from a total ordering.
Comparable
Method Summary | |
boolean |
equals(Object x)
Determine if an object is equal to this one. |
boolean |
greaterThan(Object x)
Determine if this object is greater than another one. |
boolean |
lessThan(Object x)
Determine if this object is less than another one. |
Method Detail |
public boolean greaterThan(Object x)
x
- the object to which this object will be compared.true
if this object is greater than
x
; false
otherwise.public boolean lessThan(Object x)
x
- the object to which this object will be compared.true
if this object is less than
x
; false
otherwise.public boolean equals(Object x)
equals
in class Object
x
- the object to which this object will be compared.true
if this object is equal to
x
; false
otherwise.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |