Nilorea Library

- Main Page
- Modules
- Data Structures
- Files

All Data Structures Files Functions Variables Typedefs Macros Groups
Data Structures | Macros | Typedefs | Functions
HASH_TABLE: hash table with multiples predefined type

## Data Structures

union | HASH_VALUE
struct | HASH_NODE
struct | HASH_TABLE

## Macros

#define | FORCE_INLINE inline __attribute__((always_inline))
#define | ROTL32(x, y) rotl32(x,y)
#define | BIG_CONSTANT(x) (x##LLU)
#define | HASH_INT 0
#define | HASH_DOUBLE 1
#define | HASH_STRING 2
#define | HASH_PTR 3
#define | HASH_UNKNOWN 4

## Typedefs

typedef struct HASH_NODE | HASH_NODE
typedef struct HASH_TABLE | HASH_TABLE

## Functions

void | MurmurHash3_x86_32 (const void *key, int len, uint32_t seed, void *out)
void | MurmurHash3_x86_128 (const void *key, int len, uint32_t seed, void *out)
char * | ht_node_type (HASH_NODE *node)
| get the type of a node , text version More...
HASH_TABLE * | new_ht (int size)
| Create a hash table with the given size. More...
int | ht_put_int (HASH_TABLE *table, char *key, int val)
| put an integral value with given key in the targeted hash table More...
int | ht_put_double (HASH_TABLE *table, char *key, double val)
| put a double value with given key in the targeted hash table More...
int | ht_put_ptr (HASH_TABLE *table, char *key, void *val, void(*destructor)(void *ptr))
| put a pointer value with given key in the targeted hash table More...
int | ht_put_string (HASH_TABLE *table, char *key, char *val)
| put a null terminated char *string with given key in the targeted hash table More...
HASH_NODE * | ht_get_node (HASH_TABLE *table, char *key)
| return the associated key's node inside the hash_table More...
int | ht_get_int (HASH_TABLE *table, char *key, int *val)
| Retrieve an integral value in the hash table, at the given key. Leave val untouched if key is not found. More...
int | ht_get_double (HASH_TABLE *table, char *key, double *val)
| Retrieve a double value in the hash table, at the given key. Leave val untouched if key is not found. More...
int | ht_get_ptr (HASH_TABLE *table, char *key, void **val)
| Retrieve a pointer value in the hash table, at the given key. Leave val untouched if key is not found. More...
int | ht_get_string (HASH_TABLE *table, char *key, char **val)
| Retrieve a char *string value in the hash table, at the given key. Leave val untouched if key is not found. More...
int | ht_remove (HASH_TABLE *table, char *key)
| Remove a key from a hash table. More...
int | empty_ht (HASH_TABLE *table)
| Empty a hash table. More...
int | destroy_ht (HASH_TABLE **table)
| Free and set the table to NULL. More...

## Detailed Description

## Macro Definition Documentation

#define BIG_CONSTANT | ( |  | x | ) | (x##LLU)

missing ROTL constant fix 64bit

Definition at line 59 of file n_hash.h.

#define FORCE_INLINE inline __attribute__((always_inline))

force inline attribute for WIN32 MINGW or LINUX

Definition at line 52 of file n_hash.h.

#define HASH_DOUBLE 1

value of double type inside the hash node

Definition at line 66 of file n_hash.h.

#define HASH_INT 0

value of integral type inside the hash node

Definition at line 64 of file n_hash.h.

#define HASH_PTR 3

value of pointer type inside the hash node

Definition at line 70 of file n_hash.h.

#define HASH_STRING 2

value of char * type inside the hash node

Definition at line 68 of file n_hash.h.

#define HASH_UNKNOWN 4

value of unknow type inside the hash node

Definition at line 72 of file n_hash.h.

#define ROTL32 | ( |  | x,
|  |  | y
| ) |  | rotl32(x,y)

missing ROTL fix 32bit

Definition at line 57 of file n_hash.h.

## Typedef Documentation

typedef struct HASH_NODE HASH_NODE

structure of a hash table node

typedef struct HASH_TABLE HASH_TABLE

structure of a hash table

## Function Documentation

int destroy_ht | ( | HASH_TABLE ** | table | ) |

Free and set the table to NULL.

Parameters

  table | Targeted hash table

Returns
  TRUE or FALSE.

Definition at line 776 of file n_hash.c.

Here is the call graph for this function:

int empty_ht | ( | HASH_TABLE * | table | ) |

Empty a hash table.

Parameters

  table | Targeted hash table

Returns
  TRUE or FALSE.

Definition at line 734 of file n_hash.c.

Here is the caller graph for this function:

int ht_get_double | ( | HASH_TABLE * | table,
|  | char * | key,
|  | double * | val
| ) |  |

Retrieve a double value in the hash table, at the given key. Leave val untouched if key is not found.

Parameters

  table | Targeted hash table
  key | Size Associated value's key
  val | A pointer to a destination double

Returns
  TRUE or FALSE.

Definition at line 585 of file n_hash.c.

Here is the call graph for this function:

int ht_get_int | ( | HASH_TABLE * | table,
|  | char * | key,
|  | int * | val
| ) |  |

