<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="redland-list">
<refmeta>
<refentrytitle role="top_of_page" id="redland-list.top_of_page">List</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>REDLAND Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>List</refname>
<refpurpose>Simple list class.</refpurpose>
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
</refnamediv>

<refsynopsisdiv id="redland-list.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>
typedef             <link linkend="librdf-list">librdf_list</link>;
<link linkend="librdf-list">librdf_list</link>*        <link linkend="librdf-new-list">librdf_new_list</link>                     (<link linkend="librdf-world">librdf_world</link> *world);
<link linkend="void">void</link>                <link linkend="librdf-free-list">librdf_free_list</link>                    (<link linkend="librdf-list">librdf_list</link> *list);
<link linkend="void">void</link>                <link linkend="librdf-list-clear">librdf_list_clear</link>                   (<link linkend="librdf-list">librdf_list</link> *list);
<link linkend="int">int</link>                 <link linkend="librdf-list-add">librdf_list_add</link>                     (<link linkend="librdf-list">librdf_list</link> *list,
                                                         <link linkend="void">void</link> *data);
<link linkend="int">int</link>                 <link linkend="librdf-list-unshift">librdf_list_unshift</link>                 (<link linkend="librdf-list">librdf_list</link> *list,
                                                         <link linkend="void">void</link> *data);
<link linkend="void">void</link>*               <link linkend="librdf-list-shift">librdf_list_shift</link>                   (<link linkend="librdf-list">librdf_list</link> *list);
<link linkend="void">void</link>*               <link linkend="librdf-list-pop">librdf_list_pop</link>                     (<link linkend="librdf-list">librdf_list</link> *list);
<link linkend="void">void</link>*               <link linkend="librdf-list-remove">librdf_list_remove</link>                  (<link linkend="librdf-list">librdf_list</link> *list,
                                                         <link linkend="void">void</link> *data);
<link linkend="int">int</link>                 <link linkend="librdf-list-contains">librdf_list_contains</link>                (<link linkend="librdf-list">librdf_list</link> *list,
                                                         <link linkend="void">void</link> *data);
<link linkend="int">int</link>                 <link linkend="librdf-list-size">librdf_list_size</link>                    (<link linkend="librdf-list">librdf_list</link> *list);
<link linkend="void">void</link>                <link linkend="librdf-list-set-equals">librdf_list_set_equals</link>              (<link linkend="librdf-list">librdf_list</link> *list,
                                                         <link linkend="int">int</link> (equalsvoid* data1, void *data2) ());
<link linkend="librdf-iterator">librdf_iterator</link>*    <link linkend="librdf-list-get-iterator">librdf_list_get_iterator</link>            (<link linkend="librdf-list">librdf_list</link> *list);
<link linkend="void">void</link>                <link linkend="librdf-list-foreach">librdf_list_foreach</link>                 (<link linkend="librdf-list">librdf_list</link> *list,
                                                         <link linkend="void">void</link> (fnvoid *, void *) (),
                                                         <link linkend="void">void</link> *user_data);
</synopsis>
</refsynopsisdiv>









<refsect1 id="redland-list.description" role="desc">
<title role="desc.title">Description</title>
<para>
A simple list class used internally.
</para>
</refsect1>

<refsect1 id="redland-list.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="librdf-list" role="typedef">
<title>librdf_list</title>
<indexterm zone="librdf-list"><primary>librdf_list</primary></indexterm><programlisting>typedef struct librdf_list_s librdf_list;
</programlisting>
<para>
Redland list class.</para>
<para>

</para></refsect2>
<refsect2 id="librdf-new-list" role="function">
<title>librdf_new_list ()</title>
<indexterm zone="librdf-new-list"><primary>librdf_new_list</primary></indexterm><programlisting><link linkend="librdf-list">librdf_list</link>*        librdf_new_list                     (<link linkend="librdf-world">librdf_world</link> *world);</programlisting>
<para>
Constructor - create a new <link linkend="librdf-list"><type>librdf_list</type></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>world</parameter>&nbsp;:</term>
<listitem><simpara> redland world object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="librdf-list"><type>librdf_list</type></link> or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-free-list" role="function">
<title>librdf_free_list ()</title>
<indexterm zone="librdf-free-list"><primary>librdf_free_list</primary></indexterm><programlisting><link linkend="void">void</link>                librdf_free_list                    (<link linkend="librdf-list">librdf_list</link> *list);</programlisting>
<para>
Destructor - destroy a <link linkend="librdf-list"><type>librdf_list</type></link> object.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>list</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-list"><type>librdf_list</type></link> object
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-list-clear" role="function">
<title>librdf_list_clear ()</title>
<indexterm zone="librdf-list-clear"><primary>librdf_list_clear</primary></indexterm><programlisting><link linkend="void">void</link>                librdf_list_clear                   (<link linkend="librdf-list">librdf_list</link> *list);</programlisting>
<para>
Empty an librdf_list.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>list</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-list"><type>librdf_list</type></link> object
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-list-add" role="function">
<title>librdf_list_add ()</title>
<indexterm zone="librdf-list-add"><primary>librdf_list_add</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_list_add                     (<link linkend="librdf-list">librdf_list</link> *list,
                                                         <link linkend="void">void</link> *data);</programlisting>
