rlib
Convenience library for useful things
Loading...
Searching...
No Matches
Hash functions

Default RHashFunc / REqualFunc implementations used by Hash table and Hash set when the caller doesn't want to spell out a custom pair. More...

Files

file  rhashfuncs.h
 Pre-built hash / equality function pairs for the common key types (pointer-identity, NUL-terminated string).
 

Macros

#define R_HASH_EMPTY   RSIZE_MAX
 Sentinel returned by hash functions for "no value".
 

Functions

rsize r_direct_hash (rconstpointer data)
 Pointer-identity hash: treats data as an opaque machine-word and returns it directly.
 
rboolean r_direct_equal (rconstpointer a, rconstpointer b)
 Pointer-identity equality: returns TRUE iff a == b.
 
rsize r_str_hash (rconstpointer data)
 Hash a NUL-terminated C string.
 
rsize r_str_hash_sized (const rchar *data, rssize size)
 Hash a byte string of caller-supplied length.
 
rboolean r_str_equal (rconstpointer a, rconstpointer b)
 Equality for NUL-terminated C strings (via strcmp).
 

Detailed Description

Default RHashFunc / REqualFunc implementations used by Hash table and Hash set when the caller doesn't want to spell out a custom pair.

Function Documentation

◆ r_direct_hash()

rsize r_direct_hash ( rconstpointer  data)

Pointer-identity hash: treats data as an opaque machine-word and returns it directly.

Pair with r_direct_equal for hashtables keyed by pointer identity or by small integer values cast to rconstpointer.

◆ r_str_hash()

rsize r_str_hash ( rconstpointer  data)

Hash a NUL-terminated C string.

Walks data byte-by-byte until the terminator; pair with r_str_equal.

◆ r_str_hash_sized()

rsize r_str_hash_sized ( const rchar data,
rssize  size 
)

Hash a byte string of caller-supplied length.

Useful when the key isn't NUL-terminated. Pass size = -1 for the same behaviour as r_str_hash.