Navit SVN

/work/compile/navit/src/navit/support/glib/ghash.h

00001 /* GLIB - Library of useful routines for C programming
00002  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA 02111-1307, USA.
00018  */
00019 
00020 /*
00021  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
00022  * file for a list of people on the GLib Team.  See the ChangeLog
00023  * files for a list of changes.  These files are distributed with
00024  * GLib at ftp://ftp.gtk.org/pub/gtk/.
00025  */
00026 
00027 #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
00028 #error "Only <glib.h> can be included directly."
00029 #endif
00030 
00031 #ifndef __G_HASH_H__
00032 #define __G_HASH_H__
00033 
00034 #include <glib/gtypes.h>
00035 #include <glib/glist.h>
00036 
00037 G_BEGIN_DECLS
00038 
00039 typedef struct _GHashTable  GHashTable;
00040 
00041 typedef gboolean  (*GHRFunc)  (gpointer  key,
00042                                gpointer  value,
00043                                gpointer  user_data);
00044 
00045 typedef struct _GHashTableIter GHashTableIter;
00046 
00047 struct _GHashTableIter
00048 {
00049   /*< private >*/
00050   gpointer      dummy1;
00051   gpointer      dummy2;
00052   gpointer      dummy3;
00053   int           dummy4;
00054   gboolean      dummy5;
00055   gpointer      dummy6;
00056 };
00057 
00058 /* Hash tables
00059  */
00060 GHashTable* g_hash_table_new               (GHashFunc       hash_func,
00061                                             GEqualFunc      key_equal_func);
00062 GHashTable* g_hash_table_new_full          (GHashFunc       hash_func,
00063                                             GEqualFunc      key_equal_func,
00064                                             GDestroyNotify  key_destroy_func,
00065                                             GDestroyNotify  value_destroy_func);
00066 void        g_hash_table_destroy           (GHashTable     *hash_table);
00067 void        g_hash_table_insert            (GHashTable     *hash_table,
00068                                             gpointer        key,
00069                                             gpointer        value);
00070 void        g_hash_table_replace           (GHashTable     *hash_table,
00071                                             gpointer        key,
00072                                             gpointer        value);
00073 gboolean    g_hash_table_remove            (GHashTable     *hash_table,
00074                                             gconstpointer   key);
00075 void        g_hash_table_remove_all        (GHashTable     *hash_table);
00076 gboolean    g_hash_table_steal             (GHashTable     *hash_table,
00077                                             gconstpointer   key);
00078 void        g_hash_table_steal_all         (GHashTable     *hash_table);
00079 gpointer    g_hash_table_lookup            (GHashTable     *hash_table,
00080                                             gconstpointer   key);
00081 gboolean    g_hash_table_lookup_extended   (GHashTable     *hash_table,
00082                                             gconstpointer   lookup_key,
00083                                             gpointer       *orig_key,
00084                                             gpointer       *value);
00085 void        g_hash_table_foreach           (GHashTable     *hash_table,
00086                                             GHFunc          func,
00087                                             gpointer        user_data);
00088 gpointer    g_hash_table_find              (GHashTable     *hash_table,
00089                                             GHRFunc         predicate,
00090                                             gpointer        user_data);
00091 guint       g_hash_table_foreach_remove    (GHashTable     *hash_table,
00092                                             GHRFunc         func,
00093                                             gpointer        user_data);
00094 guint       g_hash_table_foreach_steal     (GHashTable     *hash_table,
00095                                             GHRFunc         func,
00096                                             gpointer        user_data);
00097 guint       g_hash_table_size              (GHashTable     *hash_table);
00098 GList *     g_hash_table_get_keys          (GHashTable     *hash_table);
00099 GList *     g_hash_table_get_values        (GHashTable     *hash_table);
00100 
00101 void        g_hash_table_iter_init         (GHashTableIter *iter,
00102                                             GHashTable     *hash_table);
00103 gboolean    g_hash_table_iter_next         (GHashTableIter *iter,
00104                                             gpointer       *key,
00105                                             gpointer       *value);
00106 GHashTable* g_hash_table_iter_get_hash_table (GHashTableIter *iter);
00107 void        g_hash_table_iter_remove       (GHashTableIter *iter);
00108 void        g_hash_table_iter_steal        (GHashTableIter *iter);
00109 
00110 /* keeping hash tables alive */
00111 GHashTable* g_hash_table_ref               (GHashTable     *hash_table);
00112 void        g_hash_table_unref             (GHashTable     *hash_table);
00113 
00114 #ifndef G_DISABLE_DEPRECATED
00115 
00116 /* The following two functions are deprecated and will be removed in
00117  * the next major release. They do no good. */
00118 #define g_hash_table_freeze(hash_table) ((void)0)
00119 #define g_hash_table_thaw(hash_table) ((void)0)
00120 
00121 #endif /* G_DISABLE_DEPRECATED */
00122 
00123 /* Hash Functions
00124  */
00125 gboolean g_str_equal (gconstpointer  v1,
00126                       gconstpointer  v2);
00127 guint    g_str_hash  (gconstpointer  v);
00128 
00129 gboolean g_int_equal (gconstpointer  v1,
00130                       gconstpointer  v2);
00131 guint    g_int_hash  (gconstpointer  v);
00132 
00133 /* This "hash" function will just return the key's address as an
00134  * unsigned integer. Useful for hashing on plain addresses or
00135  * simple integer values.
00136  * Passing NULL into g_hash_table_new() as GHashFunc has the
00137  * same effect as passing g_direct_hash().
00138  */
00139 guint    g_direct_hash  (gconstpointer  v) G_GNUC_CONST;
00140 gboolean g_direct_equal (gconstpointer  v1,
00141                          gconstpointer  v2) G_GNUC_CONST;
00142 
00143 G_END_DECLS
00144 
00145 #endif /* __G_HASH_H__ */