From c226088028b2664b601c7ee8a407acb2339115a5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 24 Sep 2023 22:47:21 -0400 Subject: [PATCH] docs: Move the GNode SECTION Move the contents to the data-structures.md file. Helps: #3037 --- docs/reference/glib/data-structures.md | 30 +++++++++++++++++++++ glib/gnode.c | 37 -------------------------- 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/docs/reference/glib/data-structures.md b/docs/reference/glib/data-structures.md index d7fbd427a..995b2777c 100644 --- a/docs/reference/glib/data-structures.md +++ b/docs/reference/glib/data-structures.md @@ -392,3 +392,33 @@ To traverse a `GTree`, calling a function for each node visited in the traversal, use [method@GLib.Tree.foreach]. To destroy a `GTree`, use [method@GLib.Tree.destroy]. + +## N-ary Trees + +The [struct@GLib.Node] struct and its associated functions provide a N-ary tree +data structure, where nodes in the tree can contain arbitrary data. + +To create a new tree use [func@GLib.Node.new]. + +To insert a node into a tree use [method@GLib.Node.insert], [method@GLib.Node.insert_before], +[func@GLib.node_append] and [method@GLib.Node.prepend], + +To create a new node and insert it into a tree use [func@GLib.node_insert_data], +[func@GLib.node_insert_data_after], [func@GLib.node_insert_data_before], +[func@GLib.node_append_data] and [func@GLib.node_prepend_data]. + +To reverse the children of a node use [method@GLib.Node.reverse_children]. + +To find a node use [method@GLib.Node.get_root], [method@GLib.Node.find], [method@GLib.Node.find_child], +[method@GLib.Node.child_index], [method@GLib.Node.child_position], [func@GLib.node_first_child], +[method@GLib.Node.last_child], [method@GLib.Node.nth_child], [method@GLib.Node.first_sibling], +[func@GLib.node_prev_sibling], [func@GLib.node_next_sibling] or [method@GLib.Node.last_sibling]. + +To get information about a node or tree use `G_NODE_IS_LEAF()`, +`G_NODE_IS_ROOT()`, [method@GLib.Node.depth], [method@GLib.Node.n_nodes], +[method@GLib.Node.n_children], [method@GLib.Node.is_ancestor] or [method@GLib.Node.max_height]. + +To traverse a tree, calling a function for each node visited in the traversal, use +[method@GLib.Node.traverse] or [method@GLib.Node.children_foreach]. + +To remove a node or subtree from a tree use [method@GLib.Node.unlink] or [method@GLib.Node.destroy]. diff --git a/glib/gnode.c b/glib/gnode.c index b9a68c2f6..e07f126d0 100644 --- a/glib/gnode.c +++ b/glib/gnode.c @@ -39,43 +39,6 @@ #include "gtestutils.h" -/** - * SECTION:trees-nary - * @title: N-ary Trees - * @short_description: trees of data with any number of branches - * - * The #GNode struct and its associated functions provide a N-ary tree - * data structure, where nodes in the tree can contain arbitrary data. - * - * To create a new tree use g_node_new(). - * - * To insert a node into a tree use g_node_insert(), - * g_node_insert_before(), g_node_append() and g_node_prepend(). - * - * To create a new node and insert it into a tree use - * g_node_insert_data(), g_node_insert_data_after(), - * g_node_insert_data_before(), g_node_append_data() - * and g_node_prepend_data(). - * - * To reverse the children of a node use g_node_reverse_children(). - * - * To find a node use g_node_get_root(), g_node_find(), - * g_node_find_child(), g_node_child_index(), g_node_child_position(), - * g_node_first_child(), g_node_last_child(), g_node_nth_child(), - * g_node_first_sibling(), g_node_prev_sibling(), g_node_next_sibling() - * or g_node_last_sibling(). - * - * To get information about a node or tree use G_NODE_IS_LEAF(), - * G_NODE_IS_ROOT(), g_node_depth(), g_node_n_nodes(), - * g_node_n_children(), g_node_is_ancestor() or g_node_max_height(). - * - * To traverse a tree, calling a function for each node visited in the - * traversal, use g_node_traverse() or g_node_children_foreach(). - * - * To remove a node or subtree from a tree use g_node_unlink() or - * g_node_destroy(). - **/ - /** * GNode: * @data: contains the actual data of the node.