Re: GHashTable improvements



on 3/16/01 11:48 AM, Owen Taylor at otaylor redhat com wrote:

>  - In the discussion earlier, there was some idea that g_hash_table_replace()
>    wasn't necessary as long as g_hash_table_insert() called the destroy
>    notify on the key function.
> 
>    The main argument for keeping g_hash_table_replace() then seems
>    to be that you might have a case where key and value are
>    associated:
> 
>     g_hash_table_insert (hash, entry->name, entry);
> 
>    I've done this fairly frequently in the past.

I think that argument is compelling enough that we should still add
g_hash_table_replace. Many of my hash tables work like this.

>  - Do we need g_hash_table_foreach_remove_no_notify() since
>    we have remove_no_notify() and destroy_no_notify()?

I'd say yes, although I find that that foreach_remove is rarely useful. (I
almost always want to share the code that removes hash table elements for
use outside the foreach function, so I find myself copying the data out of
the hash table and doing individual remove calls instead.)

>  - The name in GObject is not g_object_set_data_notify() as it
>    was in GtkObject, but g_object_steal_data(). So perhaps,
>    if this is our desired name, we should have
>    g_hash_table_steal() g_hash_table_destroy_stealing_all (????)
>    g_hash_table_foreach_steal()?

I think these names are OK.

    -- Darin





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