Retrieve an integral value in the hash table, at the given key. Leave val untouched if key is not found.

Parameters

  table | Targeted hash table
  key | Size Associated value's key
  val | A pointer to a destination integer

Returns
  TRUE or FALSE.

Definition at line 556 of file n_hash.c.

Here is the call graph for this function:

HASH_NODE * ht_get_node | ( | HASH_TABLE * | table,
|  | char * | key
| ) |  |

return the associated key's node inside the hash_table

Parameters

  table | Targeted hash table
  key | Size Associated value's key

Returns
  The found node, or NULL

Definition at line 519 of file n_hash.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ht_get_ptr | ( | HASH_TABLE * | table,
|  | char * | key,
|  | void ** | val
| ) |  |

Retrieve a pointer value in the hash table, at the given key. Leave val untouched if key is not found.

Parameters

  table | Targeted hash table
  key | Size Associated value's key
  val | A pointer to an empty pointer store

Returns
  TRUE or FALSE.

Definition at line 614 of file n_hash.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ht_get_string | ( | HASH_TABLE * | table,
|  | char * | key,
|  | char ** | val
| ) |  |

Retrieve a char *string value in the hash table, at the given key. Leave val untouched if key is not found.

Parameters

  table | Targeted hash table
  key | Size Associated value's key
  val | A pointer to an empty destination char *string

Returns
  TRUE or FALSE.

Definition at line 641 of file n_hash.c.

Here is the call graph for this function:

char * ht_node_type | ( | HASH_NODE * | node | ) |

get the type of a node , text version

Parameters

  node | node to check

Returns
  NULL or the associated node type

Definition at line 249 of file n_hash.c.

Here is the caller graph for this function:

int ht_put_double | ( | HASH_TABLE * | table,
|  | char * | key,
|  | double | val
| ) |  |

put a double value with given key in the targeted hash table

Parameters

  table | Targeted hash table
  key | Size Associated value's key
  val | double value to put

Returns
  TRUE or FALSE

Definition at line 354 of file n_hash.c.

Here is the call graph for this function:

int ht_put_int | ( | HASH_TABLE * | table,
|  | char * | key,
|  | int | val
| ) |  |

put an integral value with given key in the targeted hash table

Parameters

  table | Targeted hash table
  key | Size Associated value's key
  val | integral value to put

Returns
  TRUE or FALSE

Definition at line 301 of file n_hash.c.

Here is the call graph for this function:

int ht_put_ptr | ( | HASH_TABLE * | table,
|  | char * | key,
|  | void * | val,
|  | void(*)(void *ptr) | destructor
| ) |  |

put a pointer value with given key in the targeted hash table

Parameters

  table | Targeted hash table
  key | Size Associated value's key
  val | pointer value to put
  destructor | Pointer to the ptr type destructor function. Leave to NULL if there isn't

Returns
  TRUE or FALSE

Definition at line 408 of file n_hash.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ht_put_string | ( | HASH_TABLE * | table,
|  | char * | key,
|  | char * | val
| ) |  |

put a null terminated char *string with given key in the targeted hash table

Parameters

  table | Targeted hash table
  key | Size Associated value's key
  val | string value to put

Returns
  TRUE or FALSE

Definition at line 466 of file n_hash.c.

Here is the call graph for this function:

int ht_remove | ( | HASH_TABLE * | table,
|  | char * | key
| ) |  |

Remove a key from a hash table.

Parameters

  table | Targeted hash table
  key | Key to remove

Returns
  TRUE or FALSE.

Definition at line 668 of file n_hash.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void MurmurHash3_x86_128 | ( | const void * | key,
|  | int | len,
|  | uint32_t | seed,
|  | void * | out
| ) |  |

brief MurmurHash3 was written by Austin Appleby, and is placed in the public domain. The author hereby disclaims copyright to this source code. Note - The x86 and x64 versions do not produce the same results, as the algorithms are optimized for their respective platforms. You can still compile and run any of them on any platform, but your performance with the non-native version will be less than optimal.

Parameters

  key | char *string as the key
  len | size of the key
  seed | seed value for murmur hash
  out | generated hash

Definition at line 151 of file n_hash.c.

Here is the call graph for this function:

void MurmurHash3_x86_32 | ( | const void * | key,
|  | int | len,
|  | uint32_t | seed,
|  | void * | out
| ) |  |

brief MurmurHash3 was written by Austin Appleby, and is placed in the public domain. The author hereby disclaims copyright to this source code. Note - The x86 and x64 versions do not produce the same results, as the algorithms are optimized for their respective platforms. You can still compile and run any of them on any platform, but your performance with the non-native version will be less than optimal.

Parameters

  key | char *string as the key
  len | size of the key
  seed | seed value for murmur hash
  out | generated hash

Definition at line 92 of file n_hash.c.

Here is the call graph for this function:

Here is the caller graph for this function:

HASH_TABLE * new_ht | ( | int | size | ) |

Create a hash table with the given size.

Parameters

  size | Size of the root hash node table

Returns
  NULL or the new allocated hash table

Definition at line 268 of file n_hash.c.

Here is the call graph for this function:

Here is the caller graph for this function: