| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

HashTable.h

Go to the documentation of this file.
00001 #ifndef HEPHAESTUS_HASHTABLE_H
00002 #define HEPHAESTUS_HASHTABLE_H
00003 
00004 /*
00005   Trivial memory-address based hash table
00006 */
00007 
00008 #ifdef __cplusplus
00009 extern "C" {
00010 #endif
00011 
00012 struct hhh_Cell {
00013    void *key;
00014    void *value;
00015 
00016    struct hhh_Cell *next;
00017 };
00018 
00019 struct hhh_HashTable {
00020    struct hhh_Cell **table;
00021 
00022    unsigned int size;
00023    unsigned int nentries;
00024 
00025    struct hhh_Cell *lastfound;
00026 };
00027 
00028 
00029 /* create a new hash table of at least size minsize */
00030 struct hhh_HashTable *hhh_HashTable_new( unsigned long minsize );
00031 
00032 /* insert pair (key, value); return 0 on failure */
00033 int hhh_HashTable_insert( struct hhh_HashTable *ht, void *key, void *value );
00034 
00035 /* remove pair (key, value) from table; return 0 on failure */
00036 int hhh_HashTable_remove(
00037    struct hhh_HashTable *ht, void *key, void (*cleanup)( void *ptr ) );
00038 
00039 /* find value for pair; return NULL if not found */
00040 void *hhh_HashTable_find( struct hhh_HashTable *ht, void *key );
00041 
00042 /* merge one hash table into another */
00043 int hhh_HashTable_merge( struct hhh_HashTable *into, struct hhh_HashTable *from );
00044 
00045 /* delete table and (optional) contents */
00046 void hhh_HashTable_delete( struct hhh_HashTable *ht, void (*cleanup)( void *ptr ) );
00047 
00048 #ifdef __cplusplus
00049 } /* extern "C" */
00050 #endif
00051 
00052 #endif /* !HEPHAESTUS_HASHTABLE_H */
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:06:19 2011 for Hephaestus by doxygen 1.4.7