Re: GHashTable improvements



OK, given lack of other input, my "executive decision" here is:

  Add g_hash_table_replace()                  
  
   yes

  Add g_hash_table_remove_no_notify()         -
  
   yes, but as g_hash_table_steal()

  Add g_hash_table_foreach_remove_no_notify() -

   yes, but as g_hash_table_foreach_steal()

  Add g_hash_table_destroy_no_notify()        - 

   no.

The reason for the last is that I don't think it will
be a common operation, and it is easily accomplished
with foreach_steal(). On the other hand, foreach_steal()
is not easily accomplished with steal().

Sven: Can you take care of implementing this (with docs)?

Thanks,
                                        Owen
 

Owen Taylor <otaylor redhat com> writes:

> I was looking back at Sven's patches in #50796 to see if
> they were ready to commit. The patch adds:
> 
> =======
> GHashTable* g_hash_table_new_full          (GHashFunc       hash_func,
> 					    GEqualFunc      key_equal_func,
> 					    GDestroyNotify  key_destroy_func,
> 					    GDestroyNotify  value_destroy_func);
> void        g_hash_table_destroy_no_notify (GHashTable     *hash_table);
> void        g_hash_table_replace           (GHashTable     *hash_table,
> 					    gpointer        key,
> 					    gpointer        value);
> gboolean    g_hash_table_remove_no_notify  (GHashTable     *hash_table,
> 					    gconstpointer   key);
> =======
> 
> The items that may be outstanding here are:
> 
>  - 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.
> 
>  - Do we need g_hash_table_foreach_remove_no_notify() since
>    we have remove_no_notify() and destroy_no_notify()?
> 
>  - 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()? 





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