Home | History | Annotate | Download | only in tmpl
      1 <!-- ##### SECTION Title ##### -->
      2 N-ary Trees
      3 
      4 <!-- ##### SECTION Short_Description ##### -->
      5 trees of data with any number of branches
      6 
      7 <!-- ##### SECTION Long_Description ##### -->
      8 <para>
      9 The #GNode struct and its associated functions provide a N-ary tree data
     10 structure, where nodes in the tree can contain arbitrary data.
     11 </para>
     12 <para>
     13 To create a new tree use g_node_new().
     14 </para>
     15 <para>
     16 To insert a node into a tree use g_node_insert(), g_node_insert_before(),
     17 g_node_append() and g_node_prepend().
     18 </para>
     19 <para>
     20 To create a new node and insert it into a tree use g_node_insert_data(), 
     21 g_node_insert_data_before(), g_node_append_data() and g_node_prepend_data().
     22 </para>
     23 <para>
     24 To reverse the children of a node use g_node_reverse_children().
     25 </para>
     26 <para>
     27 To find a node use g_node_get_root(), g_node_find(), g_node_find_child(),
     28 g_node_child_index(), g_node_child_position(), 
     29 g_node_first_child(), g_node_last_child(),
     30 g_node_nth_child(), g_node_first_sibling(), g_node_prev_sibling(),
     31 g_node_next_sibling() or g_node_last_sibling().
     32 </para>
     33 <para>
     34 To get information about a node or tree use G_NODE_IS_LEAF(),
     35 G_NODE_IS_ROOT(), g_node_depth(), g_node_n_nodes(), g_node_n_children(),
     36 g_node_is_ancestor() or g_node_max_height().
     37 </para>
     38 <para>
     39 To traverse a tree, calling a function for each node visited in the
     40 traversal, use g_node_traverse() or g_node_children_foreach().
     41 </para>
     42 <para>
     43 To remove a node or subtree from a tree use g_node_unlink() or
     44 g_node_destroy().
     45 </para>
     46 
     47 <!-- ##### SECTION See_Also ##### -->
     48 <para>
     49 
     50 </para>
     51 
     52 <!-- ##### SECTION Stability_Level ##### -->
     53 
     54 
     55 <!-- ##### STRUCT GNode ##### -->
     56 <para>
     57 The <structname>GNode</structname> struct represents one node in a
     58 <link linkend="glib-N-ary-Trees">N-ary Tree</link>.
     59 fields 
     60 </para>
     61 
     62 @data: contains the actual data of the node.
     63 @next: points to the node's next sibling (a sibling is another 
     64   <structname>GNode</structname> with the same parent).
     65 @prev: points to the node's previous sibling.
     66 @parent: points to the parent of the <structname>GNode</structname>,
     67   or is %NULL if the <structname>GNode</structname> is the root of the tree.
     68 @children: The <structfield>children</structfield> field points to the first 
     69   child of the <structname>GNode</structname>. The other children are accessed 
     70   by using the <structfield>next</structfield> pointer of each child.
     71 
     72 <!-- ##### FUNCTION g_node_new ##### -->
     73 <para>
     74 
     75 </para>
     76 
     77 @data: 
     78 @Returns: 
     79 
     80 
     81 <!-- ##### FUNCTION g_node_copy ##### -->
     82 <para>
     83 
     84 </para>
     85 
     86 @node: 
     87 @Returns: 
     88 
     89 
     90 <!-- ##### USER_FUNCTION GCopyFunc ##### -->
     91 <para>
     92 
     93 </para>
     94 
     95 @src: 
     96 @data: 
     97 @Returns: 
     98 
     99 
    100 <!-- ##### FUNCTION g_node_copy_deep ##### -->
    101 <para>
    102 
    103 </para>
    104 
    105 @node: 
    106 @copy_func: 
    107 @data: 
    108 @Returns: 
    109 
    110 
    111 <!-- ##### FUNCTION g_node_insert ##### -->
    112 <para>
    113 
    114 </para>
    115 
    116 @parent: 
    117 @position: 
    118 @node: 
    119 @Returns: 
    120 
    121 
    122 <!-- ##### FUNCTION g_node_insert_before ##### -->
    123 <para>
    124 
    125 </para>
    126 
    127 @parent: 
    128 @sibling: 
    129 @node: 
    130 @Returns: 
    131 
    132 
    133 <!-- ##### FUNCTION g_node_insert_after ##### -->
    134 <para>
    135 
    136 </para>
    137 
    138 @parent: 
    139 @sibling: 
    140 @node: 
    141 @Returns: 
    142 
    143 
    144 <!-- ##### MACRO g_node_append ##### -->
    145 <para>
    146 
    147 </para>
    148 
    149 @parent: 
    150 @node: 
    151 @Returns: 
    152 
    153 
    154 <!-- ##### FUNCTION g_node_prepend ##### -->
    155 <para>
    156 
    157 </para>
    158 
    159 @parent: 
    160 @node: 
    161 @Returns: 
    162 
    163 
    164 <!-- ##### MACRO g_node_insert_data ##### -->
    165 <para>
    166 
    167 </para>
    168 
    169 @parent: 
    170 @position: 
    171 @data: 
    172 @Returns: 
    173 
    174 
    175 <!-- ##### MACRO g_node_insert_data_before ##### -->
    176 <para>
    177 
    178 </para>
    179 
    180 @parent: 
    181 @sibling: 
    182 @data: 
    183 @Returns: 
    184 
    185 
    186 <!-- ##### MACRO g_node_append_data ##### -->
    187 <para>
    188 
    189 </para>
    190 
    191 @parent: 
    192 @data: 
    193 @Returns: 
    194 
    195 
    196 <!-- ##### MACRO g_node_prepend_data ##### -->
    197 <para>
    198 
    199 </para>
    200 
    201 @parent: 
    202 @data: 
    203 @Returns: 
    204 
    205 
    206 <!-- ##### FUNCTION g_node_reverse_children ##### -->
    207 <para>
    208 
    209 </para>
    210 
    211 @node: 
    212 
    213 
    214 <!-- ##### FUNCTION g_node_traverse ##### -->
    215 <para>
    216 
    217 </para>
    218 
    219 @root: 
    220 @order: 
    221 @flags: 
    222 @max_depth: 
    223 @func: 
    224 @data: 
    225 
    226 
    227 <!-- ##### ENUM GTraverseFlags ##### -->
    228 <para>
    229 Specifies which nodes are visited during several of the tree functions,
    230 including g_node_traverse() and g_node_find().
    231 </para>
    232 
    233 @G_TRAVERSE_LEAVES: only leaf nodes should be visited. This name has been
    234   introduced in 2.6, for older version use %G_TRAVERSE_LEAFS.
    235 @G_TRAVERSE_NON_LEAVES: only non-leaf nodes should be visited. This name 
    236   has been introduced in 2.6, for older version use %G_TRAVERSE_NON_LEAFS.
    237 @G_TRAVERSE_ALL: all nodes should be visited.
    238 @G_TRAVERSE_MASK: a mask of all traverse flags.
    239 @G_TRAVERSE_LEAFS: identical to %G_TRAVERSE_LEAVES.
    240 @G_TRAVERSE_NON_LEAFS: identical to %G_TRAVERSE_NON_LEAVES.
    241 
    242 <!-- ##### USER_FUNCTION GNodeTraverseFunc ##### -->
    243 <para>
    244 Specifies the type of function passed to g_node_traverse().
    245 The function is called with each of the nodes visited, together with the
    246 user data passed to g_node_traverse().
    247 If the function returns %TRUE, then the traversal is stopped.
    248 </para>
    249 
    250 @node: a #GNode.
    251 @data: user data passed to g_node_traverse().
    252 @Returns: %TRUE to stop the traversal.
    253 
    254 
    255 <!-- ##### FUNCTION g_node_children_foreach ##### -->
    256 <para>
    257 
    258 </para>
    259 
    260 @node: 
    261 @flags: 
    262 @func: 
    263 @data: 
    264 
    265 
    266 <!-- ##### USER_FUNCTION GNodeForeachFunc ##### -->
    267 <para>
    268 Specifies the type of function passed to g_node_children_foreach().
    269 The function is called with each child node, together with the user data
    270 passed to g_node_children_foreach().
    271 </para>
    272 
    273 @node: a #GNode.
    274 @data: user data passed to g_node_children_foreach().
    275 
    276 
    277 <!-- ##### FUNCTION g_node_get_root ##### -->
    278 <para>
    279 
    280 </para>
    281 
    282 @node: 
    283 @Returns: 
    284 
    285 
    286 <!-- ##### FUNCTION g_node_find ##### -->
    287 <para>
    288 
    289 </para>
    290 
    291 @root: 
    292 @order: 
    293 @flags: 
    294 @data: 
    295 @Returns: 
    296 
    297 
    298 <!-- ##### FUNCTION g_node_find_child ##### -->
    299 <para>
    300 
    301 </para>
    302 
    303 @node: 
    304 @flags: 
    305 @data: 
    306 @Returns: 
    307 
    308 
    309 <!-- ##### FUNCTION g_node_child_index ##### -->
    310 <para>
    311 
    312 </para>
    313 
    314 @node: 
    315 @data: 
    316 @Returns: 
    317 
    318 
    319 <!-- ##### FUNCTION g_node_child_position ##### -->
    320 <para>
    321 
    322 </para>
    323 
    324 @node: 
    325 @child: 
    326 @Returns: 
    327 
    328 
    329 <!-- ##### MACRO g_node_first_child ##### -->
    330 <para>
    331 
    332 </para>
    333 
    334 @node: 
    335 @Returns: 
    336 
    337 
    338 <!-- ##### FUNCTION g_node_last_child ##### -->
    339 <para>
    340 
    341 </para>
    342 
    343 @node: 
    344 @Returns: 
    345 
    346 
    347 <!-- ##### FUNCTION g_node_nth_child ##### -->
    348 <para>
    349 
    350 </para>
    351 
    352 @node: 
    353 @n: 
    354 @Returns: 
    355 
    356 
    357 <!-- ##### FUNCTION g_node_first_sibling ##### -->
    358 <para>
    359 
    360 </para>
    361 
    362 @node: 
    363 @Returns: 
    364 
    365 
    366 <!-- ##### MACRO g_node_next_sibling ##### -->
    367 <para>
    368 
    369 </para>
    370 
    371 @node: 
    372 @Returns: 
    373 
    374 
    375 <!-- ##### MACRO g_node_prev_sibling ##### -->
    376 <para>
    377 
    378 </para>
    379 
    380 @node: 
    381 @Returns: 
    382 
    383 
    384 <!-- ##### FUNCTION g_node_last_sibling ##### -->
    385 <para>
    386 
    387 </para>
    388 
    389 @node: 
    390 @Returns: 
    391 
    392 
    393 <!-- ##### MACRO G_NODE_IS_LEAF ##### -->
    394 <para>
    395 
    396 </para>
    397 
    398 @node: 
    399 @Returns: 
    400 
    401 
    402 <!-- ##### MACRO G_NODE_IS_ROOT ##### -->
    403 <para>
    404 
    405 </para>
    406 
    407 @node: 
    408 @Returns: 
    409 
    410 
    411 <!-- ##### FUNCTION g_node_depth ##### -->
    412 <para>
    413 
    414 </para>
    415 
    416 @node: 
    417 @Returns: 
    418 
    419 
    420 <!-- ##### FUNCTION g_node_n_nodes ##### -->
    421 <para>
    422 
    423 </para>
    424 
    425 @root: 
    426 @flags: 
    427 @Returns: 
    428 
    429 
    430 <!-- ##### FUNCTION g_node_n_children ##### -->
    431 <para>
    432 
    433 </para>
    434 
    435 @node: 
    436 @Returns: 
    437 
    438 
    439 <!-- ##### FUNCTION g_node_is_ancestor ##### -->
    440 <para>
    441 
    442 </para>
    443 
    444 @node: 
    445 @descendant: 
    446 @Returns: 
    447 
    448 
    449 <!-- ##### FUNCTION g_node_max_height ##### -->
    450 <para>
    451 
    452 </para>
    453 
    454 @root: 
    455 @Returns: 
    456 
    457 
    458 <!-- ##### FUNCTION g_node_unlink ##### -->
    459 <para>
    460 
    461 </para>
    462 
    463 @node: 
    464 
    465 
    466 <!-- ##### FUNCTION g_node_destroy ##### -->
    467 <para>
    468 
    469 </para>
    470 
    471 @root: 
    472 
    473 
    474 <!-- ##### FUNCTION g_node_push_allocator ##### -->
    475 <para>
    476 Sets the allocator to use to allocate #GNode elements.
    477 Use g_node_pop_allocator() to restore the previous allocator.
    478 </para>
    479 <para>
    480 Note that this function is not available if GLib has been compiled
    481 with <option>--disable-mem-pools</option>
    482 </para>
    483 
    484 @dummy: the #GAllocator to use when allocating #GNode elements.
    485 @Deprecated: 2.10: It does nothing, since #GNode has been converted 
    486   to the <link linkend="glib-Memory-Slices">slice allocator</link>
    487 
    488 
    489 <!-- ##### FUNCTION g_node_pop_allocator ##### -->
    490 <para>
    491 Restores the previous #GAllocator, used when allocating #GNode elements.
    492 </para>
    493 <para>
    494 Note that this function is not available if GLib has been compiled
    495 with <option>--disable-mem-pools</option>
    496 </para>
    497 
    498 @Deprecated: 2.10: It does nothing, since #GNode has been converted 
    499   to the <link linkend="glib-Memory-Slices">slice allocator</link>
    500 
    501 
    502