|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.planetj.math.rabinhash.RabinHashFunction64
This class provides an implementation of a hash function based on Rabin fingerprints, one
which can efficiently produce a 64-bit hash value for a sequence of bytes. Its services and characteristics
are entirely analogous to that of RabinHashFunction32, except that hash values are 64 bits and
the implementation works in terms of degree 64 polynomials represented as longs.
Please see the documentation and comments for RabinHashFunction32 for more information.
| Field Summary | |
static RabinHashFunction64 |
DEFAULT_HASH_FUNCTION
Default hash function, provided for convenience. |
| Constructor Summary | |
RabinHashFunction64(long P)
Creates a RabinHashFunction64 based on the specified polynomial. |
|
| Method Summary | |
boolean |
equals(java.lang.Object o)
|
long |
getP()
|
long |
hash(byte[] A)
Return the Rabin hash value of an array of bytes. |
long |
hash(java.nio.ByteBuffer A)
Returns the Rabin hash value of a ByteBuffer. |
long |
hash(char[] A)
Return the Rabin hash value of an array of chars. |
long |
hash(java.io.File f)
Computes the Rabin hash value of the contents of a file. |
long |
hash(java.io.InputStream is)
Computes the Rabin hash value of the data from an InputStream. |
long |
hash(long[] A)
Returns the Rabin hash value of an array of longs. |
long |
hash(java.nio.LongBuffer A)
Returns the Rabin hash value of an LongBuffer. |
long |
hash(java.io.Serializable obj)
Returns the Rabin hash value of a serializable object. |
long |
hash(java.lang.String s)
Computes the Rabin hash value of a String. |
long |
hash(java.net.URL url)
Computes the Rabin hash value of the contents of a file, specified by URL. |
int |
hashCode()
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final RabinHashFunction64 DEFAULT_HASH_FUNCTION
| Constructor Detail |
public RabinHashFunction64(long P)
Creates a RabinHashFunction64 based on the specified polynomial.
This class does not test the polynomial for irreducibility; therefore this constructor should only be used with polynomials that are already known to be irreducible, or else the hash function will not perform optimally.
P - a degree 64 polynomial over GF(2), represented as a long| Method Detail |
public long getP()
longpublic long hash(byte[] A)
Return the Rabin hash value of an array of bytes.
A - the array of bytes
java.lang.NullPointerException - if A is nullpublic long hash(char[] A)
Return the Rabin hash value of an array of chars.
A - the array of chars
java.lang.NullPointerException - if A is nullpublic long hash(long[] A)
Returns the Rabin hash value of an array of longs. This method is the most efficient of
all the hash methods, so it should be used when possible.
A - array of longs
java.lang.NullPointerException - if A is nullpublic long hash(java.nio.ByteBuffer A)
Returns the Rabin hash value of a ByteBuffer.
A - ByteBuffer
java.lang.NullPointerException - if A is nullpublic long hash(java.nio.LongBuffer A)
Returns the Rabin hash value of an LongBuffer.
A - LongBuffer
java.lang.NullPointerException - if A is nullpublic long hash(java.io.Serializable obj)
Returns the Rabin hash value of a serializable object.
obj - the object to be hashed
java.lang.NullPointerException - if obj is nullpublic long hash(java.lang.String s)
Computes the Rabin hash value of a String.
s - the string to be hashed
java.lang.NullPointerException - if s is null
public long hash(java.io.File f)
throws java.io.FileNotFoundException,
java.io.IOException
Computes the Rabin hash value of the contents of a file.
f - the file to be hashed
java.io.FileNotFoundException - if the file cannot be found
java.io.IOException - if an error occurs while reading the file
java.lang.NullPointerException - if f is null
public long hash(java.net.URL url)
throws java.io.IOException
Computes the Rabin hash value of the contents of a file, specified by URL.
url - the URL of the file to be hashed
java.io.IOException - if an error occurs while reading from the URL
java.lang.NullPointerException - if url is null
public long hash(java.io.InputStream is)
throws java.io.IOException
Computes the Rabin hash value of the data from an InputStream.
is - the InputStream to hash
java.io.IOException - if an error occurs while reading from the InputStream
java.lang.NullPointerException - if stream is nullpublic boolean equals(java.lang.Object o)
public int hashCode()
public java.lang.String toString()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||