Add g_key_file_load_from_dirs for looking through a search path for a
[platform/upstream/glib.git] / glib / ghash.h
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 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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GLib Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #ifndef __G_HASH_H__
28 #define __G_HASH_H__
29
30 #include <glib/gtypes.h>
31 #include <glib/glist.h>
32
33 G_BEGIN_DECLS
34
35 typedef struct _GHashTable  GHashTable;
36
37 typedef gboolean  (*GHRFunc)  (gpointer  key,
38                                gpointer  value,
39                                gpointer  user_data);
40
41 /* Hash tables
42  */
43 GHashTable* g_hash_table_new               (GHashFunc       hash_func,
44                                             GEqualFunc      key_equal_func);
45 GHashTable* g_hash_table_new_full          (GHashFunc       hash_func,
46                                             GEqualFunc      key_equal_func,
47                                             GDestroyNotify  key_destroy_func,
48                                             GDestroyNotify  value_destroy_func);
49 void        g_hash_table_destroy           (GHashTable     *hash_table);
50 void        g_hash_table_insert            (GHashTable     *hash_table,
51                                             gpointer        key,
52                                             gpointer        value);
53 void        g_hash_table_replace           (GHashTable     *hash_table,
54                                             gpointer        key,
55                                             gpointer        value);
56 gboolean    g_hash_table_remove            (GHashTable     *hash_table,
57                                             gconstpointer   key);
58 void        g_hash_table_remove_all        (GHashTable     *hash_table);
59 gboolean    g_hash_table_steal             (GHashTable     *hash_table,
60                                             gconstpointer   key);
61 void        g_hash_table_steal_all         (GHashTable     *hash_table);
62 gpointer    g_hash_table_lookup            (GHashTable     *hash_table,
63                                             gconstpointer   key);
64 gboolean    g_hash_table_lookup_extended   (GHashTable     *hash_table,
65                                             gconstpointer   lookup_key,
66                                             gpointer       *orig_key,
67                                             gpointer       *value);
68 void        g_hash_table_foreach           (GHashTable     *hash_table,
69                                             GHFunc          func,
70                                             gpointer        user_data);
71 gpointer    g_hash_table_find              (GHashTable     *hash_table,
72                                             GHRFunc         predicate,
73                                             gpointer        user_data);
74 guint       g_hash_table_foreach_remove    (GHashTable     *hash_table,
75                                             GHRFunc         func,
76                                             gpointer        user_data);
77 guint       g_hash_table_foreach_steal     (GHashTable     *hash_table,
78                                             GHRFunc         func,
79                                             gpointer        user_data);
80 guint       g_hash_table_size              (GHashTable     *hash_table);
81 GList *     g_hash_table_get_keys          (GHashTable     *hash_table);
82 GList *     g_hash_table_get_values        (GHashTable     *hash_table);
83
84 /* keeping hash tables alive */
85 GHashTable* g_hash_table_ref               (GHashTable     *hash_table);
86 void        g_hash_table_unref             (GHashTable     *hash_table);
87
88 #ifndef G_DISABLE_DEPRECATED
89
90 /* The following two functions are deprecated and will be removed in
91  * the next major release. They do no good. */
92 #define g_hash_table_freeze(hash_table) ((void)0)
93 #define g_hash_table_thaw(hash_table) ((void)0)
94
95 #endif /* G_DISABLE_DEPRECATED */
96
97 /* Hash Functions
98  */
99 gboolean g_str_equal (gconstpointer  v1,
100                       gconstpointer  v2);
101 guint    g_str_hash  (gconstpointer  v);
102
103 gboolean g_int_equal (gconstpointer  v1,
104                       gconstpointer  v2);
105 guint    g_int_hash  (gconstpointer  v);
106
107 /* This "hash" function will just return the key's address as an
108  * unsigned integer. Useful for hashing on plain addresses or
109  * simple integer values.
110  * Passing NULL into g_hash_table_new() as GHashFunc has the
111  * same effect as passing g_direct_hash().
112  */
113 guint    g_direct_hash  (gconstpointer  v) G_GNUC_CONST;
114 gboolean g_direct_equal (gconstpointer  v1,
115                          gconstpointer  v2) G_GNUC_CONST;
116
117 G_END_DECLS
118
119 #endif /* __G_HASH_H__ */
120