All Packages  Class Hierarchy  This Package  Previous  Next  Index  
Class Supporting.MyInteger
java.lang.Object
    |
    +----Supporting.MyInteger
- public final class MyInteger
- extends Object- implements Comparable, Hashable
Wrapper class for use with generic data structures.
Mimics Integer.
 
 MyInteger() MyInteger()
- Construct the MyInteger object with initial value 0.
 MyInteger(int) MyInteger(int)
- Construct the MyInteger object.
 
 compares(Comparable) compares(Comparable)
- Implements the compares method.
 equals(Object) equals(Object)
- Implements the equals method.
 hash(int) hash(int)
- Implements the hash method.
 intValue() intValue()
- Gets the stored int value.
 lessThan(Comparable) lessThan(Comparable)
- Implements the lessThan method.
 toString() toString()
- Implements the toString method.
 
 MyInteger
MyInteger
public MyInteger()
- Construct the MyInteger object with initial value 0.
 
 MyInteger
MyInteger
public MyInteger(int x)
- Construct the MyInteger object.
 
- 
- Parameters:
- x - the initial value.
 
 
 intValue
intValue
public int intValue()
- Gets the stored int value.
 
- 
- Returns:
- the stored value.
 
 toString
toString
public String toString()
- Implements the toString method.
 
- 
- Returns:
- the String representation.
- Overrides:
- toString in class Object
 
 compares
compares
public int compares(Comparable rhs)
- Implements the compares 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.
 
 lessThan
lessThan
public boolean lessThan(Comparable rhs)
- Implements the lessThan method.
 
- 
- Parameters:
- rhs - the second MyInteger.
- Returns:
- true if this object is smaller;
false otherwise.
- Throws:
ClassCastException
- if rhs is not
a MyInteger.
 
 equals
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
 
 hash
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