1 /* GNU m4 -- A simple macro processor
2 Copyright (C) 2001, 2006-2007, 2010, 2013-2014, 2017 Free Software
4 Written by Gary V. Vaughan <gary@gnu.org>
6 This file is part of GNU M4.
8 GNU M4 is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 GNU M4 is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include <m4/system.h>
27 /* Must be 1 less than a power of 2 for the resize algorithm to
29 #define M4_HASH_DEFAULT_SIZE 511
31 /* When the average number of values per bucket breaks this value
32 the table will be grown to reduce the density accordingly. */
33 #define M4_HASH_MAXIMUM_DENSITY 3.0
37 typedef struct m4_hash m4_hash
;
39 typedef size_t m4_hash_hash_func (const void *key
);
40 typedef int m4_hash_cmp_func (const void *key
, const void *try);
41 typedef void * m4_hash_copy_func (m4_hash
*src
, const void *key
, void *value
,
44 extern m4_hash
*m4_hash_new (size_t size
, m4_hash_hash_func
*hash_func
,
45 m4_hash_cmp_func
*cmp_func
);
46 extern m4_hash
*m4_hash_dup (m4_hash
*hash
, m4_hash_copy_func
*copy
);
47 extern void m4_hash_delete (m4_hash
*hash
);
48 extern void m4_hash_exit (void);
50 extern size_t m4_get_hash_length (m4_hash
*hash
);
52 extern void ** m4_hash_lookup (m4_hash
*hash
, const void *key
);
53 extern void * m4_hash_remove (m4_hash
*hash
, const void *key
);
54 extern const void * m4_hash_insert (m4_hash
*hash
, const void *key
,
59 extern size_t m4_hash_string_hash (const void *key
);
60 extern int m4_hash_string_cmp (const void *key
, const void *try);
64 typedef struct m4_hash_iterator m4_hash_iterator
;
65 typedef void * m4_hash_apply_func (m4_hash
*hash
, const void *key
,
66 void *value
, void *userdata
);
68 extern void * m4_hash_apply (m4_hash
*hash
, m4_hash_apply_func
*func
,
71 extern const void * m4_get_hash_iterator_key (m4_hash_iterator
*place
);
72 extern void * m4_get_hash_iterator_value (m4_hash_iterator
*place
);
73 extern m4_hash_iterator
*m4_get_hash_iterator_next (const m4_hash
*hash
,
74 m4_hash_iterator
*place
);
75 extern void m4_free_hash_iterator (const m4_hash
*hash
,
76 m4_hash_iterator
*place
);
81 #endif /* !M4_HASH_H */