Package com.tomgibara.crinch.hashing
Interface Hash<T>
- 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.
- Author:
- tomgibara
-
Method Summary
Modifier and TypeMethodDescriptiongetRange()
hashAsBigInt
(T value) The hash value as aBigInteger
.int
The hash value as an int.long
hashAsLong
(T value) The hash value as a long.
-
Method Details
-
getRange
HashRange getRange() -
hashAsBigInt
The hash value as aBigInteger
. This method may be useful in circumstances where the generated hash is too large to be accomodated 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
-