typedef typedefG_BEGIN_DECLS struct _GNode | GNode |
Enumerator | Value | Description |
---|---|---|
G_TRAVERSE_LEAVES | 1 << 0 | |
G_TRAVERSE_NON_LEAVES | 1 << 1 | |
G_TRAVERSE_ALL | G_TRAVERSE_LEAVES | G_TRAVERSE_NON_LEAVES | |
G_TRAVERSE_MASK | 0x03 | |
G_TRAVERSE_LEAFS | G_TRAVERSE_LEAVES | |
G_TRAVERSE_NON_LEAFS | G_TRAVERSE_NON_LEAVES |
Enumerator | Value | Description |
---|---|---|
G_IN_ORDER | ||
G_PRE_ORDER | ||
G_POST_ORDER | ||
G_LEVEL_ORDER |
typedef gboolean(* | GNodeTraverseFunc |
typedef void(* | GNodeForeachFunc |
typedef gpointer(* | GCopyFunc |
GCopyFunc: : A pointer to the data which should be copied : Additional data
A function of this signature is used to copy the node data when doing a deep-copy of a tree.
Returns: A pointer to the copy
Since: 2.4
g_node_new: : the data of the new node
Creates a new GNode containing the given data. Used to create the first node in a tree.
Returns: a new GNode
IMPORT_C void | g_node_destroy | ( | GNode * | root | ) |
g_node_destroy: : the root of the tree/subtree to destroy
Removes and its children from the tree, freeing any memory allocated.
IMPORT_C void | g_node_unlink | ( | GNode * | node | ) |
g_node_unlink: : the GNode to unlink, which becomes the root of a new tree
Unlinks a GNode from a tree, resulting in two separate trees.
g_node_copy_deep: : a GNode : the function which is called to copy the data inside each node, or NULL to use the original data. : data to pass to
Recursively copies a GNode and its data.
Return value: a new GNode containing copies of the data in .
Since: 2.4
g_node_copy: : a GNode
Recursively copies a GNode (but does not deep-copy the data inside the nodes, see g_node_copy_deep() if you need that).
Returns: a new GNode containing the same data pointers
g_node_insert: : the GNode to place under : the position to place at, with respect to its siblings If position is -1, is inserted as the last child of : the GNode to insert
Inserts a GNode beneath the parent at the given position.
Returns: the inserted GNode
g_node_insert_before: : the GNode to place under : the sibling GNode to place before. If sibling is NULL, the node is inserted as the last child of . : the GNode to insert
Inserts a GNode beneath the parent before the given sibling.
Returns: the inserted GNode
g_node_insert_after: : the GNode to place under : the sibling GNode to place after. If sibling is NULL, the node is inserted as the first child of . : the GNode to insert
Inserts a GNode beneath the parent after the given sibling.
Returns: the inserted GNode
g_node_prepend: : the GNode to place the new GNode under : the GNode to insert
Inserts a GNode as the first child of the given parent.
Returns: the inserted GNode
IMPORT_C guint | g_node_n_nodes | ( | GNode * | root, |
GTraverseFlags | flags | |||
) |
g_node_n_nodes: : a GNode : which types of children are to be counted, one of G_TRAVERSE_ALL, G_TRAVERSE_LEAVES and G_TRAVERSE_NON_LEAVES
Gets the number of nodes in a tree.
Returns: the number of nodes in the tree
g_node_is_ancestor: : a GNode : a GNode
Returns TRUE if is an ancestor of . This is true if node is the parent of , or if node is the grandparent of etc.
Returns: TRUE if is an ancestor of
g_node_depth: : a GNode
Gets the depth of a GNode.
If is NULL the depth is 0. The root node has a depth of 1. For the children of the root node the depth is 2. And so on.
Returns: the depth of the GNode
IMPORT_C GNode * | g_node_find | ( | GNode * | root, |
GTraverseType | order, | |||
GTraverseFlags | flags, | |||
gpointer | data | |||
) |
g_node_find: : the root GNode of the tree to search : the order in which nodes are visited - G_IN_ORDER, G_PRE_ORDER, G_POST_ORDER, or G_LEVEL_ORDER : which types of children are to be searched, one of G_TRAVERSE_ALL, G_TRAVERSE_LEAVES and G_TRAVERSE_NON_LEAVES : the data to find
Finds a GNode in a tree.
Returns: the found GNode, or NULL if the data is not found
IMPORT_C void | g_node_traverse | ( | GNode * | root, |
GTraverseType | order, | |||
GTraverseFlags | flags, | |||
gint | max_depth, | |||
GNodeTraverseFunc | func, | |||
gpointer | data | |||
) |
g_node_traverse: : the root GNode of the tree to traverse : the order in which nodes are visited - G_IN_ORDER, G_PRE_ORDER, G_POST_ORDER, or G_LEVEL_ORDER. : which types of children are to be visited, one of G_TRAVERSE_ALL, G_TRAVERSE_LEAVES and G_TRAVERSE_NON_LEAVES : the maximum depth of the traversal. Nodes below this depth will not be visited. If max_depth is -1 all nodes in the tree are visited. If depth is 1, only the root is visited. If depth is 2, the root and its children are visited. And so on. : the function to call for each visited GNode : user data to pass to the function
Traverses a tree starting at the given root GNode. It calls the given function for each node visited. The traversal can be halted at any point by returning TRUE from .
g_node_max_height: : a GNode
Gets the maximum height of all branches beneath a GNode. This is the maximum distance from the GNode to all leaf nodes.
If is NULL, 0 is returned. If has no children, 1 is returned. If has children, 2 is returned. And so on.
Returns: the maximum height of the tree beneath
IMPORT_C void | g_node_children_foreach | ( | GNode * | node, |
GTraverseFlags | flags, | |||
GNodeForeachFunc | func, | |||
gpointer | data | |||
) |
g_node_children_foreach: : a GNode : which types of children are to be visited, one of G_TRAVERSE_ALL, G_TRAVERSE_LEAVES and G_TRAVERSE_NON_LEAVES : the function to call for each visited node : user data to pass to the function
Calls a function for each of the children of a GNode. Note that it doesn't descend beneath the child nodes.
IMPORT_C void | g_node_reverse_children | ( | GNode * | node | ) |
g_node_reverse_children: : a GNode.
Reverses the order of the children of a GNode. (It doesn't change the order of the grandchildren.)
g_node_n_children: : a GNode
Gets the number of children of a GNode.
Returns: the number of children of
g_node_nth_child: : a GNode : the index of the desired child
Gets a child of a GNode, using the given index. The first child is at index 0. If the index is too big, NULL is returned.
Returns: the child of at index
g_node_last_child: : a GNode (must not be NULL)
Gets the last child of a GNode.
Returns: the last child of , or NULL if has no children
IMPORT_C GNode * | g_node_find_child | ( | GNode * | node, |
GTraverseFlags | flags, | |||
gpointer | data | |||
) |
g_node_find_child: : a GNode : which types of children are to be searched, one of G_TRAVERSE_ALL, G_TRAVERSE_LEAVES and G_TRAVERSE_NON_LEAVES : the data to find
Finds the first child of a GNode with the given data.
Returns: the found child GNode, or NULL if the data is not found
g_node_child_position: : a GNode : a child of
Gets the position of a GNode with respect to its siblings. must be a child of . The first child is numbered 0, the second 1, and so on.
Returns: the position of with respect to its siblings
g_node_child_index: : a GNode : the data to find
Gets the position of the first child of a GNode which contains the given data.
Returns: the index of the child of which contains , or -1 if the data is not found
g_node_first_sibling: : a GNode
Gets the first sibling of a GNode. This could possibly be the node itself.
Returns: the first sibling of
g_node_last_sibling: : a GNode
Gets the last sibling of a GNode. This could possibly be the node itself.
Returns: the last sibling of