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()
- Construct the MyInteger object with initial value 0.
-
MyInteger(int)
- Construct the MyInteger object.
-
compares(Comparable)
- Implements the compares method.
-
equals(Object)
- Implements the equals method.
-
hash(int)
- Implements the hash method.
-
intValue()
- Gets the stored int value.
-
lessThan(Comparable)
- Implements the lessThan method.
-
toString()
- Implements the toString method.
MyInteger
public MyInteger()
- Construct the MyInteger object with initial value 0.
MyInteger
public MyInteger(int x)
- Construct the MyInteger object.
- Parameters:
- x - the initial value.
intValue
public int intValue()
- Gets the stored int value.
- Returns:
- the stored value.
toString
public String toString()
- Implements the toString method.
- Returns:
- the String representation.
- Overrides:
- toString in class Object
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
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
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
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