After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 131937 - Adding a first_that function to GHashTable
Adding a first_that function to GHashTable
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.3.x
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2004-01-19 16:18 UTC by wollny
Modified: 2011-02-18 16:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch against 2.3.1 to add g_hash_table_first_that plus tests. (4.09 KB, patch)
2004-01-19 16:19 UTC, wollny
none Details | Review

Description wollny 2004-01-19 16:18:55 UTC
Hello, 

sometimes it would be usefull not to iterate over the full hash table (like
g_hash_table_for_each always does), but only to find the first element with
a given property. 

Therefore, I propose to add a g_hash_table_first_that function.
Comment 1 wollny 2004-01-19 16:19:57 UTC
Created attachment 23529 [details] [review]
Patch against 2.3.1 to add g_hash_table_first_that plus tests.
Comment 2 alexander.winston 2004-01-25 19:59:49 UTC
Adding the PATCH keyword and marking Priority=High.
Comment 3 Owen Taylor 2004-01-25 21:14:35 UTC
I don't see efficiency as a reason to add this ... the algorithm
stays O(n) ... if going through half the elements is fast enough
on average, then going through all the elements is fsat
enough. But perhaps convenience is ... sometimes you want to
find exactly one element that matches a test, but not more
than one.

I think it would be better called foreach_while() or 
maybe g_hash_table_find() or something like that.
Comment 4 rjones 2004-01-26 15:03:55 UTC
This patch would improve efficiency, under the not unreasonable
assumption that the density of searched-for elements is better than
constant.
Comment 5 Tim Janik 2004-02-20 02:05:42 UTC
applied with rename as per owen's suggestions.
Comment 6 Tim Janik 2004-02-20 02:05:55 UTC
applied with rename as per owen's suggestions.
Comment 7 Max Kanat-Alexander 2009-08-21 03:22:38 UTC
This bug was marked RESOLVED without a resolution, which Bugzilla does not allow (and so I am fixing it). It is assumed that the bug was intended to be marked as FIXED. If the bug should have some other resolution, please change its resolution.