ucx
UAP Common Extensions
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
hash_key.h File Reference

Interface for map implementations. More...

#include "common.h"
#include "string.h"

Go to the source code of this file.

Data Structures

struct  cx_hash_key_s
 Internal structure for a key within a hash map. More...
 

Macros

#define cx_hash_key_cxstr(str)   cx_hash_key_cxstr(cx_strcast(str))
 Computes a hash key from a UCX string.
 

Typedefs

typedef struct cx_hash_key_s CxHashKey
 Type for a hash key.
 

Functions

void cx_hash_murmur (CxHashKey *key)
 Computes a murmur2 32-bit hash.
 
CxHashKey cx_hash_key_str (const char *str)
 Computes a hash key from a string.
 
CxHashKey cx_hash_key_bytes (const unsigned char *bytes, size_t len)
 Computes a hash key from a byte array.
 
CxHashKey cx_hash_key (const void *obj, size_t len)
 Computes a hash key for an arbitrary object.
 
static CxHashKey cx_hash_key_cxstr (cxstring str)
 Computes a hash key from a UCX string.
 

Detailed Description

Interface for map implementations.

Author
Mike Becker
Olaf Wintermann

Macro Definition Documentation

◆ cx_hash_key_cxstr

#define cx_hash_key_cxstr ( str)    cx_hash_key_cxstr(cx_strcast(str))

Computes a hash key from a UCX string.

Parameters
str(cxstring or cxmutstr) the string
Returns
(CxHashKey) the hash key

Function Documentation

◆ cx_hash_key()

CxHashKey cx_hash_key ( const void * obj,
size_t len )

Computes a hash key for an arbitrary object.

The computation uses the in-memory representation that might not be the same on different platforms. Therefore, this hash should not be used for data exchange with different machines.

Parameters
obja pointer to an arbitrary object
lenthe length of object in memory
Returns
the hash key

◆ cx_hash_key_bytes()

CxHashKey cx_hash_key_bytes ( const unsigned char * bytes,
size_t len )

Computes a hash key from a byte array.

Parameters
bytesthe array
lenthe length
Returns
the hash key

◆ cx_hash_key_cxstr()

static CxHashKey cx_hash_key_cxstr ( cxstring str)
inlinestatic

Computes a hash key from a UCX string.

Parameters
strthe string
Returns
the hash key

◆ cx_hash_key_str()

CxHashKey cx_hash_key_str ( const char * str)

Computes a hash key from a string.

The string needs to be zero-terminated.

Parameters
strthe string
Returns
the hash key

◆ cx_hash_murmur()

void cx_hash_murmur ( CxHashKey * key)

Computes a murmur2 32-bit hash.

You need to initialize data and len in the key struct. The hash is then directly written to that struct.

Usually you should not need this function. Use cx_hash_key(), instead.

Note
If data is NULL, the hash is defined as 1574210520.
Parameters
keythe key, the hash shall be computed for
See also
cx_hash_key()