public class Hashs extends Object
| 构造器和说明 |
|---|
Hashs() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <H extends Hasher> |
getHasher(String hasherName,
Object initParams)
Get a singleton instance of hash function of a given type.
|
static long |
hash(Hasher hasher,
byte[] bytes)
Calculate a hash using all bytes from the input argument, and
a seed of 0.
|
static long |
hash(Hasher hasher,
byte[] bytes,
int length,
long seed)
一次性计算 hash
Calculate a hash using bytes from 0 to
length, and
the provided seed value |
static long |
hash(Hasher hasher,
byte[] bytes,
long seed)
一次性计算 hash
Calculate a hash using all bytes from the input argument,
and a provided seed value.
|
static long |
hash(String hasher,
Object initParams,
byte[] bytes,
int length,
long seed) |
static int |
hashToIndex(int hash,
int length)
A function that calculates the index (e.g. to be used in an array/list) for a given hash.
|
public static long hash(Hasher hasher, byte[] bytes)
bytes - input bytespublic static long hash(Hasher hasher, byte[] bytes, long seed)
Calculate a hash using all bytes from the input argument, and a provided seed value.
bytes - input bytesseed - seed valuepublic static long hash(Hasher hasher, byte[] bytes, int length, long seed)
Calculate a hash using bytes from 0 to length, and
the provided seed value
bytes - input byteslength - length of the valid bytes to considerseed - seed valuepublic static <H extends Hasher> H getHasher(String hasherName, Object initParams)
hasherName - predefined hash typepublic static int hashToIndex(int hash,
int length)
length - the length of the array/listIllegalArgumentException - if length is smaller than 1.Copyright © 2022. All rights reserved.