|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--DataStructures.MyInteger
Wrapper class for use with generic data structures. Mimics Integer. In Java 1.2, you can use Integer if Comparable is needed.
Constructor Summary | |
MyInteger()
Construct the MyInteger object with initial value 0. |
|
MyInteger(int x)
Construct the MyInteger object. |
Method Summary | |
int |
compareTo(Comparable rhs)
Implements the compareTo method. |
boolean |
equals(java.lang.Object rhs)
Implements the equals method. |
int |
hash(int tableSize)
Implements the hash method. |
int |
intValue()
Gets the stored int value. |
java.lang.String |
toString()
Implements the toString method. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public MyInteger()
public MyInteger(int x)
x
- the initial value.Method Detail |
public int intValue()
public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(Comparable rhs)
compareTo
in interface Comparable
rhs
- the other MyInteger object.ClassCastException
- if rhs is not
a MyInteger.public boolean equals(java.lang.Object rhs)
equals
in class java.lang.Object
rhs
- the second MyInteger.ClassCastException
- if rhs is not
a MyInteger.public int hash(int tableSize)
hash
in interface Hashable
tableSize
- the hash table size.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |