Re: [gtk-list] Re: GLIB's N-ary trees



rom: Derek Simkowiak <dereks@kd-dev.com>
> > > Are Glib's N-ary trees any different from a normal BTree?  (I
> > > haven't seen the term "N-ary" used to describe such trees before)
> > 
> > GTree is a sorted binary tree suitable for key-value pairs, GNode
> > doesn't know anything about its contents it's just a generic
> > tree-shaped structure (like an XML document or a parse tree or CTree
> > contents).
> 
> Ah, so a GNode is not a BTree because it doesn't do any kind of
> balancing.
> 
> I need to write a BTree API for the new text widget I'm working
> on.  Would you suggest I write the balancing code within the framework of
> a GNode, or should I just start from scratch?

The GTree is allready able to auto-balance (have a small look in
gtree.c: g_tree_insert() actually calls the g_tree_node_insert()
static - and this one calls g_tree_node_balance() if needed).
So you don't have to build your own Btree.

Yours,

Emmanuel

> 
> Thanks,
> Derek




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