1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * GNode: N-way tree implementation.
5 * Copyright (C) 1998 Tim Janik
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
22 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
23 * file for a list of people on the GLib Team. See the ChangeLog
24 * files for a list of changes. These files are distributed with
25 * GLib at ftp://ftp.gtk.org/pub/gtk/.
38 #include "gtestutils.h"
43 * @short_description: trees of data with any number of branches
45 * The #GNode struct and its associated functions provide a N-ary tree
46 * data structure, where nodes in the tree can contain arbitrary data.
48 * To create a new tree use g_node_new().
50 * To insert a node into a tree use g_node_insert(),
51 * g_node_insert_before(), g_node_append() and g_node_prepend().
53 * To create a new node and insert it into a tree use
54 * g_node_insert_data(), g_node_insert_data_after(),
55 * g_node_insert_data_before(), g_node_append_data()
56 * and g_node_prepend_data().
58 * To reverse the children of a node use g_node_reverse_children().
60 * To find a node use g_node_get_root(), g_node_find(),
61 * g_node_find_child(), g_node_child_index(), g_node_child_position(),
62 * g_node_first_child(), g_node_last_child(), g_node_nth_child(),
63 * g_node_first_sibling(), g_node_prev_sibling(), g_node_next_sibling()
64 * or g_node_last_sibling().
66 * To get information about a node or tree use G_NODE_IS_LEAF(),
67 * G_NODE_IS_ROOT(), g_node_depth(), g_node_n_nodes(),
68 * g_node_n_children(), g_node_is_ancestor() or g_node_max_height().
70 * To traverse a tree, calling a function for each node visited in the
71 * traversal, use g_node_traverse() or g_node_children_foreach().
73 * To remove a node or subtree from a tree use g_node_unlink() or
79 * @data: contains the actual data of the node.
80 * @next: points to the node's next sibling (a sibling is another
81 * #GNode with the same parent).
82 * @prev: points to the node's previous sibling.
83 * @parent: points to the parent of the #GNode, or is %NULL if the
84 * #GNode is the root of the tree.
85 * @children: points to the first child of the #GNode. The other
86 * children are accessed by using the @next pointer of each
89 * The #GNode struct represents one node in a [n-ary tree][glib-N-ary-Trees].
92 #define g_node_alloc0() g_slice_new0 (GNode)
93 #define g_node_free(node) g_slice_free (GNode, node)
95 /* --- functions --- */
98 * @data: the data of the new node
100 * Creates a new #GNode containing the given data.
101 * Used to create the first node in a tree.
103 * Returns: a new #GNode
106 g_node_new (gpointer data
)
108 GNode
*node
= g_node_alloc0 ();
114 g_nodes_free (GNode
*node
)
118 GNode
*next
= node
->next
;
120 g_nodes_free (node
->children
);
128 * @root: the root of the tree/subtree to destroy
130 * Removes @root and its children from the tree, freeing any memory
134 g_node_destroy (GNode
*root
)
136 g_return_if_fail (root
!= NULL
);
138 if (!G_NODE_IS_ROOT (root
))
139 g_node_unlink (root
);
146 * @node: the #GNode to unlink, which becomes the root of a new tree
148 * Unlinks a #GNode from a tree, resulting in two separate trees.
151 g_node_unlink (GNode
*node
)
153 g_return_if_fail (node
!= NULL
);
156 node
->prev
->next
= node
->next
;
157 else if (node
->parent
)
158 node
->parent
->children
= node
->next
;
162 node
->next
->prev
= node
->prev
;
171 * @copy_func: the function which is called to copy the data inside each node,
172 * or %NULL to use the original data.
173 * @data: data to pass to @copy_func
175 * Recursively copies a #GNode and its data.
177 * Returns: a new #GNode containing copies of the data in @node.
182 g_node_copy_deep (GNode
*node
,
186 GNode
*new_node
= NULL
;
188 if (copy_func
== NULL
)
189 return g_node_copy (node
);
193 GNode
*child
, *new_child
;
195 new_node
= g_node_new (copy_func (node
->data
, data
));
197 for (child
= g_node_last_child (node
); child
; child
= child
->prev
)
199 new_child
= g_node_copy_deep (child
, copy_func
, data
);
200 g_node_prepend (new_node
, new_child
);
211 * Recursively copies a #GNode (but does not deep-copy the data inside the
212 * nodes, see g_node_copy_deep() if you need that).
214 * Returns: a new #GNode containing the same data pointers
217 g_node_copy (GNode
*node
)
219 GNode
*new_node
= NULL
;
225 new_node
= g_node_new (node
->data
);
227 for (child
= g_node_last_child (node
); child
; child
= child
->prev
)
228 g_node_prepend (new_node
, g_node_copy (child
));
236 * @parent: the #GNode to place @node under
237 * @position: the position to place @node at, with respect to its siblings
238 * If position is -1, @node is inserted as the last child of @parent
239 * @node: the #GNode to insert
241 * Inserts a #GNode beneath the parent at the given position.
243 * Returns: the inserted #GNode
246 g_node_insert (GNode
*parent
,
250 g_return_val_if_fail (parent
!= NULL
, node
);
251 g_return_val_if_fail (node
!= NULL
, node
);
252 g_return_val_if_fail (G_NODE_IS_ROOT (node
), node
);
255 return g_node_insert_before (parent
,
256 g_node_nth_child (parent
, position
),
258 else if (position
== 0)
259 return g_node_prepend (parent
, node
);
260 else /* if (position < 0) */
261 return g_node_append (parent
, node
);
265 * g_node_insert_before:
266 * @parent: the #GNode to place @node under
267 * @sibling: the sibling #GNode to place @node before.
268 * If sibling is %NULL, the node is inserted as the last child of @parent.
269 * @node: the #GNode to insert
271 * Inserts a #GNode beneath the parent before the given sibling.
273 * Returns: the inserted #GNode
276 g_node_insert_before (GNode
*parent
,
280 g_return_val_if_fail (parent
!= NULL
, node
);
281 g_return_val_if_fail (node
!= NULL
, node
);
282 g_return_val_if_fail (G_NODE_IS_ROOT (node
), node
);
284 g_return_val_if_fail (sibling
->parent
== parent
, node
);
286 node
->parent
= parent
;
292 node
->prev
= sibling
->prev
;
293 node
->prev
->next
= node
;
294 node
->next
= sibling
;
295 sibling
->prev
= node
;
299 node
->parent
->children
= node
;
300 node
->next
= sibling
;
301 sibling
->prev
= node
;
306 if (parent
->children
)
308 sibling
= parent
->children
;
309 while (sibling
->next
)
310 sibling
= sibling
->next
;
311 node
->prev
= sibling
;
312 sibling
->next
= node
;
315 node
->parent
->children
= node
;
322 * g_node_insert_after:
323 * @parent: the #GNode to place @node under
324 * @sibling: the sibling #GNode to place @node after.
325 * If sibling is %NULL, the node is inserted as the first child of @parent.
326 * @node: the #GNode to insert
328 * Inserts a #GNode beneath the parent after the given sibling.
330 * Returns: the inserted #GNode
333 g_node_insert_after (GNode
*parent
,
337 g_return_val_if_fail (parent
!= NULL
, node
);
338 g_return_val_if_fail (node
!= NULL
, node
);
339 g_return_val_if_fail (G_NODE_IS_ROOT (node
), node
);
341 g_return_val_if_fail (sibling
->parent
== parent
, node
);
343 node
->parent
= parent
;
349 sibling
->next
->prev
= node
;
351 node
->next
= sibling
->next
;
352 node
->prev
= sibling
;
353 sibling
->next
= node
;
357 if (parent
->children
)
359 node
->next
= parent
->children
;
360 parent
->children
->prev
= node
;
362 parent
->children
= node
;
370 * @parent: the #GNode to place the new #GNode under
371 * @node: the #GNode to insert
373 * Inserts a #GNode as the first child of the given parent.
375 * Returns: the inserted #GNode
378 g_node_prepend (GNode
*parent
,
381 g_return_val_if_fail (parent
!= NULL
, node
);
383 return g_node_insert_before (parent
, parent
->children
, node
);
390 * Gets the root of a tree.
392 * Returns: the root of the tree
395 g_node_get_root (GNode
*node
)
397 g_return_val_if_fail (node
!= NULL
, NULL
);
406 * g_node_is_ancestor:
408 * @descendant: a #GNode
410 * Returns %TRUE if @node is an ancestor of @descendant.
411 * This is true if node is the parent of @descendant,
412 * or if node is the grandparent of @descendant etc.
414 * Returns: %TRUE if @node is an ancestor of @descendant
417 g_node_is_ancestor (GNode
*node
,
420 g_return_val_if_fail (node
!= NULL
, FALSE
);
421 g_return_val_if_fail (descendant
!= NULL
, FALSE
);
425 if (descendant
->parent
== node
)
428 descendant
= descendant
->parent
;
438 * Gets the depth of a #GNode.
440 * If @node is %NULL the depth is 0. The root node has a depth of 1.
441 * For the children of the root node the depth is 2. And so on.
443 * Returns: the depth of the #GNode
446 g_node_depth (GNode
*node
)
460 * g_node_reverse_children:
463 * Reverses the order of the children of a #GNode.
464 * (It doesn't change the order of the grandchildren.)
467 g_node_reverse_children (GNode
*node
)
472 g_return_if_fail (node
!= NULL
);
474 child
= node
->children
;
480 last
->next
= last
->prev
;
483 node
->children
= last
;
490 * Gets the maximum height of all branches beneath a #GNode.
491 * This is the maximum distance from the #GNode to all leaf nodes.
493 * If @root is %NULL, 0 is returned. If @root has no children,
494 * 1 is returned. If @root has children, 2 is returned. And so on.
496 * Returns: the maximum height of the tree beneath @root
499 g_node_max_height (GNode
*root
)
502 guint max_height
= 0;
507 child
= root
->children
;
512 tmp_height
= g_node_max_height (child
);
513 if (tmp_height
> max_height
)
514 max_height
= tmp_height
;
518 return max_height
+ 1;
522 g_node_traverse_pre_order (GNode
*node
,
523 GTraverseFlags flags
,
524 GNodeTraverseFunc func
,
531 if ((flags
& G_TRAVERSE_NON_LEAFS
) &&
535 child
= node
->children
;
541 child
= current
->next
;
542 if (g_node_traverse_pre_order (current
, flags
, func
, data
))
546 else if ((flags
& G_TRAVERSE_LEAFS
) &&
554 g_node_depth_traverse_pre_order (GNode
*node
,
555 GTraverseFlags flags
,
557 GNodeTraverseFunc func
,
564 if ((flags
& G_TRAVERSE_NON_LEAFS
) &&
572 child
= node
->children
;
578 child
= current
->next
;
579 if (g_node_depth_traverse_pre_order (current
, flags
, depth
, func
, data
))
583 else if ((flags
& G_TRAVERSE_LEAFS
) &&
591 g_node_traverse_post_order (GNode
*node
,
592 GTraverseFlags flags
,
593 GNodeTraverseFunc func
,
600 child
= node
->children
;
606 child
= current
->next
;
607 if (g_node_traverse_post_order (current
, flags
, func
, data
))
611 if ((flags
& G_TRAVERSE_NON_LEAFS
) &&
616 else if ((flags
& G_TRAVERSE_LEAFS
) &&
624 g_node_depth_traverse_post_order (GNode
*node
,
625 GTraverseFlags flags
,
627 GNodeTraverseFunc func
,
637 child
= node
->children
;
643 child
= current
->next
;
644 if (g_node_depth_traverse_post_order (current
, flags
, depth
, func
, data
))
649 if ((flags
& G_TRAVERSE_NON_LEAFS
) &&
654 else if ((flags
& G_TRAVERSE_LEAFS
) &&
662 g_node_traverse_in_order (GNode
*node
,
663 GTraverseFlags flags
,
664 GNodeTraverseFunc func
,
672 child
= node
->children
;
674 child
= current
->next
;
676 if (g_node_traverse_in_order (current
, flags
, func
, data
))
679 if ((flags
& G_TRAVERSE_NON_LEAFS
) &&
686 child
= current
->next
;
687 if (g_node_traverse_in_order (current
, flags
, func
, data
))
691 else if ((flags
& G_TRAVERSE_LEAFS
) &&
699 g_node_depth_traverse_in_order (GNode
*node
,
700 GTraverseFlags flags
,
702 GNodeTraverseFunc func
,
713 child
= node
->children
;
715 child
= current
->next
;
717 if (g_node_depth_traverse_in_order (current
, flags
, depth
, func
, data
))
720 if ((flags
& G_TRAVERSE_NON_LEAFS
) &&
727 child
= current
->next
;
728 if (g_node_depth_traverse_in_order (current
, flags
, depth
, func
, data
))
732 else if ((flags
& G_TRAVERSE_NON_LEAFS
) &&
736 else if ((flags
& G_TRAVERSE_LEAFS
) &&
744 g_node_traverse_level (GNode
*node
,
745 GTraverseFlags flags
,
747 GNodeTraverseFunc func
,
749 gboolean
*more_levels
)
756 return (flags
& G_TRAVERSE_NON_LEAFS
) && func (node
, data
);
760 return (flags
& G_TRAVERSE_LEAFS
) && func (node
, data
);
765 node
= node
->children
;
769 if (g_node_traverse_level (node
, flags
, level
- 1, func
, data
, more_levels
))
780 g_node_depth_traverse_level (GNode
*node
,
781 GTraverseFlags flags
,
783 GNodeTraverseFunc func
,
787 gboolean more_levels
;
790 while (depth
< 0 || level
!= (guint
) depth
)
793 if (g_node_traverse_level (node
, flags
, level
, func
, data
, &more_levels
))
804 * @root: the root #GNode of the tree to traverse
805 * @order: the order in which nodes are visited - %G_IN_ORDER,
806 * %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER.
807 * @flags: which types of children are to be visited, one of
808 * %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
809 * @max_depth: the maximum depth of the traversal. Nodes below this
810 * depth will not be visited. If max_depth is -1 all nodes in
811 * the tree are visited. If depth is 1, only the root is visited.
812 * If depth is 2, the root and its children are visited. And so on.
813 * @func: the function to call for each visited #GNode
814 * @data: user data to pass to the function
816 * Traverses a tree starting at the given root #GNode.
817 * It calls the given function for each node visited.
818 * The traversal can be halted at any point by returning %TRUE from @func.
819 * @func must not do anything that would modify the structure of the tree.
824 * @G_IN_ORDER: vists a node's left child first, then the node itself,
825 * then its right child. This is the one to use if you
826 * want the output sorted according to the compare
828 * @G_PRE_ORDER: visits a node, then its children.
829 * @G_POST_ORDER: visits the node's children, then the node itself.
830 * @G_LEVEL_ORDER: is not implemented for
831 * [balanced binary trees][glib-Balanced-Binary-Trees].
832 * For [n-ary trees][glib-N-ary-Trees], it
833 * vists the root node first, then its children, then
834 * its grandchildren, and so on. Note that this is less
835 * efficient than the other orders.
837 * Specifies the type of traveral performed by g_tree_traverse(),
838 * g_node_traverse() and g_node_find(). The different orders are
840 * - In order: A, B, C, D, E, F, G, H, I
841 * ![](Sorted_binary_tree_inorder.svg)
842 * - Pre order: F, B, A, D, C, E, G, I, H
843 * ![](Sorted_binary_tree_preorder.svg)
844 * - Post order: A, C, E, D, B, H, I, G, F
845 * ![](Sorted_binary_tree_postorder.svg)
846 * - Level order: F, B, G, A, D, I, C, E, H
847 * ![](Sorted_binary_tree_breadth-first_traversal.svg)
852 * @G_TRAVERSE_LEAVES: only leaf nodes should be visited. This name has
853 * been introduced in 2.6, for older version use
855 * @G_TRAVERSE_NON_LEAVES: only non-leaf nodes should be visited. This
856 * name has been introduced in 2.6, for older
857 * version use %G_TRAVERSE_NON_LEAFS.
858 * @G_TRAVERSE_ALL: all nodes should be visited.
859 * @G_TRAVERSE_MASK: a mask of all traverse flags.
860 * @G_TRAVERSE_LEAFS: identical to %G_TRAVERSE_LEAVES.
861 * @G_TRAVERSE_NON_LEAFS: identical to %G_TRAVERSE_NON_LEAVES.
863 * Specifies which nodes are visited during several of the tree
864 * functions, including g_node_traverse() and g_node_find().
869 * @data: user data passed to g_node_traverse().
871 * Specifies the type of function passed to g_node_traverse(). The
872 * function is called with each of the nodes visited, together with the
873 * user data passed to g_node_traverse(). If the function returns
874 * %TRUE, then the traversal is stopped.
876 * Returns: %TRUE to stop the traversal.
879 g_node_traverse (GNode
*root
,
881 GTraverseFlags flags
,
883 GNodeTraverseFunc func
,
886 g_return_if_fail (root
!= NULL
);
887 g_return_if_fail (func
!= NULL
);
888 g_return_if_fail (order
<= G_LEVEL_ORDER
);
889 g_return_if_fail (flags
<= G_TRAVERSE_MASK
);
890 g_return_if_fail (depth
== -1 || depth
> 0);
896 g_node_traverse_pre_order (root
, flags
, func
, data
);
898 g_node_depth_traverse_pre_order (root
, flags
, depth
, func
, data
);
902 g_node_traverse_post_order (root
, flags
, func
, data
);
904 g_node_depth_traverse_post_order (root
, flags
, depth
, func
, data
);
908 g_node_traverse_in_order (root
, flags
, func
, data
);
910 g_node_depth_traverse_in_order (root
, flags
, depth
, func
, data
);
913 g_node_depth_traverse_level (root
, flags
, depth
, func
, data
);
919 g_node_find_func (GNode
*node
,
924 if (*d
!= node
->data
)
934 * @root: the root #GNode of the tree to search
935 * @order: the order in which nodes are visited - %G_IN_ORDER,
936 * %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER
937 * @flags: which types of children are to be searched, one of
938 * %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
939 * @data: the data to find
941 * Finds a #GNode in a tree.
943 * Returns: the found #GNode, or %NULL if the data is not found
946 g_node_find (GNode
*root
,
948 GTraverseFlags flags
,
953 g_return_val_if_fail (root
!= NULL
, NULL
);
954 g_return_val_if_fail (order
<= G_LEVEL_ORDER
, NULL
);
955 g_return_val_if_fail (flags
<= G_TRAVERSE_MASK
, NULL
);
960 g_node_traverse (root
, order
, flags
, -1, g_node_find_func
, d
);
966 g_node_count_func (GNode
*node
,
967 GTraverseFlags flags
,
974 if (flags
& G_TRAVERSE_NON_LEAFS
)
977 child
= node
->children
;
980 g_node_count_func (child
, flags
, n
);
984 else if (flags
& G_TRAVERSE_LEAFS
)
991 * @flags: which types of children are to be counted, one of
992 * %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
994 * Gets the number of nodes in a tree.
996 * Returns: the number of nodes in the tree
999 g_node_n_nodes (GNode
*root
,
1000 GTraverseFlags flags
)
1004 g_return_val_if_fail (root
!= NULL
, 0);
1005 g_return_val_if_fail (flags
<= G_TRAVERSE_MASK
, 0);
1007 g_node_count_func (root
, flags
, &n
);
1013 * g_node_last_child:
1014 * @node: a #GNode (must not be %NULL)
1016 * Gets the last child of a #GNode.
1018 * Returns: the last child of @node, or %NULL if @node has no children
1021 g_node_last_child (GNode
*node
)
1023 g_return_val_if_fail (node
!= NULL
, NULL
);
1025 node
= node
->children
;
1036 * @n: the index of the desired child
1038 * Gets a child of a #GNode, using the given index.
1039 * The first child is at index 0. If the index is
1040 * too big, %NULL is returned.
1042 * Returns: the child of @node at index @n
1045 g_node_nth_child (GNode
*node
,
1048 g_return_val_if_fail (node
!= NULL
, NULL
);
1050 node
= node
->children
;
1052 while ((n
-- > 0) && node
)
1059 * g_node_n_children:
1062 * Gets the number of children of a #GNode.
1064 * Returns: the number of children of @node
1067 g_node_n_children (GNode
*node
)
1071 g_return_val_if_fail (node
!= NULL
, 0);
1073 node
= node
->children
;
1084 * g_node_find_child:
1086 * @flags: which types of children are to be searched, one of
1087 * %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
1088 * @data: the data to find
1090 * Finds the first child of a #GNode with the given data.
1092 * Returns: the found child #GNode, or %NULL if the data is not found
1095 g_node_find_child (GNode
*node
,
1096 GTraverseFlags flags
,
1099 g_return_val_if_fail (node
!= NULL
, NULL
);
1100 g_return_val_if_fail (flags
<= G_TRAVERSE_MASK
, NULL
);
1102 node
= node
->children
;
1105 if (node
->data
== data
)
1107 if (G_NODE_IS_LEAF (node
))
1109 if (flags
& G_TRAVERSE_LEAFS
)
1114 if (flags
& G_TRAVERSE_NON_LEAFS
)
1125 * g_node_child_position:
1127 * @child: a child of @node
1129 * Gets the position of a #GNode with respect to its siblings.
1130 * @child must be a child of @node. The first child is numbered 0,
1131 * the second 1, and so on.
1133 * Returns: the position of @child with respect to its siblings
1136 g_node_child_position (GNode
*node
,
1141 g_return_val_if_fail (node
!= NULL
, -1);
1142 g_return_val_if_fail (child
!= NULL
, -1);
1143 g_return_val_if_fail (child
->parent
== node
, -1);
1145 node
= node
->children
;
1158 * g_node_child_index:
1160 * @data: the data to find
1162 * Gets the position of the first child of a #GNode
1163 * which contains the given data.
1165 * Returns: the index of the child of @node which contains
1166 * @data, or -1 if the data is not found
1169 g_node_child_index (GNode
*node
,
1174 g_return_val_if_fail (node
!= NULL
, -1);
1176 node
= node
->children
;
1179 if (node
->data
== data
)
1189 * g_node_first_sibling:
1192 * Gets the first sibling of a #GNode.
1193 * This could possibly be the node itself.
1195 * Returns: the first sibling of @node
1198 g_node_first_sibling (GNode
*node
)
1200 g_return_val_if_fail (node
!= NULL
, NULL
);
1203 return node
->parent
->children
;
1212 * g_node_last_sibling:
1215 * Gets the last sibling of a #GNode.
1216 * This could possibly be the node itself.
1218 * Returns: the last sibling of @node
1221 g_node_last_sibling (GNode
*node
)
1223 g_return_val_if_fail (node
!= NULL
, NULL
);
1232 * g_node_children_foreach:
1234 * @flags: which types of children are to be visited, one of
1235 * %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
1236 * @func: the function to call for each visited node
1237 * @data: user data to pass to the function
1239 * Calls a function for each of the children of a #GNode. Note that it
1240 * doesn't descend beneath the child nodes. @func must not do anything
1241 * that would modify the structure of the tree.
1246 * @data: user data passed to g_node_children_foreach().
1248 * Specifies the type of function passed to g_node_children_foreach().
1249 * The function is called with each child node, together with the user
1250 * data passed to g_node_children_foreach().
1253 g_node_children_foreach (GNode
*node
,
1254 GTraverseFlags flags
,
1255 GNodeForeachFunc func
,
1258 g_return_if_fail (node
!= NULL
);
1259 g_return_if_fail (flags
<= G_TRAVERSE_MASK
);
1260 g_return_if_fail (func
!= NULL
);
1262 node
= node
->children
;
1268 node
= current
->next
;
1269 if (G_NODE_IS_LEAF (current
))
1271 if (flags
& G_TRAVERSE_LEAFS
)
1272 func (current
, data
);
1276 if (flags
& G_TRAVERSE_NON_LEAFS
)
1277 func (current
, data
);