GNOME Bugzilla – Bug 652822
Add a g_hash_table_iter_replace
Last modified: 2011-06-21 10:32:38 UTC
Qt's QHash has an interesting feature which allows you to replace a value during iteration of a hashtable: http://doc.qt.nokia.com/latest/qhash-iterator.html#value QHash<uint, ServiceRequest*>::iterator i = priv->requests.begin(); while (i != priv->requests.end()) { if (i.key() == "Hello") i.value() = "Bonjour"; ++i; } In GLib something similar could be done by adding alongside the already existing g_hash_table_iter_remove a g_hash_table_iter_replace.
I've been thinking about that, indeed. A patch would be welcome.
Created attachment 190176 [details] [review] Implementation of a iter_replace API for GHashTableIter This is what I got. The unit test seems to work, but please verify correctness too.
The following fix has been pushed: f6ed357 Add iter_replace API to GHashTableIter
Created attachment 190333 [details] [review] Add iter_replace API to GHashTableIter
Thanks!