Re: GHashTable reverse lookup / find key (patch exists)



On Sun, 12 Nov 2006, Bastiaan Veelo wrote:

Dear glib developers,

Long ago, Russel Shaw submitted a patch
http://mail.gnome.org/archives/gtk-devel-list/2004-June/msg00109.html to
do reverse lookups in a GHashTable. That is, to find the key for a
certain key/value pair. His post does not seem to have caused any
reaction on the list, and it has not made it into glib 2.12.4 which I am
using.

I am currently using a hack to get this functionality. Is there any
chance that this patch eventually gets accepted? Should I submit a
feature request on bugzilla?

P.S. Russel called his function g_hash_table_lookup_reverse(). But since
this is not a cheap operation, maybe g_hash_table_find_key() is better,
also because the only difference to g_hash_table_find() is just one
identifier.

it'd be best to submit a patch in bugzilla including function docs and
a test case (e.g. like http://bugzilla.gnome.org/show_bug.cgi?id=368686 ).
as for the name, i'd say g_hash_table_find_by_value() would be a good
candidate to name an O(n) reverse lookup.

Thanks,
Bastiaan.

---
ciaoTJ



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