edu.stanford.math.plex
public class CRC extends java.lang.Object
CRC
class provides good hash methods for int/long and string data.Modifier and Type | Field and Description |
---|---|
protected static int[] |
hash32tab0
Internal table used by CRC code.
|
protected static long[] |
hash64tab0
Internal table used by CRC code.
|
protected static long[] |
hash64tab1
Internal table used by CRC code.
|
Modifier and Type | Method and Description |
---|---|
static int |
hash32(byte[] v)
Compute 32-bit CRC for an array of bytes.
|
static int |
hash32(double[] v)
Compute 32-bit CRC for an array of double.
|
static int |
hash32(double[][] A,
int rows,
int cols)
Compute 32-bit CRC for a matrix of doubles.
|
static int |
hash32(float[] v)
Compute 32-bit CRC for an array of float.
|
static int |
hash32(int[] v)
Compute 32-bit CRC for an array of ints.
|
static int |
hash32(long[] v)
Compute 32-bit CRC for an array of longs.
|
static int |
hash32(long x,
int initial)
Easily testable function which computes 32-bit CRC for a single long.
|
static int |
hash32(short[] v)
Compute 32-bit CRC for an array of shorts.
|
protected static long |
hash64(byte[] v)
Compute 64-bit CRC for an array of bytes.
|
static long |
hash64(double[] v)
Compute 64-bit CRC for an array of double.
|
static long |
hash64(float[] v)
Compute 64-bit CRC for an array of float.
|
static long |
hash64(int[] v)
Compute 64-bit CRC for an array of ints.
|
static long |
hash64(long[] v)
Compute 64-bit CRC for an array of longs.
|
static long |
hash64(long x,
long initial)
Easily testable function which computes 64-bit CRC for a single long.
|
static long |
hash64(short[] v)
Compute 64-bit CRC for an array of shorts.
|
static long |
update_hash(int x,
long hcode)
Incremental 64-bit CRC for an integer.
|
static long |
update_hash(long x,
long hcode)
Incremental 64-bit CRC for a long.
|
protected static int |
update32(byte b,
int hcode,
int[] tbl)
Incremental 32-bit CRC calculation for a single byte.
|
protected static int |
update32(int i,
int hcode,
int[] tbl)
Incremental 32-bit CRC calculation for a single int.
|
protected static int |
update32(long l,
int hcode,
int[] tbl)
Incremental 32-bit CRC calculation for a single long.
|
protected static int |
update32(short s,
int hcode,
int[] tbl)
Incremental 32-bit CRC calculation for a single short.
|
protected static int |
update32l(long b,
int hcode,
int[] tbl)
Incremental 32-bit CRC calculation for a single byte.
|
protected static long |
update64(byte b,
long hcode,
long[] tbl)
Incremental 64-bit CRC calculation for a single byte.
|
protected static long |
update64(int i,
long hcode,
long[] tbl)
Incremental 64-bit CRC calculation for a single int.
|
protected static long |
update64(long l,
long hcode,
long[] tbl)
Incremental 64-bit CRC calculation for a single long.
|
protected static long |
update64(short s,
long hcode,
long[] tbl)
Incremental 64-bit CRC calculation for a single short.
|
protected static long |
update64l(long b,
long hcode,
long[] tbl)
Incremental 64-bit CRC calculation for a single byte.
|
protected static long[] hash64tab0
protected static long[] hash64tab1
protected static int[] hash32tab0
protected static int update32l(long b, int hcode, int[] tbl)
b
- The next data in the CRC calculation (only lowest byte is used).hcode
- The current int result.protected static int update32(byte b, int hcode, int[] tbl)
b
- The next data in the CRC calculation.hcode
- The current long result.protected static int update32(short s, int hcode, int[] tbl)
s
- The next data in the CRC calculation.hcode
- The current long result.protected static int update32(int i, int hcode, int[] tbl)
i
- The next data in the CRC calculation.hcode
- The current long result.protected static int update32(long l, int hcode, int[] tbl)
l
- The next data in the CRC calculation.hcode
- The current long result.protected static long update64l(long b, long hcode, long[] tbl)
b
- The next data in the CRC calculation (only lowest byte is used).hcode
- The current long result.protected static long update64(byte b, long hcode, long[] tbl)
b
- The next data in the CRC calculation.hcode
- The current long result.protected static long update64(short s, long hcode, long[] tbl)
s
- The next data in the CRC calculation.hcode
- The current long result.protected static long update64(int i, long hcode, long[] tbl)
i
- The next data in the CRC calculation.hcode
- The current long result.protected static long update64(long l, long hcode, long[] tbl)
l
- The next data in the CRC calculation.hcode
- The current long result.protected static long hash64(byte[] v)
v
- The byte array.public static long hash64(short[] v)
v
- The short array.public static long update_hash(int x, long hcode)
x
- The int.hcode
- The hash so far.public static long update_hash(long x, long hcode)
x
- The long.hcode
- The hash so far.public static long hash64(int[] v)
v
- The int array.public static long hash64(float[] v)
v
- The float array.public static long hash64(long[] v)
v
- The long array.public static long hash64(double[] v)
v
- The double array.public static int hash32(byte[] v)
v
- The byte array.public static int hash32(short[] v)
v
- The short array.public static int hash32(int[] v)
v
- The int array.public static int hash32(float[] v)
v
- The float array.public static int hash32(long[] v)
v
- The long array.public static int hash32(double[] v)
v
- The double array.public static int hash32(double[][] A, int rows, int cols)
A
- The double[][].rows
- The length of A.cols
- The length of A[0].public static long hash64(long x, long initial)
These functions are only intended as entry points for test code. They are structurally the same as a some functions in a long-used and well-tested C library, so we were easily able to generate testcases for this code from the C code.
x
- The long to be hashed.initial
- The CRC value to be updated.public static int hash32(long x, int initial)
These functions are only intended as entry points for test code. They are structurally the same as a some functions in a long-used and well-tested C library, so we were easily able to generate testcases for this code from the C code.
x
- The long to be hashed.initial
- The CRC value to be updated.