All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class DataStructures.MyInteger

java.lang.Object
    |
    +----DataStructures.MyInteger

public final class MyInteger
extends Object
implements Comparable, Hashable
Wrapper class for use with generic data structures. Mimics Integer. In Java 1.2, you can use Integer if Comparable is needed.


Constructor Index

 o MyInteger()
Construct the MyInteger object with initial value 0.
 o MyInteger(int)
Construct the MyInteger object.

Method Index

 o compareTo(Comparable)
Implements the compareTo method.
 o equals(Object)
Implements the equals method.
 o hash(int)
Implements the hash method.
 o intValue()
Gets the stored int value.
 o toString()
Implements the toString method.

Constructors

 o MyInteger
public MyInteger()
Construct the MyInteger object with initial value 0.

 o MyInteger
public MyInteger(int x)
Construct the MyInteger object.

Parameters:
x - the initial value.

Methods

 o intValue
public int intValue()
Gets the stored int value.

Returns:
the stored value.
 o toString
public String toString()
Implements the toString method.

Returns:
the String representation.
Overrides:
toString in class Object
 o compareTo
public int compareTo(Comparable rhs)
Implements the compareTo method.

Parameters:
rhs - the other MyInteger object.
Returns:
0 if two objects are equal; less than zero if this object is smaller; greater than zero if this object is larger.
Throws: ClassCastException
if rhs is not a MyInteger.
 o equals
public boolean equals(Object rhs)
Implements the equals method.

Parameters:
rhs - the second MyInteger.
Returns:
true if the objects are equal, false otherwise.
Throws: ClassCastException
if rhs is not a MyInteger.
Overrides:
equals in class Object
 o hash
public int hash(int tableSize)
Implements the hash method.

Parameters:
tableSize - the hash table size.
Returns:
a number between 0 and tableSize-1.

All Packages  Class Hierarchy  This Package  Previous  Next  Index