gdsl  1.8
gdsl_hash.h
Go to the documentation of this file.
00001 /*
00002  * This file is part of the Generic Data Structures Library (GDSL).
00003  * Copyright (C) 1998-2017 Nicolas Darnis <ndarnis@free.fr>.
00004  *
00005  * GDSL is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation, either version 3 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * GDSL is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with GDSL.  If not, see <http://www.gnu.org/licenses/>. 
00017  *
00018  * $RCSfile: gdsl_hash.h,v $
00019  * $Revision: 1.26 $
00020  * $Date: 2015/02/17 12:22:56 $
00021  */
00022 
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 
00042 
00055 typedef struct hash_table* gdsl_hash_t;
00056 
00063 typedef const char* (*gdsl_key_func_t) (void* VALUE
00064                     );
00065 
00071 typedef ulong (*gdsl_hash_func_t) (const char* KEY
00072                    );
00073 
00074 /******************************************************************************/
00075 /* Generic hash function                                                      */
00076 /******************************************************************************/
00077 
00088 extern ulong
00089 gdsl_hash (const char* KEY
00090        );
00091 
00092 /******************************************************************************/
00093 /* Management functions of hashtables                                         */
00094 /******************************************************************************/
00095 
00128 extern gdsl_hash_t
00129 gdsl_hash_alloc (const char* NAME,
00130          gdsl_alloc_func_t ALLOC_F,
00131          gdsl_free_func_t FREE_F,
00132          gdsl_key_func_t KEY_F,
00133          gdsl_hash_func_t HASH_F,
00134          ushort INITIAL_ENTRIES_NB
00135          );
00136 
00150 extern void
00151 gdsl_hash_free (gdsl_hash_t H
00152         );
00153 
00167 extern void
00168 gdsl_hash_flush (gdsl_hash_t H
00169          );
00170 
00171 /******************************************************************************/
00172 /* Consultation functions of hashtables                                       */
00173 /******************************************************************************/
00174 
00184 extern const char*
00185 gdsl_hash_get_name (const gdsl_hash_t H
00186             );
00187 
00197 extern ushort
00198 gdsl_hash_get_entries_number (const gdsl_hash_t H
00199                   );
00200 
00215 extern ushort
00216 gdsl_hash_get_lists_max_size (const gdsl_hash_t H
00217                   );
00218 
00230 extern ushort
00231 gdsl_hash_get_longest_list_size (const gdsl_hash_t H
00232                  );
00233 
00244 extern ulong
00245 gdsl_hash_get_size (const gdsl_hash_t H
00246             );
00247 
00258 extern double
00259 gdsl_hash_get_fill_factor (const gdsl_hash_t H
00260                );
00261 
00262 /******************************************************************************/
00263 /* Modification functions of hashtables                                       */
00264 /******************************************************************************/
00265   
00279 extern gdsl_hash_t
00280 gdsl_hash_set_name (gdsl_hash_t H,
00281             const char* NEW_NAME
00282             );
00283 
00313 extern gdsl_element_t
00314 gdsl_hash_insert (gdsl_hash_t H,
00315           void* VALUE
00316           );
00317   
00334 extern gdsl_element_t
00335 gdsl_hash_remove (gdsl_hash_t H,
00336           const char* KEY
00337           );
00355 extern gdsl_hash_t
00356 gdsl_hash_delete (gdsl_hash_t H,
00357           const char* KEY
00358           );
00359 
00388 extern gdsl_hash_t
00389 gdsl_hash_modify (gdsl_hash_t H, 
00390           ushort NEW_ENTRIES_NB, 
00391           ushort NEW_LISTS_MAX_SIZE
00392           );
00393 
00394 /******************************************************************************/
00395 /* Search functions of hashtables                                             */
00396 /******************************************************************************/
00397 
00413 extern gdsl_element_t
00414 gdsl_hash_search (const gdsl_hash_t H,
00415           const char* KEY
00416           );
00417 
00418 /******************************************************************************/
00419 /* Parse functions of hashtables                                              */
00420 /******************************************************************************/
00421 
00437 extern gdsl_element_t
00438 gdsl_hash_map (const gdsl_hash_t H,
00439            gdsl_map_func_t MAP_F,
00440            void* USER_DATA
00441            );
00442 
00443 /******************************************************************************/
00444 /* Input/output functions of hashtables                                       */
00445 /******************************************************************************/
00446 
00462 extern void
00463 gdsl_hash_write (const gdsl_hash_t H,
00464          gdsl_write_func_t WRITE_F,
00465          FILE* OUTPUT_FILE,
00466          void* USER_DATA
00467          );
00468 
00485 extern void
00486 gdsl_hash_write_xml (const gdsl_hash_t H,
00487              gdsl_write_func_t WRITE_F,
00488              FILE* OUTPUT_FILE,
00489              void* USER_DATA
00490              );
00491 
00508 extern void
00509 gdsl_hash_dump (const gdsl_hash_t H,
00510         gdsl_write_func_t WRITE_F,
00511         FILE* OUTPUT_FILE,
00512         void* USER_DATA
00513         );
00514 
00515 /*
00516  * @}
00517  */
00518 
00519 
00520 #ifdef __cplusplus
00521 }
00522 #endif /* __cplusplus */
00523 
00524 
00525 #endif /* _GDSL_HASH_H_ */
00526 
00527