comparison src/hash.h @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents 74fd4e045ea6
children
comparison
equal deleted inserted replaced
411:12e008d41344 412:697ef44129c6
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. */ 16 Boston, MA 02111-1307, USA. */
17 17
18 /* Synched up with: Not in FSF. */ 18 /* Synched up with: Not in FSF. */
19 19
20 #ifndef INCLUDED_hash_h_ 20 #ifndef _HASH_H_
21 #define INCLUDED_hash_h_ 21 #define _HASH_H_
22 22
23 typedef struct 23 typedef struct
24 { 24 {
25 const void *key; 25 CONST void *key;
26 void *contents; 26 void *contents;
27 } hentry; 27 } hentry;
28 28
29 typedef int (*hash_table_test_function) (const void *, const void *); 29 typedef int (*hash_table_test_function) (CONST void *, CONST void *);
30 typedef unsigned long (*hash_table_hash_function) (const void *); 30 typedef unsigned long (*hash_table_hash_function) (CONST void *);
31 typedef size_t hash_size_t; 31 typedef size_t hash_size_t;
32 32
33 struct hash_table 33 struct hash_table
34 { 34 {
35 hentry *harray; 35 hentry *harray;
55 55
56 /* Free HASH-TABLE and its substructures */ 56 /* Free HASH-TABLE and its substructures */
57 void free_hash_table (struct hash_table *hash_table); 57 void free_hash_table (struct hash_table *hash_table);
58 58
59 /* Returns a hentry whose key is 0 if the entry does not exist in HASH-TABLE */ 59 /* Returns a hentry whose key is 0 if the entry does not exist in HASH-TABLE */
60 const void *gethash (const void *key, struct hash_table *hash_table, 60 CONST void *gethash (CONST void *key, struct hash_table *hash_table,
61 const void **ret_value); 61 CONST void **ret_value);
62 62
63 /* KEY should be different from 0 */ 63 /* KEY should be different from 0 */
64 void puthash (const void *key, void *contents, struct hash_table *hash_table); 64 void puthash (CONST void *key, void *contents, struct hash_table *hash_table);
65 65
66 /* delete the entry with key KEY */ 66 /* delete the entry with key KEY */
67 void remhash (const void *key, struct hash_table *hash_table); 67 void remhash (CONST void *key, struct hash_table *hash_table);
68 68
69 typedef int (*maphash_function) (const void* key, void* contents, void* arg); 69 typedef int (*maphash_function) (CONST void* key, void* contents, void* arg);
70 70
71 typedef int (*remhash_predicate) (const void* key, const void* contents, 71 typedef int (*remhash_predicate) (CONST void* key, CONST void* contents,
72 void* arg); 72 void* arg);
73 73
74 /* Call MF (key, contents, arg) for every entry in HASH-TABLE */ 74 /* Call MF (key, contents, arg) for every entry in HASH-TABLE */
75 void maphash (maphash_function mf, struct hash_table *hash_table, void* arg); 75 void maphash (maphash_function mf, struct hash_table *hash_table, void* arg);
76 76
77 /* Delete all objects from HASH-TABLE satisfying PREDICATE */ 77 /* Delete all objects from HASH-TABLE satisfying PREDICATE */
78 void map_remhash (remhash_predicate predicate, 78 void map_remhash (remhash_predicate predicate,
79 struct hash_table *hash_table, void *arg); 79 struct hash_table *hash_table, void *arg);
80 80
81 #endif /* INCLUDED_hash_h_ */ 81 #endif /* _HASH_H_ */