I'm trying to implement an N-ary Tree in c++ using the glib, but as I'm not a c++ expert, I'm having some problems finding out how to use it right. Does anybody have a simple example written in C++ to help me understand how to use the basic functions? I'm having special problems with g_node_traverse, I just can't get the GNodeTraverseFunc right.
You can find the description of the N-ary Tree here: http://developer.gnome.org/glib/stable/glib-N-ary-Trees.html
I found some examples in c, but I couldn't manage to translate them correctly into c++ here:
http://www.ibm.com/developerworks/linux/tutorials/l-glib/section7.html
Tried with the last piece of code for n-ary trees.
I appreciate your help.
Well, I have managed to run some code. The problem was basically the casts that were needed because Gnome uses gpointers and my data is to be stored in a struct. So my code is:
Where my struct is:
The idea is to have the whole previous "trajectory" stored at each node so if I choose a random node/leaf I don't have to reconstruct the trajectory but just take it.
This code works now. It might be improved and I'm open to any comment.
I hope it's useful for someone.