struct_hashtable_t Struct Reference

A basic implementation of a hashtable. More...

#include <lib/utils/include/hashtable.h>


Data Fields

uint32_t alloced
uint32_t nentries
linked_list_tbuckets
int(* cmp_func )(const void *const key_a, const void *const key_b)
uint32_t(* hash_func )(const void *const key)


Detailed Description

A basic implementation of a hashtable.

This structure defines a simple generic hashtable. It can store any type of elements, provided that suitable comparison and hash functions exist for the type of the keys used.

This hashtable implementation uses a simple sequential search in a linked list to solve the collisions.

Warning:
Due to limitations in the current implementation, it is strongly advised to use only pointers to integers or strings as keys.

Definition at line 59 of file hashtable.h.


Field Documentation

Number of allocated buckets (always a power of two).

Definition at line 63 of file hashtable.h.

Current number of entries in the hashtable.

Definition at line 67 of file hashtable.h.

Array of linked_list_t of size alloced used to store the hashtable's entries.

Definition at line 72 of file hashtable.h.

int(* struct_hashtable_t::cmp_func)(const void *const key_a, const void *const key_b)

Pointer to a comparison function for the keys stored in the hashtable. The function's signature should be: int cmp_func(const void* const, const void* const). The function should take two keys of identical type passed as pointers to void.

For now, the only requirement if that the pointed function should return 0 if two identical keys are compared.

uint32_t(* struct_hashtable_t::hash_func)(const void *const key)

Pointer to the hash function used by the hashtable. The hash function's signature should be: uint32_t hash_func(const void* const). The function should take a key passed as a pointer to void.

Needless to say, the real type of the key handled by this function should be the same as the one handled by the comparison function pointed by cmp_int.


The documentation for this struct was generated from the following file:

Generated on Fri Jun 17 11:10:12 2011 for TIFA by Doxygen 1.5.5