<para>
Add a data item to the end of a librdf_list.
</para>
<para>
Equivalent to the list 'push' notion, thus if <link linkend="librdf-list-pop"><function>librdf_list_pop()</function></link>
is called after this, it will return the value added here.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>list</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-list"><type>librdf_list</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&nbsp;:</term>
<listitem><simpara> the data value
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non 0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-list-unshift" role="function">
<title>librdf_list_unshift ()</title>
<indexterm zone="librdf-list-unshift"><primary>librdf_list_unshift</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_list_unshift                 (<link linkend="librdf-list">librdf_list</link> *list,
                                                         <link linkend="void">void</link> *data);</programlisting>
<para>
Add a data item to the start of a librdf_list.
</para>
<para>
if <link linkend="librdf-list-shift"><function>librdf_list_shift()</function></link> is called after this, it will return the value
added here.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>list</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-list"><type>librdf_list</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&nbsp;:</term>
<listitem><simpara> the data value
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non 0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-list-shift" role="function">
<title>librdf_list_shift ()</title>
<indexterm zone="librdf-list-shift"><primary>librdf_list_shift</primary></indexterm><programlisting><link linkend="void">void</link>*               librdf_list_shift                   (<link linkend="librdf-list">librdf_list</link> *list);</programlisting>
<para>
Remove and return the data at the start of the list.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>list</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-list"><type>librdf_list</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> the data object or NULL if the list is empty
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-list-pop" role="function">
<title>librdf_list_pop ()</title>
<indexterm zone="librdf-list-pop"><primary>librdf_list_pop</primary></indexterm><programlisting><link linkend="void">void</link>*               librdf_list_pop                     (<link linkend="librdf-list">librdf_list</link> *list);</programlisting>
<para>
Remove and return the data at the end of the list.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>list</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-list"><type>librdf_list</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> the data object or NULL if the list is empty
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-list-remove" role="function">
<title>librdf_list_remove ()</title>
<indexterm zone="librdf-list-remove"><primary>librdf_list_remove</primary></indexterm><programlisting><link linkend="void">void</link>*               librdf_list_remove                  (<link linkend="librdf-list">librdf_list</link> *list,
                                                         <link linkend="void">void</link> *data);</programlisting>
<para>
Remove a data item from an librdf_list.
</para>
<para>
The search is done using the 'equals' function which may be set
by <link linkend="librdf-list-set-equals"><function>librdf_list_set_equals()</function></link> or by straight comparison of pointers
if not set.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>list</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-list"><type>librdf_list</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&nbsp;:</term>
<listitem><simpara> the data item
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> the data stored or NULL on failure (not found or list empty)
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-list-contains" role="function">
<title>librdf_list_contains ()</title>
<indexterm zone="librdf-list-contains"><primary>librdf_list_contains</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_list_contains                (<link linkend="librdf-list">librdf_list</link> *list,
                                                         <link linkend="void">void</link> *data);</programlisting>
<para>
Check for presence of data item in list.
</para>
<para>
The search is done using the 'equals' function which may be set
by <link linkend="librdf-list-set-equals"><function>librdf_list_set_equals()</function></link> or by straight comparison of pointers
if not set.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>list</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-list"><type>librdf_list</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&nbsp;:</term>
<listitem><simpara> the data value
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non 0 if item was found
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-list-size" role="function">
<title>librdf_list_size ()</title>
<indexterm zone="librdf-list-size"><primary>librdf_list_size</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_list_size                    (<link linkend="librdf-list">librdf_list</link> *list);</programlisting>
<para>
Return the length of the list.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>list</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-list"><type>librdf_list</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> length of the list
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-list-set-equals" role="function">
<title>librdf_list_set_equals ()</title>
<indexterm zone="librdf-list-set-equals"><primary>librdf_list_set_equals</primary></indexterm><programlisting><link linkend="void">void</link>                librdf_list_set_equals              (<link linkend="librdf-list">librdf_list</link> *list,
                                                         <link linkend="int">int</link> (equalsvoid* data1, void *data2) ());</programlisting>
<para>
Set the equals function for the list.
</para>
<para>
The function given is used when comparing items in the list
during searches such as those done in <link linkend="librdf-list-remove"><function>librdf_list_remove()</function></link> or
<link linkend="librdf-list-contains"><function>librdf_list_contains()</function></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>list</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-list"><type>librdf_list</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>equals</parameter>&nbsp;:</term>
<listitem><simpara> the equals function
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-list-get-iterator" role="function">
<title>librdf_list_get_iterator ()</title>
<indexterm zone="librdf-list-get-iterator"><primary>librdf_list_get_iterator</primary></indexterm><programlisting><link linkend="librdf-iterator">librdf_iterator</link>*    librdf_list_get_iterator            (<link linkend="librdf-list">librdf_list</link> *list);</programlisting>
<para>
Get an iterator for the list.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>list</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-list"><type>librdf_list</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="librdf-iterator"><type>librdf_iterator</type></link> object or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-list-foreach" role="function">
<title>librdf_list_foreach ()</title>
<indexterm zone="librdf-list-foreach"><primary>librdf_list_foreach</primary></indexterm><programlisting><link linkend="void">void</link>                librdf_list_foreach                 (<link linkend="librdf-list">librdf_list</link> *list,
                                                         <link linkend="void">void</link> (fnvoid *, void *) (),
                                                         <link linkend="void">void</link> *user_data);</programlisting>
<para>
Apply a function for each data item in a librdf_list.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>list</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-list"><type>librdf_list</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>fn</parameter>&nbsp;:</term>
<listitem><simpara> pointer to function to apply that takes data pointer and user data parameters
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&nbsp;:</term>
<listitem><simpara> user data for applied function 
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
