public final class Weight extends Object implements Comparable<Weight>, Serializable
Long except that there are special values representing
positive infinity, negative infinity, positive epsilon (smallest positive
value), and negative epsilon (smallest negative value).| Modifier and Type | Method and Description |
|---|---|
Weight |
add(Weight w)
Creates a new weight with value equal to the sum of both weights.
|
int |
compareTo(Weight anotherWeight)
Compares two
Weight objects numerically. |
int |
compareToLong(long val) |
boolean |
equals(Object o) |
boolean |
greaterThan(long val)
Checks to see if this weight is greater than the given long value.
|
int |
hashCode() |
Weight |
invertSign()
Creates a new weight with the opposite sign.
|
boolean |
isEqual(long val)
Checks if this weight has the same value as the given long.
|
boolean |
isInfinity()
Checks if this weight has value of positive or negative infinity.
|
boolean |
isNegativeInfinity()
Checks if this weight has value of negative infinity.
|
boolean |
isPositiveInfinity()
Checks if this weight has value of positive infinity.
|
boolean |
lessThan(long val)
Checks to see if this weight is less than the given long value.
|
static Weight |
max(Weight w1,
Weight w2)
Gets the larger of the two given weights.
|
static Weight |
min(Weight w1,
Weight w2)
Gets the smaller of the two given weights.
|
Weight |
subtract(Weight w)
Creates a new weight the value equal to the difference between the two
weights.
|
String |
toString() |
long |
value()
Gets the value of this weight.
|
public long value()
Long.MAX_VALUE is
returned. If this weight has a value of negative infinity,
Long.MIN_VALUE is returned.public boolean greaterThan(long val)
val - a long value.public int compareToLong(long val)
public boolean lessThan(long val)
val - a long value.public boolean isEqual(long val)
val - a long.public Weight add(Weight w)
w - a weight.public Weight subtract(Weight w)
w - a weight.public static Weight max(Weight w1, Weight w2)
w1 - a weight. Cannot be null.w2 - a weight. Cannot be null.public static Weight min(Weight w1, Weight w2)
w1 - a weight. Cannot be null.w2 - a weight. Cannot be null.public boolean isPositiveInfinity()
true if it does, false if it
doesn't.public boolean isNegativeInfinity()
true if it does, false if it
doesn't.public boolean isInfinity()
true if it does, false if it
doesn't.public Weight invertSign()
Weight.public int compareTo(Weight anotherWeight)
Weight objects numerically.compareTo in interface Comparable<Weight>anotherWeight - the Weight to be compared.0 if this Weight is equal
to the argument Weight; a value less than
0 if this Weight is numerically
less than the argument Weight; and a value
greater than 0 if this Weight is
numerically greater than the argument Weight
(signed comparison).Copyright © 2012–2018 Emory University. All rights reserved.