Re: g_hash_table_find()



On Sunday 20 June 2004 10:21, Russell Shaw wrote:

That api is a bit clunky. It would be better if the key
was returned.

gboolean
predicate_func (gpointer key, gpointer value, gpointer userdata)
{
        gpointer  *p_key = (gpointer*)userdata;

        if (... value matches what you're looking for ...)
        {
                *p_key = key;
                return TRUE;
        }

        return FALSE;
}

   gpointer  value, key;

   value = g_hash_table_find (ht, predicate_func, &key);


Pass a struct if the predicate function needs more than one user data 
argument.

Cheers
 -Tim




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