|
|||||||||||
| 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.MutableInteger
The MutableInteger class wraps a value of the primitive type int in a mutable object. An object of type MutableInteger contains a single field whose type is int.
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 int to a String and a String to a int.
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 | |
MutableInteger()
Constructs a new MutableInteger with default value 0. |
|
MutableInteger(int initialValue)
|
|
| Method Summary | |
MutableInteger |
add(double value)
Increases the int's value by value. |
int |
compareTo(java.lang.Object o)
|
void |
decrement()
Subtracts one from the contained integer value. |
double |
doubleValue()
Returns the integer value of this object, expressed as a double. |
boolean |
equals(java.lang.Object obj)
Compares this object to the specified object. |
float |
floatValue()
Returns the integer value of this object, expressed as a float. |
int |
hashCode()
Returns a hashcode for this Integer. |
MutableInteger |
increment()
Adds one to the contained integer value. |
int |
intValue()
Returns the integer value of this object. |
long |
longValue()
Returns the integer value of this object, expressed as a long. |
void |
setInteger(int newInteger)
Sets the value of this object to newInteger. |
MutableInteger |
subtract(double value)
Increases the int's value by value. |
java.lang.String |
toString()
|
| 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 MutableInteger()
public MutableInteger(int initialValue)
| Method Detail |
public int intValue()
public long longValue()
public float floatValue()
public double doubleValue()
public MutableInteger add(double value)
(int) ( intValue() + value ) .
value - the amount to add
public MutableInteger subtract(double value)
(int) ( intValue() - value ) .
value - the amount to subtract
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 MutableInteger object that contains
the same int value as this object.
obj - the object to compare with.
true if the objects are the same;
false otherwise.public int hashCode()
public void setInteger(int newInteger)
public MutableInteger increment()
public void decrement()
public java.lang.String toString()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||