|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.lang.Number
edu.uci.ics.jung.utils.MutableDouble
The MutableDouble class wraps a value of the primitive type double in a mutable object. An object of type MutableDouble contains a single field whose type is double.
This allows the system to not pile up large
sets of temporary "numbers" and reduces object creation when doing math.
In addition, this class provides several methods for converting a double to a String and a String to a double.
Warning: It is important to not modify Mutable values when they are in a sorted data structure, such as a TreeSet! They will fall out of order and cause the set to be inconsistent
| Constructor Summary | |
MutableDouble()
Constructs a new MutableDouble with a default value of 0 assigned |
|
MutableDouble(double initialValue)
Constructs a new MutableDouble with the input value. |
|
| Method Summary | |
MutableDouble |
add(double value)
Increases the double's value by value. |
int |
compareTo(java.lang.Object o)
|
double |
doubleValue()
Returns the value as a double, accomplished by returning the primitive contained double. |
boolean |
equals(java.lang.Object obj)
Compares this object to the specified object. |
float |
floatValue()
Returns the nearest float value, accomplished by casting the contained double to float. |
int |
hashCode()
Returns a hashcode for this Integer. |
int |
intValue()
Returns the floor integer value, accomplished by casting the contained double to int. |
long |
longValue()
Returns the floor integer value as a long, accomplished by casting the contained double to long. |
void |
setDoubleValue(double newDouble)
Sets the double value to a new value. |
MutableDouble |
subtract(double value)
Decreases the double's value by value. |
java.lang.String |
toString()
Uses the default String converter to return the value of this as a string. |
| Methods inherited from class java.lang.Number |
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public MutableDouble()
public MutableDouble(double initialValue)
| Method Detail |
public int intValue()
int.
public long longValue()
long.
public float floatValue()
float.
public double doubleValue()
public int compareTo(java.lang.Object o)
compareTo in interface java.lang.ComparableComparablepublic boolean equals(java.lang.Object obj)
true if and only if the argument is not
null and is an MutableDouble object that contains
the same double value as this object.
obj - the object to compare with.
true if the objects are the same;
false otherwise.public int hashCode()
public void setDoubleValue(double newDouble)
public MutableDouble add(double value)
doubleValue() + value.
value - the amount to add
public MutableDouble subtract(double value)
doubleValue() - value.
value - the amount to subtract
public java.lang.String toString()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||