ROOT  6.05/03
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Macros | Typedefs | Functions
ghash.h File Reference
#include <glib/gtypes.h>
+ Include dependency graph for ghash.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define g_hash_table_freeze(hash_table)   ((void)0)
 
#define g_hash_table_thaw(hash_table)   ((void)0)
 

Typedefs

typedef typedefG_BEGIN_DECLS
struct _GHashTable 
GHashTable
 
typedef gboolean(* GHRFunc )(gpointer key, gpointer value, gpointer user_data)
 

Functions

GHashTableg_hash_table_new (GHashFunc hash_func, GEqualFunc key_equal_func)
 g_hash_table_new: : a function to create a hash value from a key. More...
 
GHashTableg_hash_table_new_full (GHashFunc hash_func, GEqualFunc key_equal_func, GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
 g_hash_table_new_full: : a function to create a hash value from a key. More...
 
void g_hash_table_destroy (GHashTable *hash_table)
 g_hash_table_destroy: : a GHashTable. More...
 
void g_hash_table_insert (GHashTable *hash_table, gpointer key, gpointer value)
 g_hash_table_insert: : a GHashTable. More...
 
void g_hash_table_replace (GHashTable *hash_table, gpointer key, gpointer value)
 g_hash_table_replace: : a GHashTable. More...
 
gboolean g_hash_table_remove (GHashTable *hash_table, gconstpointer key)
 g_hash_table_remove: : a GHashTable. More...
 
gboolean g_hash_table_steal (GHashTable *hash_table, gconstpointer key)
 g_hash_table_steal: : a GHashTable. More...
 
gpointer g_hash_table_lookup (GHashTable *hash_table, gconstpointer key)
 g_hash_table_lookup: : a GHashTable. More...
 
gboolean g_hash_table_lookup_extended (GHashTable *hash_table, gconstpointer lookup_key, gpointer *orig_key, gpointer *value)
 g_hash_table_lookup_extended: : a GHashTable. More...
 
void g_hash_table_foreach (GHashTable *hash_table, GHFunc func, gpointer user_data)
 g_hash_table_foreach: : a GHashTable. More...
 
guint g_hash_table_foreach_remove (GHashTable *hash_table, GHRFunc func, gpointer user_data)
 g_hash_table_foreach_remove: : a GHashTable. More...
 
guint g_hash_table_foreach_steal (GHashTable *hash_table, GHRFunc func, gpointer user_data)
 g_hash_table_foreach_steal: : a GHashTable. More...
 
guint g_hash_table_size (GHashTable *hash_table)
 g_hash_table_size: : a GHashTable. More...
 
gboolean g_str_equal (gconstpointer v, gconstpointer v2)
 
guint g_str_hash (gconstpointer v)
 
gboolean g_int_equal (gconstpointer v, gconstpointer v2) G_GNUC_CONST
 
guint g_int_hash (gconstpointer v) G_GNUC_CONST
 
guint g_direct_hash (gconstpointer v) G_GNUC_CONST
 
gboolean g_direct_equal (gconstpointer v, gconstpointer v2) G_GNUC_CONST
 

Macro Definition Documentation

#define g_hash_table_freeze (   hash_table)    ((void)0)

Definition at line 80 of file ghash.h.

#define g_hash_table_thaw (   hash_table)    ((void)0)

Definition at line 81 of file ghash.h.

Typedef Documentation

typedef typedefG_BEGIN_DECLS struct _GHashTable GHashTable

Definition at line 34 of file ghash.h.

typedef gboolean(* GHRFunc)(gpointer key, gpointer value, gpointer user_data)

Definition at line 36 of file ghash.h.

Function Documentation

gboolean g_direct_equal ( gconstpointer  v,
gconstpointer  v2 
)

Definition at line 1039 of file gutils.c.

guint g_direct_hash ( gconstpointer  v)

Definition at line 1033 of file gutils.c.

Referenced by g_data_initialize(), and g_hash_table_new_full().

void g_hash_table_destroy ( GHashTable hash_table)

g_hash_table_destroy: : a GHashTable.

Destroys the GHashTable. If keys and/or values are dynamically allocated, you should either free them first or create the GHashTable using g_hash_table_new_full(). In the latter case the destroy functions you supplied will be called on all keys and values before destroying the GHashTable.

Definition at line 171 of file ghash.c.

Referenced by _gdk_colormap_real_destroy(), _gdk_pixmap_create_from_xpm(), g_cache_destroy(), g_relation_delete(), g_relation_destroy(), g_relation_free_array(), g_scanner_destroy(), g_string_chunk_free(), gdk_color_context_add_palette(), and init_palette().

void g_hash_table_foreach ( GHashTable hash_table,
GHFunc  func,
gpointer  user_data 
)

g_hash_table_foreach: : a GHashTable.

: the function to call for each key/value pair. : user data to pass to the function.

Calls the given function for each of the key/value pairs in the GHashTable. The function is passed the key and value of each pair, and the given parameter.

Definition at line 544 of file ghash.c.

Referenced by g_cache_key_foreach(), g_cache_value_foreach(), g_relation_delete(), g_relation_destroy(), g_relation_print(), g_relation_print_index(), g_relation_select(), g_scanner_destroy(), g_scanner_scope_foreach_symbol(), gdk_color_context_add_palette(), and init_palette().

guint g_hash_table_foreach_remove ( GHashTable hash_table,
GHRFunc  func,
gpointer  user_data 
)

g_hash_table_foreach_remove: : a GHashTable.

: the function to call for each key/value pair. : user data to pass to the function.

Calls the given function for each key/value pair in the GHashTable. If the function returns TRUE, then the key/value pair is removed from the GHashTable. If you supplied key or value destroy functions when creating the GHashTable, they are used to free the memory allocated for the removed keys and values.

Return value: the number of key/value pairs removed.

Definition at line 451 of file ghash.c.

guint g_hash_table_foreach_steal ( GHashTable hash_table,
GHRFunc  func,
gpointer  user_data 
)

g_hash_table_foreach_steal: : a GHashTable.

: the function to call for each key/value pair. : user data to pass to the function.

Calls the given function for each key/value pair in the GHashTable. If the function returns TRUE, then the key/value pair is removed from the GHashTable, but no key or value destroy functions are called.

Return value: the number of key/value pairs removed.

Definition at line 474 of file ghash.c.

void g_hash_table_insert ( GHashTable hash_table,
gpointer  key,
gpointer  value 
)

g_hash_table_insert: : a GHashTable.

: a key to insert. : the value to associate with the key.

Inserts a new key and value into a GHashTable.

If the key already exists in the GHashTable its current value is replaced with the new value. If you supplied a value_destroy_func when creating the GHashTable, the old value is freed using that function. If you supplied a key_destroy_func when creating the GHashTable, the passed key is freed using that function.

Definition at line 285 of file ghash.c.

Referenced by _gdk_pixmap_create_from_xpm(), g_cache_insert(), g_dataset_id_set_data_full(), g_quark_new(), g_relation_insert(), g_scanner_scope_add_symbol(), g_string_chunk_insert_const(), g_win32_get_package_installation_directory(), gdk_atom_intern(), gdk_color_context_get_pixel(), gdk_colormap_add(), gdk_colormap_alloc1(), gdk_font_hash_insert(), gdk_sel_prop_store(), gdk_xid_table_insert(), and get_package_directory_from_module().

gpointer g_hash_table_lookup ( GHashTable hash_table,
gconstpointer  key 
)
gboolean g_hash_table_lookup_extended ( GHashTable hash_table,
gconstpointer  lookup_key,
gpointer orig_key,
gpointer value 
)

g_hash_table_lookup_extended: : a GHashTable.

: the key to look up. : returns the original key. : returns the value associated with the key.

Looks up a key in the GHashTable, returning the original key and the associated value and a gboolean which is TRUE if the key was found. This is useful if you need to free the memory allocated for the original key, for example before calling g_hash_table_remove().

Return value: TRUE if the key was found in the GHashTable.

Definition at line 247 of file ghash.c.

GHashTable* g_hash_table_new ( GHashFunc  hash_func,
GEqualFunc  key_equal_func 
)

g_hash_table_new: : a function to create a hash value from a key.

Hash values are used to determine where keys are stored within the GHashTable data structure. The g_direct_hash(), g_int_hash() and g_str_hash() functions are provided for some common types of keys. If hash_func is NULL, g_direct_hash() is used. : a function to check two keys for equality. This is used when looking up keys in the GHashTable. The g_direct_equal(), g_int_equal() and g_str_equal() functions are provided for the most common types of keys. If is NULL, keys are compared directly in a similar fashion to g_direct_equal(), but without the overhead of a function call.

Creates a new GHashTable.

Return value: a new GHashTable.

Definition at line 112 of file ghash.c.

Referenced by _gdk_pixmap_create_from_xpm(), g_cache_new(), g_data_initialize(), g_quark_from_static_string(), g_quark_from_string(), g_relation_index(), g_relation_insert(), g_relation_new(), g_scanner_new(), g_string_chunk_insert_const(), g_win32_get_package_installation_directory(), gdk_atom_intern(), gdk_color_context_get_pixel(), gdk_colormap_add(), gdk_colormap_get_system(), gdk_colormap_new(), gdk_colormap_remove(), gdk_font_hash_insert(), gdk_win32_selection_init(), gdk_xid_table_insert(), gdk_xid_table_remove(), get_package_directory_from_module(), and init_palette().

GHashTable* g_hash_table_new_full ( GHashFunc  hash_func,
GEqualFunc  key_equal_func,
GDestroyNotify  key_destroy_func,
GDestroyNotify  value_destroy_func 
)

g_hash_table_new_full: : a function to create a hash value from a key.

: a function to check two keys for equality. : a function to free the memory allocated for the key used when removing the entry from the GHashTable or NULL if you don't want to supply such a function. : a function to free the memory allocated for the value used when removing the entry from the GHashTable or NULL if you don't want to supply such a function.

Creates a new GHashTable like g_hash_table_new() and allows to specify functions to free the memory allocated for the key and value that get called when removing the entry from the GHashTable.

Return value: a new GHashTable.

Definition at line 137 of file ghash.c.

Referenced by g_hash_table_new().

gboolean g_hash_table_remove ( GHashTable hash_table,
gconstpointer  key 
)

g_hash_table_remove: : a GHashTable.

: the key to remove.

Removes a key and its associated value from a GHashTable.

If the GHashTable was created using g_hash_table_new_full(), the key and value are freed using the supplied destroy_functions, otherwise you have to make sure that any dynamically allocated values are freed yourself.

Return value: TRUE if the key was found and removed from the GHashTable.

Definition at line 377 of file ghash.c.

Referenced by g_cache_remove(), g_dataset_destroy_internal(), g_relation_delete(), g_relation_delete_tuple(), g_scanner_scope_remove_symbol(), gdk_colormap_free_colors(), gdk_colormap_remove(), gdk_colors_free(), gdk_font_hash_remove(), gdk_sel_prop_store(), gdk_selection_convert(), gdk_selection_property_delete(), and gdk_xid_table_remove().

void g_hash_table_replace ( GHashTable hash_table,
gpointer  key,
gpointer  value 
)

g_hash_table_replace: : a GHashTable.

: a key to insert. : the value to associate with the key.

Inserts a new key and value into a GHashTable similar to g_hash_table_insert(). The difference is that if the key already exists in the GHashTable, it gets replaced by the new key. If you supplied a value_destroy_func when creating the GHashTable, the old value is freed using that function. If you supplied a key_destroy_func when creating the GHashTable, the old key is freed using that function.

Definition at line 333 of file ghash.c.

guint g_hash_table_size ( GHashTable hash_table)

g_hash_table_size: : a GHashTable.

Returns the number of elements contained in the GHashTable.

Return value: the number of key/value pairs in the GHashTable.

Definition at line 568 of file ghash.c.

Referenced by g_relation_count().

gboolean g_hash_table_steal ( GHashTable hash_table,
gconstpointer  key 
)

g_hash_table_steal: : a GHashTable.

: the key to remove.

Removes a key and its associated value from a GHashTable without calling the key and value destroy functions.

Return value: TRUE if the key was found and removed from the GHashTable.

Definition at line 413 of file ghash.c.

gboolean g_int_equal ( gconstpointer  v,
gconstpointer  v2 
)

Definition at line 1046 of file gutils.c.

Referenced by gdk_win32_selection_init().

guint g_int_hash ( gconstpointer  v)

Definition at line 1053 of file gutils.c.

Referenced by gdk_win32_selection_init().

gboolean g_str_equal ( gconstpointer  v,
gconstpointer  v2 
)
guint g_str_hash ( gconstpointer  v)