Re: API for iterating the g_hash_table



Hi,

Tony Yat-Tung Cheung <tony astri org> 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_table, GHashTableIterator iterator);
> gconspointer g_hash_table_get_value(GHashTable *hash_table, GHashTableIterator iterator);
> 
> It's certainly an improvement for g_hash_table_foreach() to stop
> traversal when the callback function returns TRUE. We should have
> this, except that it breaks the current API. Even with it, sometimes
> the user may also want to do more than just stopping the
> trasversal. He/she may also want to get the current node, return a
> special value from the current function...etc. I think the most
> convenient API is an iterator, either in a simple integer index or an
> iterator structure.

You didn't come up with a real-life use case and yet I fail to see
when the iterator API would be needed. But anyway, if you think such
an API would be useful, you should file an enhancement request on
bugzilla.gnome.org. Of course you are supposed to check first if a
similar request has already been made.


Sven



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]