Conversion between glib data structures
- From: Morten Welinder <terra diku dk>
- To: gtk-devel-list gnome org
- Subject: Conversion between glib data structures
- Date: 6 Sep 2001 14:38:32 -0000
While Gnumeric-hacking, I quite often find it necessary to convert
from one glib data structure to another. Glib has no provisions
for that, it seems.
Typically, things have been built and maintained as a hash for
speed, but is needed as a list in the end. This can certainly
be done with the current method of _foreach, but it's cumbersome
and quite inelegant in C.
Would it be acceptable to add a bunch of functions to glib?
Specifically...
GSList *g_hash_table_to_slist (GHash *h, gboolean keys, gboolean values);
GList *g_hash_table_to_list (GHash *h, gboolean keys, gboolean values);
GPtrArray *g_hash_table_to_ptrarray (GHash *h, gboolean keys, gboolean values);
And possibly, for naming convenience:
#define g_hash_table_domain_slist(h) \
g_hash_table_to_slist (h, TRUE, FALSE)
#define g_hash_table_range_slist(h) \
g_hash_table_to_slist (h, FALSE, TRUE)
etc.
These should probably be placed in a file of their own, to avoid tying
the .o files together with inter-file references.
Comments?
Morten
(cc, please -- not on list)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]