Node

The #GNode struct represents one node in a [n-ary tree][glib-N-ary-Trees].

Members

Functions

childIndex
int childIndex(void* data)

Gets the position of the first child of a #GNode which contains the given data.

childPosition
int childPosition(glib.node.Node child)

Gets the position of a #GNode with respect to its siblings. child must be a child of node. The first child is numbered 0, the second 1, and so on.

childrenForeach
void childrenForeach(glib.types.TraverseFlags flags, glib.types.NodeForeachFunc func)

Calls a function for each of the children of a #GNode. Note that it doesn't descend beneath the child nodes. func must not do anything that would modify the structure of the tree.

depth
uint depth()

Gets the depth of a #GNode.

destroy
void destroy()

Removes root and its children from the tree, freeing any memory allocated.

isAncestor
bool isAncestor(glib.node.Node descendant)

Returns true if node is an ancestor of descendant. This is true if node is the parent of descendant, or if node is the grandparent of descendant etc.

maxHeight
uint maxHeight()

Gets the maximum height of all branches beneath a #GNode. This is the maximum distance from the #GNode to all leaf nodes.

nChildren
uint nChildren()

Gets the number of children of a #GNode.

nNodes
uint nNodes(glib.types.TraverseFlags flags)

Gets the number of nodes in a tree.

reverseChildren
void reverseChildren()

Reverses the order of the children of a #GNode. (It doesn't change the order of the grandchildren.)

traverse
void traverse(glib.types.TraverseType order, glib.types.TraverseFlags flags, int maxDepth, glib.types.NodeTraverseFunc func)

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 func. func must not do anything that would modify the structure of the tree.

unlink
void unlink()

Unlinks a #GNode from a tree, resulting in two separate trees.

Static functions

popAllocator
void popAllocator()
pushAllocator
void pushAllocator(glib.types.Allocator allocator)