List

List — Simple list class.

Synopsis

typedef             librdf_list;
librdf_list *       librdf_new_list                     (librdf_world *world);
void                librdf_free_list                    (librdf_list *list);
void                librdf_list_clear                   (librdf_list *list);
int                 librdf_list_add                     (librdf_list *list,
                                                         void *data);
int                 librdf_list_unshift                 (librdf_list *list,
                                                         void *data);
void *              librdf_list_shift                   (librdf_list *list);
void *              librdf_list_pop                     (librdf_list *list);
void *              librdf_list_remove                  (librdf_list *list,
                                                         void *data);
int                 librdf_list_contains                (librdf_list *list,
                                                         void *data);
int                 librdf_list_size                    (librdf_list *list);
void                librdf_list_set_equals              (librdf_list *list,
                                                         int (*equals) (void* data1, void *data2));
librdf_iterator *   librdf_list_get_iterator            (librdf_list *list);
void                librdf_list_foreach                 (librdf_list *list,
                                                         void (*fn) (void *, void *),
                                                         void *user_data);

Description

A simple list class used internally.

Details

librdf_list

typedef struct librdf_list_s librdf_list;

Redland list class.


librdf_new_list ()

librdf_list *       librdf_new_list                     (librdf_world *world);

Constructor - create a new librdf_list.

world :

redland world object

Returns :

a new librdf_list or NULL on failure

librdf_free_list ()

void                librdf_free_list                    (librdf_list *list);

Destructor - destroy a librdf_list object.

list :

librdf_list object

librdf_list_clear ()

void                librdf_list_clear                   (librdf_list *list);

Empty an librdf_list.

list :

librdf_list object

librdf_list_add ()

int                 librdf_list_add                     (librdf_list *list,
                                                         void *data);

Add a data item to the end of a librdf_list.

Equivalent to the list 'push' notion, thus if librdf_list_pop() is called after this, it will return the value added here.

list :

librdf_list object

data :

the data value

Returns :

non 0 on failure

librdf_list_unshift ()

int                 librdf_list_unshift                 (librdf_list *list,
                                                         void *data);

Add a data item to the start of a librdf_list.

if librdf_list_shift() is called after this, it will return the value added here.

list :

librdf_list object

data :

the data value

Returns :

non 0 on failure

librdf_list_shift ()

void *              librdf_list_shift                   (librdf_list *list);

Remove and return the data at the start of the list.

list :

librdf_list object

Returns :

the data object or NULL if the list is empty

librdf_list_pop ()

void *              librdf_list_pop                     (librdf_list *list);

Remove and return the data at the end of the list.

list :

librdf_list object

Returns :

the data object or NULL if the list is empty

librdf_list_remove ()

void *              librdf_list_remove                  (librdf_list *list,
                                                         void *data);

Remove a data item from an librdf_list.

The search is done using the 'equals' function which may be set by librdf_list_set_equals() or by straight comparison of pointers if not set.

list :

librdf_list object

data :

the data item

Returns :

the data stored or NULL on failure (not found or list empty)

librdf_list_contains ()

int                 librdf_list_contains                (librdf_list *list,
                                                         void *data);

Check for presence of data item in list.

The search is done using the 'equals' function which may be set by librdf_list_set_equals() or by straight comparison of pointers if not set.

list :

librdf_list object

data :

the data value

Returns :

non 0 if item was found

librdf_list_size ()

int                 librdf_list_size                    (librdf_list *list);

Return the length of the list.

list :

librdf_list object

Returns :

length of the list

librdf_list_set_equals ()

void                librdf_list_set_equals              (librdf_list *list,
                                                         int (*equals) (void* data1, void *data2));

Set the equals function for the list.

The function given is used when comparing items in the list during searches such as those done in librdf_list_remove() or librdf_list_contains().

list :

librdf_list object

equals :

the equals function

librdf_list_get_iterator ()

librdf_iterator *   librdf_list_get_iterator            (librdf_list *list);

Get an iterator for the list.

list :

librdf_list object

Returns :

a new librdf_iterator object or NULL on failure

librdf_list_foreach ()

void                librdf_list_foreach                 (librdf_list *list,
                                                         void (*fn) (void *, void *),
                                                         void *user_data);

Apply a function for each data item in a librdf_list.

list :

librdf_list object

fn :

pointer to function to apply that takes data pointer and user data parameters

user_data :

user data for applied function