Main Page | Modules | File List | Globals

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-2004 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.4 $
00022  * $Date: 2004/10/03 14:35:38 $
00023  */
00024 
00025 #ifndef _GDSL_HASH_H_
00026 #define _GDSL_HASH_H_
00027 
00028 
00029 #include <stdio.h>
00030 
00031 
00032 #include "gdsl_types.h"
00033 
00034 
00035 #ifdef __cplusplus
00036 extern "C" 
00037 {
00038 #endif /* __cplusplus */
00039 
00040 
00053 typedef struct hash_table* gdsl_hash_t;
00054 
00061 typedef const char* (*gdsl_key_func_t) (void* VALUE
00062                     );
00063 
00069 typedef const ulong (*gdsl_hash_func_t) (const char* KEY
00070                      );
00071 
00072 /******************************************************************************/
00073 /* Generic hash function                                                      */
00074 /******************************************************************************/
00075 
00086 extern const ulong
00087 gdsl_hash (const char* KEY
00088        );
00089 
00090 /******************************************************************************/
00091 /* Management functions of hashtables                                         */
00092 /******************************************************************************/
00093 
00126 extern gdsl_hash_t
00127 gdsl_hash_alloc (const char* NAME,
00128          gdsl_alloc_func_t ALLOC_F,
00129          gdsl_free_func_t FREE_F,
00130          gdsl_key_func_t KEY_F,
00131          gdsl_hash_func_t HASH_F,
00132          ushort INITIAL_ENTRIES_NB
00133          );
00134 
00148 extern void
00149 gdsl_hash_free (gdsl_hash_t H
00150         );
00151 
00165 extern void
00166 gdsl_hash_flush (gdsl_hash_t H
00167          );
00168 
00169 /******************************************************************************/
00170 /* Consultation functions of hashtables                                       */
00171 /******************************************************************************/
00172 
00182 extern const char*
00183 gdsl_hash_get_name (const gdsl_hash_t H
00184             );
00185 
00195 extern ushort
00196 gdsl_hash_get_entries_number (const gdsl_hash_t H
00197                   );
00198 
00213 extern ushort
00214 gdsl_hash_get_lists_max_size (const gdsl_hash_t H
00215                   );
00216 
00228 extern ushort
00229 gdsl_hash_get_longest_list_size (const gdsl_hash_t H
00230                  );
00231 
00242 extern ulong
00243 gdsl_hash_get_size (const gdsl_hash_t H
00244             );
00245 
00256 extern double
00257 gdsl_hash_get_fill_factor (const gdsl_hash_t H
00258                );
00259 
00260 /******************************************************************************/
00261 /* Modification functions of hashtables                                       */
00262 /******************************************************************************/
00263   
00277 extern gdsl_hash_t
00278 gdsl_hash_set_name (gdsl_hash_t H,
00279             const char* NEW_NAME
00280             );
00281 
00311 extern gdsl_element_t
00312 gdsl_hash_insert (gdsl_hash_t H,
00313           void *VALUE
00314           );
00315   
00332 extern gdsl_element_t
00333 gdsl_hash_remove (gdsl_hash_t H,
00334           const char* KEY
00335           );
00353 extern gdsl_hash_t
00354 gdsl_hash_delete (gdsl_hash_t H,
00355           const char* KEY
00356           );
00357 
00386 extern gdsl_hash_t
00387 gdsl_hash_modify (gdsl_hash_t H, 
00388           ushort NEW_ENTRIES_NB, 
00389           ushort NEW_LISTS_MAX_SIZE
00390           );
00391 
00392 /******************************************************************************/
00393 /* Search functions of hashtables                                             */
00394 /******************************************************************************/
00395 
00411 extern gdsl_element_t
00412 gdsl_hash_search (const gdsl_hash_t H,
00413           const char* KEY
00414           );
00415 
00416 /******************************************************************************/
00417 /* Parse functions of hashtables                                              */
00418 /******************************************************************************/
00419 
00435 extern gdsl_element_t
00436 gdsl_hash_map (const gdsl_hash_t H,
00437            gdsl_map_func_t MAP_F,
00438            void *USER_DATA
00439            );
00440 
00441 /******************************************************************************/
00442 /* Input/output functions of hashtables                                       */
00443 /******************************************************************************/
00444 
00460 extern void
00461 gdsl_hash_write (const gdsl_hash_t H,
00462          gdsl_write_func_t WRITE_F,
00463          FILE *OUTPUT_FILE,
00464          void *USER_DATA
00465          );
00466 
00483 extern void
00484 gdsl_hash_write_xml (const gdsl_hash_t H,
00485              gdsl_write_func_t WRITE_F,
00486              FILE *OUTPUT_FILE,
00487              void *USER_DATA
00488              );
00489 
00506 extern void
00507 gdsl_hash_dump (const gdsl_hash_t H,
00508         gdsl_write_func_t WRITE_F,
00509         FILE *OUTPUT_FILE,
00510         void *USER_DATA
00511         );
00512 
00513 /*
00514  * @}
00515  */
00516 
00517 
00518 #ifdef __cplusplus
00519 }
00520 #endif /* __cplusplus */
00521 
00522 
00523 #endif /* _GDSL_HASH_H_ */
00524 

Generated on Sun Oct 3 16:15:50 2004 for GDSL by doxygen 1.3.5