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-2015 Nicolas Darnis <ndarnis@free.fr>.
00004  *
00005  * The GDSL library is free software; you can redistribute it and/or 
00006  * modify it under the terms of the GNU General Public License as 
00007  * published by the Free Software Foundation; either version 2 of
00008  * the License, or (at your option) any later version.
00009  *
00010  * The GDSL library 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 the GDSL library; see the file COPYING.
00017  * If not, write to the Free Software Foundation, Inc., 
00018  * 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
00019  *
00020  * $RCSfile: gdsl_hash.h,v $
00021  * $Revision: 1.26 $
00022  * $Date: 2015/02/17 12:22:56 $
00023  */
00024 
00029 #ifndef _GDSL_HASH_H_
00030 #define _GDSL_HASH_H_
00031 
00032 
00033 #include <stdio.h>
00034 
00035 
00036 #include "gdsl_types.h"
00037 
00038 
00039 #ifdef __cplusplus
00040 extern "C" 
00041 {
00042 #endif /* __cplusplus */
00043 
00044 
00057 typedef struct hash_table* gdsl_hash_t;
00058 
00065 typedef const char* (*gdsl_key_func_t) (void* VALUE
00066                     );
00067 
00073 typedef ulong (*gdsl_hash_func_t) (const char* KEY
00074                    );
00075 
00076 /******************************************************************************/
00077 /* Generic hash function                                                      */
00078 /******************************************************************************/
00079 
00090 extern ulong
00091 gdsl_hash (const char* KEY
00092        );
00093 
00094 /******************************************************************************/
00095 /* Management functions of hashtables                                         */
00096 /******************************************************************************/
00097 
00130 extern gdsl_hash_t
00131 gdsl_hash_alloc (const char* NAME,
00132          gdsl_alloc_func_t ALLOC_F,
00133          gdsl_free_func_t FREE_F,
00134          gdsl_key_func_t KEY_F,
00135          gdsl_hash_func_t HASH_F,
00136          ushort INITIAL_ENTRIES_NB
00137          );
00138 
00152 extern void
00153 gdsl_hash_free (gdsl_hash_t H
00154         );
00155 
00169 extern void
00170 gdsl_hash_flush (gdsl_hash_t H
00171          );
00172 
00173 /******************************************************************************/
00174 /* Consultation functions of hashtables                                       */
00175 /******************************************************************************/
00176 
00186 extern const char*
00187 gdsl_hash_get_name (const gdsl_hash_t H
00188             );
00189 
00199 extern ushort
00200 gdsl_hash_get_entries_number (const gdsl_hash_t H
00201                   );
00202 
00217 extern ushort
00218 gdsl_hash_get_lists_max_size (const gdsl_hash_t H
00219                   );
00220 
00232 extern ushort
00233 gdsl_hash_get_longest_list_size (const gdsl_hash_t H
00234                  );
00235 
00246 extern ulong
00247 gdsl_hash_get_size (const gdsl_hash_t H
00248             );
00249 
00260 extern double
00261 gdsl_hash_get_fill_factor (const gdsl_hash_t H
00262                );
00263 
00264 /******************************************************************************/
00265 /* Modification functions of hashtables                                       */
00266 /******************************************************************************/
00267   
00281 extern gdsl_hash_t
00282 gdsl_hash_set_name (gdsl_hash_t H,
00283             const char* NEW_NAME
00284             );
00285 
00315 extern gdsl_element_t
00316 gdsl_hash_insert (gdsl_hash_t H,
00317           void* VALUE
00318           );
00319   
00336 extern gdsl_element_t
00337 gdsl_hash_remove (gdsl_hash_t H,
00338           const char* KEY
00339           );
00357 extern gdsl_hash_t
00358 gdsl_hash_delete (gdsl_hash_t H,
00359           const char* KEY
00360           );
00361 
00390 extern gdsl_hash_t
00391 gdsl_hash_modify (gdsl_hash_t H, 
00392           ushort NEW_ENTRIES_NB, 
00393           ushort NEW_LISTS_MAX_SIZE
00394           );
00395 
00396 /******************************************************************************/
00397 /* Search functions of hashtables                                             */
00398 /******************************************************************************/
00399 
00415 extern gdsl_element_t
00416 gdsl_hash_search (const gdsl_hash_t H,
00417           const char* KEY
00418           );
00419 
00420 /******************************************************************************/
00421 /* Parse functions of hashtables                                              */
00422 /******************************************************************************/
00423 
00439 extern gdsl_element_t
00440 gdsl_hash_map (const gdsl_hash_t H,
00441            gdsl_map_func_t MAP_F,
00442            void* USER_DATA
00443            );
00444 
00445 /******************************************************************************/
00446 /* Input/output functions of hashtables                                       */
00447 /******************************************************************************/
00448 
00464 extern void
00465 gdsl_hash_write (const gdsl_hash_t H,
00466          gdsl_write_func_t WRITE_F,
00467          FILE* OUTPUT_FILE,
00468          void* USER_DATA
00469          );
00470 
00487 extern void
00488 gdsl_hash_write_xml (const gdsl_hash_t H,
00489              gdsl_write_func_t WRITE_F,
00490              FILE* OUTPUT_FILE,
00491              void* USER_DATA
00492              );
00493 
00510 extern void
00511 gdsl_hash_dump (const gdsl_hash_t H,
00512         gdsl_write_func_t WRITE_F,
00513         FILE* OUTPUT_FILE,
00514         void* USER_DATA
00515         );
00516 
00517 /*
00518  * @}
00519  */
00520 
00521 
00522 #ifdef __cplusplus
00523 }
00524 #endif /* __cplusplus */
00525 
00526 
00527 #endif /* _GDSL_HASH_H_ */
00528 
00529