|
||||||||||
| 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
public class 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(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(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. |
String |
toString()
|
| 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 MutableInteger()
public MutableInteger(int initialValue)
| Method Detail |
|---|
public int intValue()
intValue in class Numberpublic long longValue()
longValue in class Numberpublic float floatValue()
floatValue in class Numberpublic double doubleValue()
doubleValue in class Numberpublic 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(Object o)
compareTo in interface ComparableComparablepublic boolean equals(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.
equals in class Objectobj - the object to compare with.
true if the objects are the same;
false otherwise.public int hashCode()
hashCode in class Objectpublic void setInteger(int newInteger)
public MutableInteger increment()
public void decrement()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||