BloombergLP::bdlb::HashUtil::hash0

Return a modular hash value for the specified key.

Synopsis

Declared in <bdlb_hashutil.h>

static
unsigned int
hash0(
    char key,
    int modulus);

Description

Return an unsigned integer hash value in the range from zero to one less than the specified modulus corresponding to the specified key. The behavior is undefined unless 0 < modulus < 2^31. Note that modulus is expected to be a prime not close to an integral power of 2. Also note that specifying a modulus of 1 will cause 0 to be returned for every value.

Return Value

modular hash value for key in [0 .. modulus)]

Parameters

NameDescription
keyvalue to hash
moduluspositive upper bound (exclusive) of the hash range