All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Supporting.MyInteger

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

public final class MyInteger
extends java.lang.Object
implements Supporting.Comparable, Supporting.Hashable
Wrapper class for use with generic data structures. Mimics Integer.


Constructor Index

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

Method Index

 o compares(Comparable)
Implements the compares method.
 o equals(Object)
Implements the equals method.
 o hash(int)
Implements the hash method.
 o intValue()
Gets the stored int value.
 o lessThan(Comparable)
Implements the lessThan method.
 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 java.lang.String toString()
Implements the toString method.

Returns:
the String representation.
Overrides:
toString in class java.lang.Object
 o compares
 public int compares(Supporting.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.
 o lessThan
 public boolean lessThan(Supporting.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.
 o equals
 public boolean equals(java.lang.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 java.lang.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