Re: Newbie



Hi,
In regards to "GNode", if I wanted to search only the "immediate" child nodes' DATA to see if they contain matching data would I have to start looking with a loop that starts with the first child node and then traverses to each next sibling and each time checking the node's data? Or is there a better way to conduct this search? I wasn't sure because g_node_find_child() seemed to suggest that it will look into ALL children of a node by doing a tree traversal.. this is not what I want.. I just want the search to take place one level below the current GNode to see if such a node containing my data already exists!
Any suggestions on how to do this best? I know I can use a for loop or something to start with the first child and then iterate .. but I want to see if there is a neater looking way?

Cheers,
CBro



On Wed, Jun 16, 2010 at 3:56 PM, Ian Liu Rodrigues <ian liu88 gmail com> wrote:
Attached there is an example of usage

Regards,
Ian L.


On Wed, Jun 16, 2010 at 10:32 AM, Manu Kaul <manu kaul gmail com> wrote:
Hi Ian,
I have already looked at that API but I am just wondering if I can see some sample code to see how it all hangs together and get a better idea?

Cheers!

On Wed, Jun 16, 2010 at 2:29 PM, <ian liu88 gmail com> wrote:
GNode has a 'data' attribute, which you can set to any structure you want.

Take a look at the GNode API and you will see every function you need to manipulate the tree:
http://library.gnome.org/devel/glib/stable/glib-N-ary-Trees.html

Em , Manu Kaul <manu kaul gmail com> escreveu:

> Hi All,I am a newbie to this mailing list and I want to implement a n-ary tree and came across "GNode" in glib and wanted to see if there was some good sample code that I could look at to see how I can go about setting up this tree. Also I needed the ability to be able to work upwards from a node all the way to the root by just following the parent pointers. So I was unsure as to how I can do this using GNode. I also wanted to know how I can add additional pointers to the GNode node if I needed them?
>
>
>
> Cheers,
> CBro
>
>
>
>



--

The greater danger for most of us lies not in setting our aim too high and falling short; but in setting our aim too low, and achieving our mark.
- Michelangelo




--

The greater danger for most of us lies not in setting our aim too high and falling short; but in setting our aim too low, and achieving our mark.
- Michelangelo


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