mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-27 17:52:58 +02:00
Add g_hash_table_get_keys() and g_hash_table_get_values(), API to retrieve
2007-04-11 Emmanuele Bassi <ebassi@gnome.org> * glib/ghash.[ch]: Add g_hash_table_get_keys() and g_hash_table_get_values(), API to retrieve the keys and values inside an hash table in list form. (#413133) * glib/glib.symbols: Update symbols. * tests/hash-test.c: Exercise newly added functions. svn path=/trunk/; revision=5444
This commit is contained in:
committed by
Emmanuele Bassi
parent
e542f521ef
commit
db8642a56c
@@ -342,7 +342,9 @@ main (int argc,
|
||||
GHashTable *hash_table;
|
||||
gint i;
|
||||
gint value = 120;
|
||||
gint *pvalue;
|
||||
gint *pvalue;
|
||||
GList *keys, *values;
|
||||
gint keys_len, values_len;
|
||||
|
||||
hash_table = g_hash_table_new (my_hash, my_hash_equal);
|
||||
for (i = 0; i < 10000; i++)
|
||||
@@ -353,6 +355,22 @@ main (int argc,
|
||||
pvalue = g_hash_table_find (hash_table, find_first, &value);
|
||||
if (!pvalue || *pvalue != value)
|
||||
g_assert_not_reached();
|
||||
|
||||
keys = g_hash_table_get_keys (hash_table);
|
||||
if (!keys)
|
||||
g_assert_not_reached ();
|
||||
|
||||
values = g_hash_table_get_values (hash_table);
|
||||
if (!values)
|
||||
g_assert_not_reached ();
|
||||
|
||||
keys_len = g_list_length (keys);
|
||||
values_len = g_list_length (values);
|
||||
if (values_len != keys_len && keys_len != g_hash_table_size (hash_table))
|
||||
g_assert_not_reached ();
|
||||
|
||||
g_list_free (keys);
|
||||
g_list_free (values);
|
||||
|
||||
g_hash_table_foreach (hash_table, my_hash_callback, NULL);
|
||||
|
||||
|
Reference in New Issue
Block a user