nz.ac.waikato.jdsl.core.ref
Class IntegerHashComparator

java.lang.Object
  extended by nz.ac.waikato.jdsl.core.ref.IntegerHashComparator
All Implemented Interfaces:
EqualityComparator, HashComparator

public class IntegerHashComparator
extends java.lang.Object
implements HashComparator

An implementation of a HashComparator for java.lang.Integers

Version:
JDSL 2.1.1
Author:
Keith Schmidt (kas)

Constructor Summary
IntegerHashComparator()
           
 
Method Summary
 int hashValue(java.lang.Object toHash)
          defines a mapping f: Integer -> \mathbb{Z} \cap [0, 2^{31} -1]
 boolean isComparable(java.lang.Object toCompare)
          determines if the Comparator can use this Object
 boolean isEqualTo(java.lang.Object first, java.lang.Object second)
          tests equality on two Integers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegerHashComparator

public IntegerHashComparator()
Method Detail

isComparable

public boolean isComparable(java.lang.Object toCompare)
determines if the Comparator can use this Object

Specified by:
isComparable in interface EqualityComparator
Parameters:
toCompare - Any java.lang.Object
Returns:
True if and only if this comparator may compare this object.

isEqualTo

public boolean isEqualTo(java.lang.Object first,
                         java.lang.Object second)
                  throws java.lang.ClassCastException
tests equality on two Integers

Specified by:
isEqualTo in interface EqualityComparator
Parameters:
first - First Object to compare
second - Second Object to compare
Returns:
True if and only if a is equal to b
Throws:
java.lang.ClassCastException

hashValue

public int hashValue(java.lang.Object toHash)
              throws java.lang.ClassCastException
defines a mapping f: Integer -> \mathbb{Z} \cap [0, 2^{31} -1]

Specified by:
hashValue in interface HashComparator
Parameters:
toHash - an object acting as a key in a hash table
Returns:
the hash code value of obj
Throws:
java.lang.ClassCastException


Copyright © 2009 ModelJUnit Project. All Rights Reserved.