- Type Parameters:
T- the type of objects for which hashes may be generated
- All Known Implementing Classes:
PerfectStringHash
public interface Hash<T>
Implementations of this interface can generate one hash value for a given object. Depending upon the implementation, null values may be supported.
Method Summary
All MethodsModifier and TypeMethodDescriptiongetRange()Returns the hash range for this hash function.hashAsBigInt(T value) The hash value as aBigInteger.intThe hash value as an int.longhashAsLong(T value) The hash value as a long.
Method Details
getRange
hashAsBigInt
The hash value as aBigInteger. This method may be useful in circumstances where the generated hash is too large to be accommodated in a single primitive value, eg. if cryptographic hashes are being used.- Parameters:
value- the object to be hashed- Returns:
- the object's hash code, never null
- Throws:
IllegalArgumentException- if the value cannot be hashed
hashAsInt
The hash value as an int. This method should provide better performance for integer-ranged hashes. This value is not guaranteed to lie within the indicatedHashRange.- Parameters:
value- the object to be hashed- Returns:
- the object's hash code
- Throws:
IllegalArgumentException- if the value cannot be hashed
hashAsLong
The hash value as a long. This method should provide better performance for long-ranged hashes. This value is not guaranteed to lie within the indicatedHashRange.- Parameters:
value- the object to be hashed- Returns:
- the object's hash code
- Throws:
IllegalArgumentException- if the value cannot be hashed