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-2006 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_8h-source.html,v $
00021  * $Revision: 1.10 $
00022  * $Date: 2006/06/22 09:16:01 $
00023  */
00024 
00025 
00026 #ifndef _GDSL_HASH_H_
00027 #define _GDSL_HASH_H_
00028 
00029 
00030 #include <stdio.h>
00031 
00032 
00033 #include "gdsl_types.h"
00034 
00035 
00036 #ifdef __cplusplus
00037 extern "C" 
00038 {
00039 #endif /* __cplusplus */
00040 
00041 
00054 typedef struct hash_table* gdsl_hash_t;
00055 
00062 typedef const char* (*gdsl_key_func_t) (void* VALUE
00063                     );
00064 
00070 typedef ulong (*gdsl_hash_func_t) (const char* KEY
00071                    );
00072 
00073 /******************************************************************************/
00074 /* Generic hash function                                                      */
00075 /******************************************************************************/
00076 
00087 extern ulong
00088 gdsl_hash (const char* KEY
00089        );
00090 
00091 /******************************************************************************/
00092 /* Management functions of hashtables                                         */
00093 /******************************************************************************/
00094 
00127 extern gdsl_hash_t
00128 gdsl_hash_alloc (const char* NAME,
00129          gdsl_alloc_func_t ALLOC_F,
00130          gdsl_free_func_t FREE_F,
00131          gdsl_key_func_t KEY_F,
00132          gdsl_hash_func_t HASH_F,
00133          ushort INITIAL_ENTRIES_NB
00134          );
00135 
00149 extern void
00150 gdsl_hash_free (gdsl_hash_t H
00151         );
00152 
00166 extern void
00167 gdsl_hash_flush (gdsl_hash_t H
00168          );
00169 
00170 /******************************************************************************/
00171 /* Consultation functions of hashtables                                       */
00172 /******************************************************************************/
00173 
00183 extern const char*
00184 gdsl_hash_get_name (const gdsl_hash_t H
00185             );
00186 
00196 extern ushort
00197 gdsl_hash_get_entries_number (const gdsl_hash_t H
00198                   );
00199 
00214 extern ushort
00215 gdsl_hash_get_lists_max_size (const gdsl_hash_t H
00216                   );
00217 
00229 extern ushort
00230 gdsl_hash_get_longest_list_size (const gdsl_hash_t H
00231                  );
00232 
00243 extern ulong
00244 gdsl_hash_get_size (const gdsl_hash_t H
00245             );
00246 
00257 extern double
00258 gdsl_hash_get_fill_factor (const gdsl_hash_t H
00259                );
00260 
00261 /******************************************************************************/
00262 /* Modification functions of hashtables                                       */
00263 /******************************************************************************/
00264   
00278 extern gdsl_hash_t
00279 gdsl_hash_set_name (gdsl_hash_t H,
00280             const char* NEW_NAME
00281             );
00282 
00312 extern gdsl_element_t
00313 gdsl_hash_insert (gdsl_hash_t H,
00314           void* VALUE
00315           );
00316   
00333 extern gdsl_element_t
00334 gdsl_hash_remove (gdsl_hash_t H,
00335           const char* KEY
00336           );
00354 extern gdsl_hash_t
00355 gdsl_hash_delete (gdsl_hash_t H,
00356           const char* KEY
00357           );
00358 
00387 extern gdsl_hash_t
00388 gdsl_hash_modify (gdsl_hash_t H, 
00389           ushort NEW_ENTRIES_NB, 
00390           ushort NEW_LISTS_MAX_SIZE
00391           );
00392 
00393 /******************************************************************************/
00394 /* Search functions of hashtables                                             */
00395 /******************************************************************************/
00396 
00412 extern gdsl_element_t
00413 gdsl_hash_search (const gdsl_hash_t H,
00414           const char* KEY
00415           );
00416 
00417 /******************************************************************************/
00418 /* Parse functions of hashtables                                              */
00419 /******************************************************************************/
00420 
00436 extern gdsl_element_t
00437 gdsl_hash_map (const gdsl_hash_t H,
00438            gdsl_map_func_t MAP_F,
00439            void* USER_DATA
00440            );
00441 
00442 /******************************************************************************/
00443 /* Input/output functions of hashtables                                       */
00444 /******************************************************************************/
00445 
00461 extern void
00462 gdsl_hash_write (const gdsl_hash_t H,
00463          gdsl_write_func_t WRITE_F,
00464          FILE* OUTPUT_FILE,
00465          void* USER_DATA
00466          );
00467 
00484 extern void
00485 gdsl_hash_write_xml (const gdsl_hash_t H,
00486              gdsl_write_func_t WRITE_F,
00487              FILE* OUTPUT_FILE,
00488              void* USER_DATA
00489              );
00490 
00507 extern void
00508 gdsl_hash_dump (const gdsl_hash_t H,
00509         gdsl_write_func_t WRITE_F,
00510         FILE* OUTPUT_FILE,
00511         void* USER_DATA
00512         );
00513 
00514 /*
00515  * @}
00516  */
00517 
00518 
00519 #ifdef __cplusplus
00520 }
00521 #endif /* __cplusplus */
00522 
00523 
00524 #endif /* _GDSL_HASH_H_ */
00525 
00526 

Generated on Thu Jun 22 11:15:30 2006 for gdsl by  doxygen 1.4.6