mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-24 13:06:14 +01:00
docs: Move the GNode SECTION
Move the contents to the data-structures.md file. Helps: #3037
This commit is contained in:
parent
2191c6024a
commit
c226088028
@ -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].
|
||||
|
37
glib/gnode.c
37
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.
|
||||
|
Loading…
Reference in New Issue
Block a user