1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 *
4 * This file is not part of the GNU gettext program, but is used with
5 * GNU gettext.
6 *
7 * The original copyright notice is as follows:
8 */
9
10 /* GLIB - Library of useful routines for C programming
11 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the
25 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 * Boston, MA 02111-1307, USA.
27 */
28
29 /*
30 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
31 * file for a list of people on the GLib Team. See the ChangeLog
32 * files for a list of changes. These files are distributed with
33 * GLib at ftp://ftp.gtk.org/pub/gtk/.
34 */
35
36 /*
37 * Modified by Bruno Haible for use as a gnulib module.
38 */
39
40 #ifndef __G_HASH_H__
41 #define __G_HASH_H__
42
43 #include <glib/gtypes.h>
44
45 G_BEGIN_DECLS
46
47 typedef struct _GHashTable GHashTable;
48
49 typedef gboolean (*GHRFunc) (gpointer key,
50 gpointer value,
51 gpointer user_data);
52
53 /* Hash tables
54 */
55 GHashTable* g_hash_table_new (GHashFunc hash_func,
56 GEqualFunc key_equal_func);
57 GHashTable* g_hash_table_new_full (GHashFunc hash_func,
58 GEqualFunc key_equal_func,
59 GDestroyNotify key_destroy_func,
60 GDestroyNotify value_destroy_func);
61 #if 0
62 void g_hash_table_destroy (GHashTable *hash_table);
63 #endif
64 void g_hash_table_insert (GHashTable *hash_table,
65 gpointer key,
66 gpointer value);
67 #if 0
68 void g_hash_table_replace (GHashTable *hash_table,
69 gpointer key,
70 gpointer value);
71 gboolean g_hash_table_remove (GHashTable *hash_table,
72 gconstpointer key);
73 void g_hash_table_remove_all (GHashTable *hash_table);
74 gboolean g_hash_table_steal (GHashTable *hash_table,
75 gconstpointer key);
76 void g_hash_table_steal_all (GHashTable *hash_table);
77 #endif
78 gpointer g_hash_table_lookup (GHashTable *hash_table,
79 gconstpointer key);
80 #if 0
81 gboolean g_hash_table_lookup_extended (GHashTable *hash_table,
82 gconstpointer lookup_key,
83 gpointer *orig_key,
84 gpointer *value);
85 void g_hash_table_foreach (GHashTable *hash_table,
86 GHFunc func,
87 gpointer user_data);
88 gpointer g_hash_table_find (GHashTable *hash_table,
89 GHRFunc predicate,
90 gpointer user_data);
91 guint g_hash_table_foreach_remove (GHashTable *hash_table,
92 GHRFunc func,
93 gpointer user_data);
94 guint g_hash_table_foreach_steal (GHashTable *hash_table,
95 GHRFunc func,
96 gpointer user_data);
97 guint g_hash_table_size (GHashTable *hash_table);
98
99 /* keeping hash tables alive */
100 GHashTable* g_hash_table_ref (GHashTable *hash_table);
101 void g_hash_table_unref (GHashTable *hash_table);
102
103 #ifndef G_DISABLE_DEPRECATED
104
105 /* The following two functions are deprecated and will be removed in
106 * the next major release. They do no good. */
107 #define g_hash_table_freeze(hash_table) ((void)0)
108 #define g_hash_table_thaw(hash_table) ((void)0)
109
110 #endif /* G_DISABLE_DEPRECATED */
111
112 #endif
113
114 /* Hash Functions
115 */
116 gboolean g_str_equal (gconstpointer v1,
117 gconstpointer v2);
118 guint g_str_hash (gconstpointer v);
119
120 #if 0
121
122 gboolean g_int_equal (gconstpointer v1,
123 gconstpointer v2);
124 guint g_int_hash (gconstpointer v);
125
126 /* This "hash" function will just return the key's address as an
127 * unsigned integer. Useful for hashing on plain addresses or
128 * simple integer values.
129 * Passing NULL into g_hash_table_new() as GHashFunc has the
130 * same effect as passing g_direct_hash().
131 */
132 guint g_direct_hash (gconstpointer v) G_GNUC_CONST;
133 gboolean g_direct_equal (gconstpointer v1,
134 gconstpointer v2) G_GNUC_CONST;
135
136 #endif
137
138 G_END_DECLS
139
140 #endif /* __G_HASH_H__ */
141