API for iterating the g_hash_table

2004-01-14 Thread Tony Yat-Tung Cheung
Hi, Is there any API for iterating GHashTable? I only see the the g_hash_table_foreach() here. But sometimes people may like to iterate through a hash table and stop the iteration when certain conditions are met. Currently, there is g_hash_table_size(), we could easily add iteration by provid

glib API for iterating the g_hash_table

2004-01-14 Thread Tony Yat-Tung Cheung
Hi, Is there any API for iterating GHashTable? I only see the the g_hash_table_foreach() here. But sometimes people may like to iterate through a hash table and stop the iteration when certain conditions are met. Currently, there is g_hash_table_size(), we could easily add iteration by providing

Re: API for iterating the g_hash_table

2004-01-14 Thread Sven Neumann
Hi, Tony Yat-Tung Cheung <[EMAIL PROTECTED]> writes: > Currently, there is g_hash_table_size(), we could easily add iteration > by providing the following two new APIs, > > gconstpointer g_hash_table_get_key(GHashTable *hash_table, int pos); > gconspointer g_hash_table_get_value(GHashTable *hash

Re: API for iterating the g_hash_table

2004-01-14 Thread dhaude
> I only see the the g_hash_table_foreach() here. But sometimes people may > like to iterate through a hash table and stop the iteration when certain > conditions are met. It is rather trivial to construct a GList of hash table keys (or values) using g_hash_table_foreach. Of course it's only use

Re: API for iterating the g_hash_table

2004-01-14 Thread Sven Neumann
Hi, [EMAIL PROTECTED] writes: > It is rather trivial to construct a GList of hash table keys (or > values) using g_hash_table_foreach. Of course it's only useful on > a table whose contents change never or seldom because the list > has to be updated on each change. Anyway, here's what I use. I >

Re: API for iterating the g_hash_table

2004-01-14 Thread dhaude
On 14 Jan 2004, Sven Neumann wrote: > Hi, > > [EMAIL PROTECTED] writes: > > > It is rather trivial to construct a GList of hash table keys (or > > values) using g_hash_table_foreach. Of course it's only useful on > > a table whose contents change never or seldom because the list > > has to be

Re: API for iterating the g_hash_table

2004-01-14 Thread Tony Yat-Tung Cheung
Sven Neumann wrote: Hi, Tony Yat-Tung Cheung <[EMAIL PROTECTED]> writes: Currently, there is g_hash_table_size(), we could easily add iteration by providing the following two new APIs, gconstpointer g_hash_table_get_key(GHashTable *hash_table, int pos); gconspointer g_hash_table

Re: API for iterating the g_hash_table

2004-01-14 Thread Tony Yat-Tung Cheung
[EMAIL PROTECTED] wrote: I only see the the g_hash_table_foreach() here. But sometimes people may like to iterate through a hash table and stop the iteration when certain conditions are met. It is rather trivial to construct a GList of hash table keys (or values) using g_ha

Re: API for iterating the g_hash_table

2004-01-15 Thread Sven Neumann
Hi, Tony Yat-Tung Cheung <[EMAIL PROTECTED]> writes: > Yes, the proposed API may expose too much implementation details in > some views. For perfect API, one may want to use an iterator, instead > of an integer index. Then APIs will become, > > gconstpointer g_hash_table_get_key(GHashTable *hash

Re: glib API for iterating the g_hash_table

2004-01-14 Thread Krzysztof Garus
On Wed, Jan 14, 2004 at 10:02:54PM +0800, Tony Yat-Tung Cheung wrote: > Hi, > > Is there any API for iterating GHashTable? > > I only see the the g_hash_table_foreach() here. But sometimes people may > like to iterate through a hash table and stop the iteration when certain > conditions are met.