Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

Chained Hash Map
[SB Library]

Hash map handling. More...

Data Structures

struct  CHTbl_
 Structure for the hashmap. More...

Typedefs

typedef CHTbl_ CHTbl
 Structure for the hashmap.

Functions

int chtbl_init (CHTbl *htbl, int buckets, int(*h)(const void *key), int(*match)(const void *obj1, const void *obj2), void(*destroy)(void *obj))
 Initialize hash map.
void chtbl_destroy (CHTbl *htbl)
 Destroy hash map.
int chtbl_size (CHTbl *htbl)
 Destroy hash map.
int chtbl_insert (CHTbl *htbl, const void *data)
 Insert element in hash map.
int chtbl_remove (CHTbl *htbl, void **data)
 Remove element from hash map.
int chtbl_lookup (CHTbl *htbl, void **data)
 Lookup for element in hash map.

Detailed Description

Hash map handling.

Author:
Stefan Bambach (sbambach@gmx.net)
Version:
0.1

Typedef Documentation

typedef struct CHTbl_ CHTbl
 

Structure for the hashmap.

Holds the internal data for managing the hashmap.

Referenced by chtbl_destroy(), chtbl_init(), chtbl_insert(), chtbl_lookup(), chtbl_remove(), and chtbl_size().


Function Documentation

void chtbl_destroy CHTbl htbl  ) 
 

Destroy hash map.

Parameters:
htbl Pointer to Hash table struct

Definition at line 34 of file hashmap.c.

References CHTbl_::buckets, CHTbl, list_destroy(), CHTbl_::rwlock, T_RDWR_WLOCK, T_RDWR_WUNLOCK, and CHTbl_::table.

int chtbl_init CHTbl htbl,
int  buckets,
int(*)(const void *key)  h,
int(*)(const void *obj1, const void *obj2)  match,
void(*)(void *obj)  destroy
 

Initialize hash map.

Parameters:
htbl Pointer to Hash table struct
buckets No. of Buckets to use
h hash function (calculate Bucketno. fro CacheObj)
match match function (compare two CacheObjs)
destroy destroy function (destroy CacheObj)
Returns:
0 if successful, -1 otherwise.

Definition at line 6 of file hashmap.c.

References CHTbl_::buckets, CHTbl, CHTbl_::h, List, list_init(), CHTbl_::rwlock, T_RDWR_INIT, and CHTbl_::table.

int chtbl_insert CHTbl htbl,
const void *  data
 

Insert element in hash map.

Parameters:
htbl Pointer to Hash table struct
data Pointer to object to be stored
Returns:
0 if successfully inserted -1 if error while inserting 1 if element is already in list

Definition at line 80 of file hashmap.c.

References CHTbl_::buckets, CHTbl, CHTbl_::h, list_insert(), CHTbl_::rwlock, T_RDWR_RLOCK, T_RDWR_RUNLOCK, and CHTbl_::table.

int chtbl_lookup CHTbl htbl,
void **  data
 

Lookup for element in hash map.

Parameters:
htbl Pointer to Hash table struct
data Pointer to pointer to object to be searched for
Returns:
0 if element found, -1 otherwise.

Definition at line 129 of file hashmap.c.

References CHTbl_::buckets, CHTbl, CHTbl_::h, list_lookup(), CHTbl_::rwlock, T_RDWR_RLOCK, T_RDWR_RUNLOCK, and CHTbl_::table.

int chtbl_remove CHTbl htbl,
void **  data
 

Remove element from hash map.

Parameters:
htbl Pointer to Hash table struct
data Pointer to pointer to object to be removed
Returns:
0 if successfully removed, -1 otherwise.

Definition at line 106 of file hashmap.c.

References CHTbl_::buckets, CHTbl, CHTbl_::h, list_remove(), CHTbl_::rwlock, T_RDWR_RLOCK, T_RDWR_RUNLOCK, and CHTbl_::table.

int chtbl_size CHTbl htbl  ) 
 

Destroy hash map.

Parameters:
htbl Pointer to Hash table struct
Returns:
Number of elements in hash map

Definition at line 60 of file hashmap.c.

References CHTbl_::buckets, CHTbl, list_getsize(), CHTbl_::rwlock, T_RDWR_RLOCK, T_RDWR_RUNLOCK, and CHTbl_::table.


Generated on Wed Mar 30 13:43:27 2005 for Mntd by  doxygen 1.3.9.1