ValueType - The type of value to discriminate between.public class DefaultWeightedValueDiscriminant<ValueType> extends DefaultWeightedValue<ValueType> implements ValueDiscriminantPair<ValueType,java.lang.Double>
ValueDiscriminantPair that stores a double
as the discriminant. It extends DefaultWeightedValue and thus also
is a WeightedValue. This may be the most generally used
implementation of the ValueDiscriminantPair since it covers the
common case where the discriminant is a real value.DefaultWeightedValue.WeightComparator| Modifier and Type | Field and Description |
|---|---|
static double |
DEFAULT_WEIGHT
The default weight is 0.0.
|
valueweight| Constructor and Description |
|---|
DefaultWeightedValueDiscriminant()
Creates a
DefaultWeightedValueDiscriminant with a null value
and a weight of 0.0. |
DefaultWeightedValueDiscriminant(ValueType value,
double weight)
Creates a
DefaultWeightedValueDiscriminant with the given
value and weight. |
DefaultWeightedValueDiscriminant(WeightedValue<? extends ValueType> other)
Creates a new
DefaultWeightedValueDiscriminant whose weight
and value are taken from the given weighted value. |
| Modifier and Type | Method and Description |
|---|---|
static <ValueType> |
create(ValueType value,
double weight)
Convenience method for creating a new
DefaultWeightedValueDiscriminant with the given value and weight. |
static <ValueType> |
create(WeightedValue<? extends ValueType> other)
Convenience method for creating a new
DefaultWeightedValueDiscriminant with a shallow copy of the given
the given value and weight. |
java.lang.Double |
getDiscriminant()
Gets the discriminant for ordering instances of the same value.
|
ValueType |
getFirst()
Gets the first object.
|
java.lang.Double |
getSecond()
Gets the second object.
|
clone, getValue, setValuegetWeight, setWeightequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetValuepublic static final double DEFAULT_WEIGHT
public DefaultWeightedValueDiscriminant()
DefaultWeightedValueDiscriminant with a null value
and a weight of 0.0.public DefaultWeightedValueDiscriminant(ValueType value, double weight)
DefaultWeightedValueDiscriminant with the given
value and weight.value - The value for the pair.weight - The weight that is to be used as the discriminant.public DefaultWeightedValueDiscriminant(WeightedValue<? extends ValueType> other)
DefaultWeightedValueDiscriminant whose weight
and value are taken from the given weighted value.other - The other weighted value to make a shallow copy of.public java.lang.Double getDiscriminant()
ValueDiscriminantPairgetDiscriminant in interface ValueDiscriminantPair<ValueType,java.lang.Double>public java.lang.Double getSecond()
Pairpublic static <ValueType> DefaultWeightedValueDiscriminant<ValueType> create(ValueType value, double weight)
DefaultWeightedValueDiscriminant with the given value and weight.ValueType - The type of value to discriminate between.value - The value for the pair.weight - The weight that is to be used as the discriminant.public static <ValueType> DefaultWeightedValueDiscriminant<ValueType> create(WeightedValue<? extends ValueType> other)
DefaultWeightedValueDiscriminant with a shallow copy of the given
the given value and weight.ValueType - The type of value to discriminate between.other - The other value to make a shallow copy of.