Additions to Glib's GPtrArray API



Hi,

I was looking at the API for GPtrArray manipulation.

For my needs, I need the equivalent of the g_list_foreach()
functionality, like g_ptr_array_foreach(), which would be easy enough to
do from userland.

In addition, I need a function along the lines of 

gpointer g_ptr_array_until(GPtrArray          *array,
                           GPointerUserFunc   func,
                           gpointer           user_data);

where the specified function should look like:

gpointer (*GPointerUserFunc) (gpointer  ptr_from_array,
                              gpointer  prev_re_user_data);

and which does 

{
  guint this = 0;
  while( (user_data != NULL) && (this < array->len) )
  {
    user_data = (*func)(array->pdata[this++],user_data);
  }

  return user_data;
}


So, that code is still pseudo, but I think communiates what I mean.

If I were to properly error-check, use correct types, and add comments,
etc., would this be a welcome addition to GLib before GTK+ 2.0?

Or, would this type of operations be better left in userland?

Please CC me directly, as I get the digest form of the list.

Eric Monsler

P.S. If this has been discussed before, my apologies, I hadn't been on
gtk-devel-list until now.  I searched for "g_prt_array_foreach" and
"GPtrArray foreach" in the archives, without any hits.




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