|
||||||||||
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
public class 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(Object o)
|
double |
doubleValue()
Returns the value as a double, accomplished by returning the primitive contained double. |
boolean |
equals(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. |
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 |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MutableDouble()
public MutableDouble(double initialValue)
Method Detail |
---|
public int intValue()
int
.
intValue
in class Number
public long longValue()
long
.
longValue
in class Number
public float floatValue()
float
.
floatValue
in class Number
public double doubleValue()
doubleValue
in class Number
public int compareTo(Object o)
compareTo
in interface Comparable
Comparable
public boolean equals(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.
equals
in class Object
obj
- the object to compare with.
true
if the objects are the same;
false
otherwise.public int hashCode()
hashCode
in class Object
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 String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |