1/* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GLib Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GLib at ftp://ftp.gtk.org/pub/gtk/.
23 */
24
25#ifndef __G_HASH_H__
26#define __G_HASH_H__
27
28#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
29#error "Only <glib.h> can be included directly."
30#endif
31
32#include <glib/gtypes.h>
33#include <glib/glist.h>
34
35G_BEGIN_DECLS
36
37typedef struct _GHashTable GHashTable;
38
39typedef gboolean (*GHRFunc) (gpointer key,
40 gpointer value,
41 gpointer user_data);
42
43typedef struct _GHashTableIter GHashTableIter;
44
45struct _GHashTableIter
46{
47 /*< private >*/
48 gpointer dummy1;
49 gpointer dummy2;
50 gpointer dummy3;
51 int dummy4;
52 gboolean dummy5;
53 gpointer dummy6;
54};
55
56GLIB_AVAILABLE_IN_ALL
57GHashTable* g_hash_table_new (GHashFunc hash_func,
58 GEqualFunc key_equal_func);
59GLIB_AVAILABLE_IN_ALL
60GHashTable* g_hash_table_new_full (GHashFunc hash_func,
61 GEqualFunc key_equal_func,
62 GDestroyNotify key_destroy_func,
63 GDestroyNotify value_destroy_func);
64GLIB_AVAILABLE_IN_ALL
65void g_hash_table_destroy (GHashTable *hash_table);
66GLIB_AVAILABLE_IN_ALL
67gboolean g_hash_table_insert (GHashTable *hash_table,
68 gpointer key,
69 gpointer value);
70GLIB_AVAILABLE_IN_ALL
71gboolean g_hash_table_replace (GHashTable *hash_table,
72 gpointer key,
73 gpointer value);
74GLIB_AVAILABLE_IN_ALL
75gboolean g_hash_table_add (GHashTable *hash_table,
76 gpointer key);
77GLIB_AVAILABLE_IN_ALL
78gboolean g_hash_table_remove (GHashTable *hash_table,
79 gconstpointer key);
80GLIB_AVAILABLE_IN_ALL
81void g_hash_table_remove_all (GHashTable *hash_table);
82GLIB_AVAILABLE_IN_ALL
83gboolean g_hash_table_steal (GHashTable *hash_table,
84 gconstpointer key);
85GLIB_AVAILABLE_IN_2_58
86gboolean g_hash_table_steal_extended (GHashTable *hash_table,
87 gconstpointer lookup_key,
88 gpointer *stolen_key,
89 gpointer *stolen_value);
90GLIB_AVAILABLE_IN_ALL
91void g_hash_table_steal_all (GHashTable *hash_table);
92GLIB_AVAILABLE_IN_ALL
93gpointer g_hash_table_lookup (GHashTable *hash_table,
94 gconstpointer key);
95GLIB_AVAILABLE_IN_ALL
96gboolean g_hash_table_contains (GHashTable *hash_table,
97 gconstpointer key);
98GLIB_AVAILABLE_IN_ALL
99gboolean g_hash_table_lookup_extended (GHashTable *hash_table,
100 gconstpointer lookup_key,
101 gpointer *orig_key,
102 gpointer *value);
103GLIB_AVAILABLE_IN_ALL
104void g_hash_table_foreach (GHashTable *hash_table,
105 GHFunc func,
106 gpointer user_data);
107GLIB_AVAILABLE_IN_ALL
108gpointer g_hash_table_find (GHashTable *hash_table,
109 GHRFunc predicate,
110 gpointer user_data);
111GLIB_AVAILABLE_IN_ALL
112guint g_hash_table_foreach_remove (GHashTable *hash_table,
113 GHRFunc func,
114 gpointer user_data);
115GLIB_AVAILABLE_IN_ALL
116guint g_hash_table_foreach_steal (GHashTable *hash_table,
117 GHRFunc func,
118 gpointer user_data);
119GLIB_AVAILABLE_IN_ALL
120guint g_hash_table_size (GHashTable *hash_table);
121GLIB_AVAILABLE_IN_ALL
122GList * g_hash_table_get_keys (GHashTable *hash_table);
123GLIB_AVAILABLE_IN_ALL
124GList * g_hash_table_get_values (GHashTable *hash_table);
125GLIB_AVAILABLE_IN_2_40
126gpointer * g_hash_table_get_keys_as_array (GHashTable *hash_table,
127 guint *length);
128
129GLIB_AVAILABLE_IN_ALL
130void g_hash_table_iter_init (GHashTableIter *iter,
131 GHashTable *hash_table);
132GLIB_AVAILABLE_IN_ALL
133gboolean g_hash_table_iter_next (GHashTableIter *iter,
134 gpointer *key,
135 gpointer *value);
136GLIB_AVAILABLE_IN_ALL
137GHashTable* g_hash_table_iter_get_hash_table (GHashTableIter *iter);
138GLIB_AVAILABLE_IN_ALL
139void g_hash_table_iter_remove (GHashTableIter *iter);
140GLIB_AVAILABLE_IN_2_30
141void g_hash_table_iter_replace (GHashTableIter *iter,
142 gpointer value);
143GLIB_AVAILABLE_IN_ALL
144void g_hash_table_iter_steal (GHashTableIter *iter);
145
146GLIB_AVAILABLE_IN_ALL
147GHashTable* g_hash_table_ref (GHashTable *hash_table);
148GLIB_AVAILABLE_IN_ALL
149void g_hash_table_unref (GHashTable *hash_table);
150
151#define g_hash_table_freeze(hash_table) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26
152#define g_hash_table_thaw(hash_table) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26
153
154/* Hash Functions
155 */
156GLIB_AVAILABLE_IN_ALL
157gboolean g_str_equal (gconstpointer v1,
158 gconstpointer v2);
159GLIB_AVAILABLE_IN_ALL
160guint g_str_hash (gconstpointer v);
161
162GLIB_AVAILABLE_IN_ALL
163gboolean g_int_equal (gconstpointer v1,
164 gconstpointer v2);
165GLIB_AVAILABLE_IN_ALL
166guint g_int_hash (gconstpointer v);
167
168GLIB_AVAILABLE_IN_ALL
169gboolean g_int64_equal (gconstpointer v1,
170 gconstpointer v2);
171GLIB_AVAILABLE_IN_ALL
172guint g_int64_hash (gconstpointer v);
173
174GLIB_AVAILABLE_IN_ALL
175gboolean g_double_equal (gconstpointer v1,
176 gconstpointer v2);
177GLIB_AVAILABLE_IN_ALL
178guint g_double_hash (gconstpointer v);
179
180GLIB_AVAILABLE_IN_ALL
181guint g_direct_hash (gconstpointer v) G_GNUC_CONST;
182GLIB_AVAILABLE_IN_ALL
183gboolean g_direct_equal (gconstpointer v1,
184 gconstpointer v2) G_GNUC_CONST;
185
186G_END_DECLS
187
188#endif /* __G_HASH_H__ */
189

source code of gtk/subprojects/glib/glib/ghash.h