📄 trees-nary.sgml
字号:
<row><entry align="right"><parameter>node</parameter> :</entry><entry>a <link linkend="GNode">GNode</link>.</entry></row><row><entry align="right"><parameter>data</parameter> :</entry><entry>user data passed to <link linkend="g-node-traverse">g_node_traverse</link>().</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> to stop the traversal.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-node-children-foreach">g_node_children_foreach ()</title><programlisting>void g_node_children_foreach (<link linkend="GNode">GNode</link> *node, <link linkend="GTraverseFlags">GTraverseFlags</link> flags, <link linkend="GNodeForeachFunc">GNodeForeachFunc</link> func, <link linkend="gpointer">gpointer</link> data);</programlisting><para>Calls a function for each of the children of a <link linkend="GNode">GNode</link>.Note that it doesn't descend beneath the child nodes.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>node</parameter> :</entry><entry>a <link linkend="GNode">GNode</link>.</entry></row><row><entry align="right"><parameter>flags</parameter> :</entry><entry>which types of children are to be visited, one of <literal>G_TRAVERSE_ALL</literal>,<literal>G_TRAVERSE_LEAFS</literal> and <literal>G_TRAVERSE_NON_LEAFS</literal>.</entry></row><row><entry align="right"><parameter>func</parameter> :</entry><entry>the function to call for each visited node.</entry></row><row><entry align="right"><parameter>data</parameter> :</entry><entry>user data to pass to the function.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GNodeForeachFunc">GNodeForeachFunc ()</title><programlisting>void (*GNodeForeachFunc) (<link linkend="GNode">GNode</link> *node, <link linkend="gpointer">gpointer</link> data);</programlisting><para>Specifies the type of function passed to <link linkend="g-node-children-foreach">g_node_children_foreach</link>().The function is called with each child node, together with the user datapassed to <link linkend="g-node-children-foreach">g_node_children_foreach</link>().</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>node</parameter> :</entry><entry>a <link linkend="GNode">GNode</link>.</entry></row><row><entry align="right"><parameter>data</parameter> :</entry><entry>user data passed to <link linkend="g-node-children-foreach">g_node_children_foreach</link>().</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-node-get-root">g_node_get_root ()</title><programlisting><link linkend="GNode">GNode</link>* g_node_get_root (<link linkend="GNode">GNode</link> *node);</programlisting><para>Gets the root of a tree.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>node</parameter> :</entry><entry>a <link linkend="GNode">GNode</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the root of the tree.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-node-find">g_node_find ()</title><programlisting><link linkend="GNode">GNode</link>* g_node_find (<link linkend="GNode">GNode</link> *root, <link linkend="GTraverseType">GTraverseType</link> order, <link linkend="GTraverseFlags">GTraverseFlags</link> flags, <link linkend="gpointer">gpointer</link> data);</programlisting><para>Finds a <link linkend="GNode">GNode</link> in a tree.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>root</parameter> :</entry><entry>the root <link linkend="GNode">GNode</link> of the tree to search.</entry></row><row><entry align="right"><parameter>order</parameter> :</entry><entry>the order in which nodes are visited - <literal>G_IN_ORDER</literal>, <literal>G_PRE_ORDER</literal>,<literal>G_POST_ORDER</literal>, or <literal>G_LEVEL_ORDER</literal>.</entry></row><row><entry align="right"><parameter>flags</parameter> :</entry><entry>which types of children are to be searched, one of <literal>G_TRAVERSE_ALL</literal>,<literal>G_TRAVERSE_LEAFS</literal> and <literal>G_TRAVERSE_NON_LEAFS</literal>.</entry></row><row><entry align="right"><parameter>data</parameter> :</entry><entry>the data to find.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the found <link linkend="GNode">GNode</link>, or <literal>NULL</literal> if the data is not found.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-node-find-child">g_node_find_child ()</title><programlisting><link linkend="GNode">GNode</link>* g_node_find_child (<link linkend="GNode">GNode</link> *node, <link linkend="GTraverseFlags">GTraverseFlags</link> flags, <link linkend="gpointer">gpointer</link> data);</programlisting><para>Finds the first child of a <link linkend="GNode">GNode</link> with the given data.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>node</parameter> :</entry><entry>a <link linkend="GNode">GNode</link>.</entry></row><row><entry align="right"><parameter>flags</parameter> :</entry><entry>which types of children are to be searched, one of <literal>G_TRAVERSE_ALL</literal>,<literal>G_TRAVERSE_LEAFS</literal> and <literal>G_TRAVERSE_NON_LEAFS</literal>.</entry></row><row><entry align="right"><parameter>data</parameter> :</entry><entry>the data to find.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the found child <link linkend="GNode">GNode</link>, or <literal>NULL</literal> if the data is not found.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-node-child-index">g_node_child_index ()</title><programlisting><link linkend="gint">gint</link> g_node_child_index (<link linkend="GNode">GNode</link> *node, <link linkend="gpointer">gpointer</link> data);</programlisting><para>Gets the position of the first child of a <link linkend="GNode">GNode</link> which contains the given data.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>node</parameter> :</entry><entry>a <link linkend="GNode">GNode</link>.</entry></row><row><entry align="right"><parameter>data</parameter> :</entry><entry>the data to find.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the index of the child of <parameter>node</parameter> which contains <parameter>data</parameter>, or -1if the data is not found.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-node-child-position">g_node_child_position ()</title><programlisting><link linkend="gint">gint</link> g_node_child_position (<link linkend="GNode">GNode</link> *node, <link linkend="GNode">GNode</link> *child);</programlisting><para>Gets the position of a <link linkend="GNode">GNode</link> with respect to its siblings.<parameter>child</parameter> must be a child of <parameter>node</parameter>.The first child is numbered 0, the second 1, and so on.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>node</parameter> :</entry><entry>a <link linkend="GNode">GNode</link>.</entry></row><row><entry align="right"><parameter>child</parameter> :</entry><entry>a child of <parameter>node</parameter>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the position of <parameter>child</parameter> with respect to its siblings.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-node-first-child">g_node_first_child()</title><programlisting>#define g_node_first_child(node)</programlisting><para>Gets the first child of a <link linkend="GNode">GNode</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>node</parameter> :</entry><entry>a <link linkend="GNode">GNode</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the last child of <parameter>node</parameter>, or <literal>NULL</literal> if <parameter>node</parameter> is <literal>NULL</literal> or has no children.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-node-last-child">g_node_last_child ()</title><programlisting><link linkend="GNode">GNode</link>* g_node_last_child (<link linkend="GNode">GNode</link> *node);</programlisting><para>Gets the last child of a <link linkend="GNode">GNode</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>node</parameter> :</entry><entry>a <link linkend="GNode">GNode</link> (must not be <literal>NULL</literal>).</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the last child of <parameter>node</parameter>, or <literal>NULL</literal> if <parameter>node</parameter> has no children.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-node-nth-child">g_node_nth_child ()</title><programlisting><link linkend="GNode">GNode</link>* g_node_nth_child (<link linkend="GNode">GNode</link> *node, <link linkend="guint">guint</link> n);</programlisting><para>Gets a child of a <link linkend="GNode">GNode</link>, using the given index.The first child is at index 0. If the index is too big, <literal>NULL</literal> is returned.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>node</parameter> :</entry><entry>a <link linkend="GNode">GNode</link>.</entry></row><row><entry align="right"><parameter>n</parameter> :</entry><entry>the index of the desired child.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the child of <parameter>node</parameter> at index <parameter>n</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-node-first-sibling">g_node_first_sibling ()</title><programlisting><link linkend="GNode">GNode</link>* g_node_first_sibling (<link linkend="GNode">GNode</link> *node);</programlisting><para>Gets the first sibling of a <link linkend="GNode">GNode</link>.This could possibly be the node itself.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>node</parameter> :</entry><entry>a <link linkend="GNode">GNode</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the first sibling of <parameter>node</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-node-next-sibling">g_node_next_sibling()</title>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -