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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description HashRange
getRange()
BigInteger
hashAsBigInt(T value)
The hash value as aBigInteger
.int
hashAsInt(T value)
The hash value as an int.long
hashAsLong(T value)
The hash value as a long.
-
-
-
Method Detail
-
getRange
HashRange getRange()
-
hashAsBigInt
BigInteger hashAsBigInt(T value) throws IllegalArgumentException
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
int hashAsInt(T value) throws IllegalArgumentException
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
long hashAsLong(T value) throws IllegalArgumentException
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
-
-