Re: [gtk-list] Re: number of GtkContainer childs ?





	I added a wrapper to my add and delete functions and
	bump my own counters to keep track of the counts in 
	a list box... works for me.. 



	Best Regards, 
	Ed


//------------------------------------------------------------------------
// Edward March Jr. WB9RAA -- Mt. Prospect, IL     
//
// ***> http://www.enteract.com/~emarch
// ***> http://www.bmtmicro.com/catalog/clone.html
//
// Win95 or Better, I chose better! 
// I Run OS/2 Warp 3.0 & 4.0 and Linux S.u.S.E. 5.3 and 6.0
//------------------------------------------------------------------------

On Tue, 29 Jun 1999, Havoc Pennington wrote:

> 
> On Tue, 29 Jun 1999, Peter Lerner wrote:
> > 
> > to be more explicit: 
> > is there a way to get the number of items in a GtkList?
> > 
> ...
> > 
> >  Gtk_Container *container = my_menu;
> >  guint num = container.size();
> > 
> 
> The only way I see to do this is:
> 
> GList* list = gtk_container_children(GTK_CONTAINER(gtklist));
> guint num = g_list_length(list);
> g_list_free(list);
> return num;
> 
> Which is needless to say not very efficient. If you want to "cheat,"  you
> can use GTK_LIST(gtklist)->children instead of calling the function, which
> saves a list copy/free but is still O(N) slow. However, technically
> speaking I think this struct member is private.
> 
> Some of the STL containers (notably list or slist, IIRC) also have O(N)
> complexity for the size() method so this should be consistent at least.
> 
> Havoc
> 
> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
> 
> 



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