gdsl  1.8
gdsl_hash.h
Go to the documentation of this file.
00001 
00027 #ifndef _GDSL_HASH_H_
00028 #define _GDSL_HASH_H_
00029 
00030 
00031 #include <stdio.h>
00032 
00033 
00034 #include "gdsl_types.h"
00035 
00036 
00037 #ifdef __cplusplus
00038 extern "C" 
00039 {
00040 #endif /* __cplusplus */
00041 
00072 typedef struct hash_table* gdsl_hash_t;
00073 
00080 typedef const char* (*gdsl_key_func_t) (void* VALUE
00081                     );
00082 
00088 typedef ulong (*gdsl_hash_func_t) (const char* KEY
00089                    );
00090 
00091 /******************************************************************************/
00092 /* Generic hash function                                                      */
00093 /******************************************************************************/
00094 
00105 extern ulong
00106 gdsl_hash (const char* KEY
00107        );
00108 
00109 /******************************************************************************/
00110 /* Management functions of hashtables                                         */
00111 /******************************************************************************/
00112 
00145 extern gdsl_hash_t
00146 gdsl_hash_alloc (const char* NAME,
00147          gdsl_alloc_func_t ALLOC_F,
00148          gdsl_free_func_t FREE_F,
00149          gdsl_key_func_t KEY_F,
00150          gdsl_hash_func_t HASH_F,
00151          ushort INITIAL_ENTRIES_NB
00152          );
00153 
00167 extern void
00168 gdsl_hash_free (gdsl_hash_t H
00169         );
00170 
00184 extern void
00185 gdsl_hash_flush (gdsl_hash_t H
00186          );
00187 
00188 /******************************************************************************/
00189 /* Consultation functions of hashtables                                       */
00190 /******************************************************************************/
00191 
00201 extern const char*
00202 gdsl_hash_get_name (const gdsl_hash_t H
00203             );
00204 
00214 extern ushort
00215 gdsl_hash_get_entries_number (const gdsl_hash_t H
00216                   );
00217 
00232 extern ushort
00233 gdsl_hash_get_lists_max_size (const gdsl_hash_t H
00234                   );
00235 
00247 extern ushort
00248 gdsl_hash_get_longest_list_size (const gdsl_hash_t H
00249                  );
00250 
00261 extern ulong
00262 gdsl_hash_get_size (const gdsl_hash_t H
00263             );
00264 
00275 extern double
00276 gdsl_hash_get_fill_factor (const gdsl_hash_t H
00277                );
00278 
00279 /******************************************************************************/
00280 /* Modification functions of hashtables                                       */
00281 /******************************************************************************/
00282   
00296 extern gdsl_hash_t
00297 gdsl_hash_set_name (gdsl_hash_t H,
00298             const char* NEW_NAME
00299             );
00300 
00330 extern gdsl_element_t
00331 gdsl_hash_insert (gdsl_hash_t H,
00332           void* VALUE
00333           );
00334   
00351 extern gdsl_element_t
00352 gdsl_hash_remove (gdsl_hash_t H,
00353           const char* KEY
00354           );
00372 extern gdsl_hash_t
00373 gdsl_hash_delete (gdsl_hash_t H,
00374           const char* KEY
00375           );
00376 
00405 extern gdsl_hash_t
00406 gdsl_hash_modify (gdsl_hash_t H, 
00407           ushort NEW_ENTRIES_NB, 
00408           ushort NEW_LISTS_MAX_SIZE
00409           );
00410 
00411 /******************************************************************************/
00412 /* Search functions of hashtables                                             */
00413 /******************************************************************************/
00414 
00430 extern gdsl_element_t
00431 gdsl_hash_search (const gdsl_hash_t H,
00432           const char* KEY
00433           );
00434 
00435 /******************************************************************************/
00436 /* Parse functions of hashtables                                              */
00437 /******************************************************************************/
00438 
00454 extern gdsl_element_t
00455 gdsl_hash_map (const gdsl_hash_t H,
00456            gdsl_map_func_t MAP_F,
00457            void* USER_DATA
00458            );
00459 
00460 /******************************************************************************/
00461 /* Input/output functions of hashtables                                       */
00462 /******************************************************************************/
00463 
00479 extern void
00480 gdsl_hash_write (const gdsl_hash_t H,
00481          gdsl_write_func_t WRITE_F,
00482          FILE* OUTPUT_FILE,
00483          void* USER_DATA
00484          );
00485 
00502 extern void
00503 gdsl_hash_write_xml (const gdsl_hash_t H,
00504              gdsl_write_func_t WRITE_F,
00505              FILE* OUTPUT_FILE,
00506              void* USER_DATA
00507              );
00508 
00525 extern void
00526 gdsl_hash_dump (const gdsl_hash_t H,
00527         gdsl_write_func_t WRITE_F,
00528         FILE* OUTPUT_FILE,
00529         void* USER_DATA
00530         );
00531 
00532 
00538 #ifdef __cplusplus
00539 }
00540 #endif /* __cplusplus */
00541 
00542 
00543 #endif /* _GDSL_HASH_H_ */
00544 
00545