⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arrays.sgml

📁 GLib是GTK+和GNOME工程的基础底层核心程序库
💻 SGML
📖 第 1 页 / 共 2 页
字号:
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the <link linkend="GArray">GArray</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-array-prepend-vals">g_array_prepend_vals ()</title><programlisting><link linkend="GArray">GArray</link>*     g_array_prepend_vals            (<link linkend="GArray">GArray</link> *array,                                             <link linkend="gconstpointer">gconstpointer</link> data,                                             <link linkend="guint">guint</link> len);</programlisting><para>Adds <parameter>len</parameter> elements onto the start of the array.</para><para>This operation is slower than <link linkend="g-array-append-vals">g_array_append_vals</link>() since the existing elementsin the array have to be moved to make space for the new elements.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter>&nbsp;:</entry><entry>a <link linkend="GArray">GArray</link>.</entry></row><row><entry align="right"><parameter>data</parameter>&nbsp;:</entry><entry>a pointer to the elements to prepend to the start of the array.</entry></row><row><entry align="right"><parameter>len</parameter>&nbsp;:</entry><entry>the number of elements to prepend.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the <link linkend="GArray">GArray</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-array-insert-val">g_array_insert_val()</title><programlisting>#define     g_array_insert_val(a,i,v)</programlisting><para>Inserts an element into an array at the given index.</para><note><para><link linkend="g-array-insert-val">g_array_insert_val</link>() is a macro which uses a reference to the valueparameter <parameter>v</parameter>. This means that you cannot use it with literal valuessuch as "27". You must use variables.</para></note><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>a</parameter>&nbsp;:</entry><entry>a <link linkend="GArray">GArray</link>.</entry></row><row><entry align="right"><parameter>i</parameter>&nbsp;:</entry><entry>the index to place the element at.</entry></row><row><entry align="right"><parameter>v</parameter>&nbsp;:</entry><entry>the value to insert into the array.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the <link linkend="GArray">GArray</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-array-insert-vals">g_array_insert_vals ()</title><programlisting><link linkend="GArray">GArray</link>*     g_array_insert_vals             (<link linkend="GArray">GArray</link> *array,                                             <link linkend="guint">guint</link> index,                                             <link linkend="gconstpointer">gconstpointer</link> data,                                             <link linkend="guint">guint</link> len);</programlisting><para>Inserts <parameter>len</parameter> elements into a <link linkend="GArray">GArray</link> at the given index.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter>&nbsp;:</entry><entry>a <link linkend="GArray">GArray</link>.</entry></row><row><entry align="right"><parameter>index</parameter>&nbsp;:</entry><entry>the index to place the elements at.</entry></row><row><entry align="right"><parameter>data</parameter>&nbsp;:</entry><entry>a pointer to the elements to insert.</entry></row><row><entry align="right"><parameter>len</parameter>&nbsp;:</entry><entry>the number of elements to insert.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the <link linkend="GArray">GArray</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-array-remove-index">g_array_remove_index ()</title><programlisting><link linkend="GArray">GArray</link>*     g_array_remove_index            (<link linkend="GArray">GArray</link> *array,                                             <link linkend="guint">guint</link> index);</programlisting><para>Removes the element at the given index from a <link linkend="GArray">GArray</link>.The following elements are moved down one place.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter>&nbsp;:</entry><entry>a <link linkend="GArray">GArray</link>.</entry></row><row><entry align="right"><parameter>index</parameter>&nbsp;:</entry><entry>the index of the element to remove.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the <link linkend="GArray">GArray</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-array-remove-index-fast">g_array_remove_index_fast ()</title><programlisting><link linkend="GArray">GArray</link>*     g_array_remove_index_fast       (<link linkend="GArray">GArray</link> *array,                                             <link linkend="guint">guint</link> index);</programlisting><para>Removes the element at the given index from a <link linkend="GArray">GArray</link>.The last element in the array is used to fill in the space, so this functiondoes not preserve the order of the <link linkend="GArray">GArray</link>. But it is faster than<link linkend="g-array-remove-index">g_array_remove_index</link>().</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter>&nbsp;:</entry><entry>a <parameter>GArray</parameter>.</entry></row><row><entry align="right"><parameter>index</parameter>&nbsp;:</entry><entry>the index of the element to remove.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the <link linkend="GArray">GArray</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-array-sort">g_array_sort ()</title><programlisting>void        g_array_sort                    (<link linkend="GArray">GArray</link> *array,                                             <link linkend="GCompareFunc">GCompareFunc</link> compare_func);</programlisting><para>Sorts a <link linkend="GArray">GArray</link> using <parameter>compare_func</parameter> which should be a <function><link linkend="qsort">qsort</link>()</function>-style comparisonfunction (returns -1 for first arg is less than second arg, 0 for equal, 1 iffirst arg is greater than second arg).</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter>&nbsp;:</entry><entry>a <link linkend="GArray">GArray</link>.</entry></row><row><entry align="right"><parameter>compare_func</parameter>&nbsp;:</entry><entry>comparison function.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-array-sort-with-data">g_array_sort_with_data ()</title><programlisting>void        g_array_sort_with_data          (<link linkend="GArray">GArray</link> *array,                                             <link linkend="GCompareDataFunc">GCompareDataFunc</link> compare_func,                                             <link linkend="gpointer">gpointer</link> user_data);</programlisting><para>Like <link linkend="g-array-sort">g_array_sort</link>(), but the comparison function receives a user dataargument.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter>&nbsp;:</entry><entry>a <link linkend="GArray">GArray</link>.</entry></row><row><entry align="right"><parameter>compare_func</parameter>&nbsp;:</entry><entry>comparison function.</entry></row><row><entry align="right"><parameter>user_data</parameter>&nbsp;:</entry><entry>data to pass to <parameter>compare_func</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-array-index">g_array_index()</title><programlisting>#define     g_array_index(a,t,i)</programlisting><para>Returns the element of a <link linkend="GArray">GArray</link> at the given index.The return value is cast to the given type.<example><title>Getting a pointer to an element in a <structname>GArray</structname>.</title><programlisting>  EDayViewEvent *event;  /* This gets a pointer to the 3rd element in the array of EDayViewEvent     structs. */  event = &amp;g_array_index (events, EDayViewEvent, 3);</programlisting></example></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>a</parameter>&nbsp;:</entry><entry>a <link linkend="GArray">GArray</link>.</entry></row><row><entry align="right"><parameter>t</parameter>&nbsp;:</entry><entry>the type of the elements.</entry></row><row><entry align="right"><parameter>i</parameter>&nbsp;:</entry><entry>the index of the element to return.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the element of the <link linkend="GArray">GArray</link> at the index given by <parameter>i</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-array-set-size">g_array_set_size ()</title><programlisting><link linkend="GArray">GArray</link>*     g_array_set_size                (<link linkend="GArray">GArray</link> *array,                                             <link linkend="guint">guint</link> length);</programlisting><para>Sets the size of the array, expanding it if necessary.If the array was created with <parameter>clear</parameter> set to <literal>TRUE</literal>, the new elements are set to 0.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter>&nbsp;:</entry><entry>a <link linkend="GArray">GArray</link>.</entry></row><row><entry align="right"><parameter>length</parameter>&nbsp;:</entry><entry>the new size of the <link linkend="GArray">GArray</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the <link linkend="GArray">GArray</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-array-free">g_array_free ()</title><programlisting><link linkend="gchar">gchar</link>*      g_array_free                    (<link linkend="GArray">GArray</link> *array,                                             <link linkend="gboolean">gboolean</link> free_segment);</programlisting><para>Frees the memory allocated for the <link linkend="GArray">GArray</link>.If <parameter>free_segment</parameter> is <literal>TRUE</literal> it frees the actual element data as well.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter>&nbsp;:</entry><entry>a <link linkend="GArray">GArray</link>.</entry></row><row><entry align="right"><parameter>free_segment</parameter>&nbsp;:</entry><entry>if <literal>TRUE</literal> the actual element data is freed as well.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry></entry></row></tbody></tgroup></informaltable></refsect2></refsect1></refentry>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -