libxml2
Loading...
Searching...
No Matches
list.h File Reference

lists interfaces More...

Typedefs

typedef struct _xmlLink xmlLink
 Linked list item.
typedef struct _xmlList xmlList
 Linked list.
typedef void(* xmlListDeallocator) (xmlLink *lk)
 Callback function used to free data from a list.
typedef int(* xmlListDataCompare) (const void *data0, const void *data1)
 Callback function used to compare 2 data.
typedef int(* xmlListWalker) (const void *data, void *user)
 Callback function used when walking a list with xmlListWalk.

Functions

xmlListxmlListCreate (xmlListDeallocator deallocator, xmlListDataCompare compare)
 Create a new list.
void xmlListDelete (xmlList *l)
 Deletes the list and its associated data.
void * xmlListSearch (xmlList *l, void *data)
 Search the list for an existing value of data
void * xmlListReverseSearch (xmlList *l, void *data)
 Search the list in reverse order for an existing value of data
int xmlListInsert (xmlList *l, void *data)
 Insert data in the ordered list at the beginning for this value.
int xmlListAppend (xmlList *l, void *data)
 Insert data in the ordered list at the end for this value.
int xmlListRemoveFirst (xmlList *l, void *data)
 Remove the first instance associated to data in the list.
int xmlListRemoveLast (xmlList *l, void *data)
 Remove the last instance associated to data in the list.
int xmlListRemoveAll (xmlList *l, void *data)
 Remove the all instance associated to data in the list.
void xmlListClear (xmlList *l)
 Remove the all data in the list.
int xmlListEmpty (xmlList *l)
 Is the list empty ?
xmlLinkxmlListFront (xmlList *l)
 Get the first element in the list.
xmlLinkxmlListEnd (xmlList *l)
 Get the last element in the list.
int xmlListSize (xmlList *l)
 Get the number of elements in the list.
void xmlListPopFront (xmlList *l)
 Removes the first element in the list.
void xmlListPopBack (xmlList *l)
 Removes the last element in the list.
int xmlListPushFront (xmlList *l, void *data)
 add the new data at the beginning of the list
int xmlListPushBack (xmlList *l, void *data)
 add the new data at the end of the list
void xmlListReverse (xmlList *l)
 Reverse the order of the elements in the list.
void xmlListSort (xmlList *l)
 Sort all the elements in the list.
void xmlListWalk (xmlList *l, xmlListWalker walker, void *user)
 Walk all the element of the first from first to last and apply the walker function to it.
void xmlListReverseWalk (xmlList *l, xmlListWalker walker, void *user)
 Walk all the element of the list in reverse order and apply the walker function to it.
void xmlListMerge (xmlList *l1, xmlList *l2)
 include all the elements of the second list in the first one and clear the second list
xmlListxmlListDup (xmlList *old)
 Duplicate the list.
int xmlListCopy (xmlList *cur, xmlList *old)
 Move all the element from the old list in the new list.
void * xmlLinkGetData (xmlLink *lk)
 See Returns.

Detailed Description

lists interfaces

this module implement the list support used in various place in the library.

Author
Gary Pennington

Typedef Documentation

◆ xmlLink

typedef struct _xmlLink xmlLink

Linked list item.

Deprecated
Don't use in new code.

◆ xmlList

typedef struct _xmlList xmlList

Linked list.

Deprecated
Don't use in new code.

◆ xmlListDataCompare

typedef int(* xmlListDataCompare) (const void *data0, const void *data1)

Callback function used to compare 2 data.

Parameters
data0the first data
data1the second data
Returns
0 is equality, -1 or 1 otherwise depending on the ordering.

◆ xmlListDeallocator

typedef void(* xmlListDeallocator) (xmlLink *lk)

Callback function used to free data from a list.

Parameters
lkthe data to deallocate

◆ xmlListWalker

typedef int(* xmlListWalker) (const void *data, void *user)

Callback function used when walking a list with xmlListWalk.

Parameters
datathe data found in the list
userextra user provided data to the walker
Returns
0 to stop walking the list, 1 otherwise.

Function Documentation

◆ xmlLinkGetData()

void * xmlLinkGetData ( xmlLink * lk)

See Returns.

Parameters
lka link
Returns
a pointer to the data referenced from this link

◆ xmlListAppend()

int xmlListAppend ( xmlList * l,
void * data )

Insert data in the ordered list at the end for this value.

Parameters
la list
datathe data
Returns
0 in case of success, 1 in case of failure

◆ xmlListClear()

void xmlListClear ( xmlList * l)

Remove the all data in the list.

Parameters
la list

◆ xmlListCopy()

int xmlListCopy ( xmlList * cur,
xmlList * old )

Move all the element from the old list in the new list.

Parameters
curthe new list
oldthe old list
Returns
0 in case of success 1 in case of error

◆ xmlListCreate()

xmlList * xmlListCreate ( xmlListDeallocator deallocator,
xmlListDataCompare compare )

Create a new list.

Parameters
deallocatoran optional deallocator function
comparean optional comparison function
Returns
the new list or NULL in case of error

◆ xmlListDelete()

void xmlListDelete ( xmlList * l)

Deletes the list and its associated data.

Parameters
la list

◆ xmlListDup()

xmlList * xmlListDup ( xmlList * old)

Duplicate the list.

Parameters
oldthe list
Returns
a new copy of the list or NULL in case of error

◆ xmlListEmpty()

int xmlListEmpty ( xmlList * l)

Is the list empty ?

Parameters
la list
Returns
1 if the list is empty, 0 if not empty and -1 in case of error

◆ xmlListEnd()

xmlLink * xmlListEnd ( xmlList * l)

Get the last element in the list.

Parameters
la list
Returns
the last element in the list, or NULL

◆ xmlListFront()

xmlLink * xmlListFront ( xmlList * l)

Get the first element in the list.

Parameters
la list
Returns
the first element in the list, or NULL

◆ xmlListInsert()

int xmlListInsert ( xmlList * l,
void * data )

Insert data in the ordered list at the beginning for this value.

Parameters
la list
datathe data
Returns
0 in case of success, 1 in case of failure

◆ xmlListMerge()

void xmlListMerge ( xmlList * l1,
xmlList * l2 )

include all the elements of the second list in the first one and clear the second list

Parameters
l1the original list
l2the new list

◆ xmlListPopBack()

void xmlListPopBack ( xmlList * l)

Removes the last element in the list.

Parameters
la list

◆ xmlListPopFront()

void xmlListPopFront ( xmlList * l)

Removes the first element in the list.

Parameters
la list

◆ xmlListPushBack()

int xmlListPushBack ( xmlList * l,
void * data )

add the new data at the end of the list

Parameters
la list
datanew data
Returns
1 if successful, 0 otherwise

◆ xmlListPushFront()

int xmlListPushFront ( xmlList * l,
void * data )

add the new data at the beginning of the list

Parameters
la list
datanew data
Returns
1 if successful, 0 otherwise

◆ xmlListRemoveAll()

int xmlListRemoveAll ( xmlList * l,
void * data )

Remove the all instance associated to data in the list.

Parameters
la list
datalist data
Returns
the number of deallocation, or 0 if not found

◆ xmlListRemoveFirst()

int xmlListRemoveFirst ( xmlList * l,
void * data )

Remove the first instance associated to data in the list.

Parameters
la list
datalist data
Returns
1 if a deallocation occurred, or 0 if not found

◆ xmlListRemoveLast()

int xmlListRemoveLast ( xmlList * l,
void * data )

Remove the last instance associated to data in the list.

Parameters
la list
datalist data
Returns
1 if a deallocation occurred, or 0 if not found

◆ xmlListReverse()

void xmlListReverse ( xmlList * l)

Reverse the order of the elements in the list.

Parameters
la list

◆ xmlListReverseSearch()

void * xmlListReverseSearch ( xmlList * l,
void * data )

Search the list in reverse order for an existing value of data

Parameters
la list
dataa search value
Returns
the value associated to data or NULL in case of error

◆ xmlListReverseWalk()

void xmlListReverseWalk ( xmlList * l,
xmlListWalker walker,
void * user )

Walk all the element of the list in reverse order and apply the walker function to it.

Parameters
la list
walkera processing function
usera user parameter passed to the walker function

◆ xmlListSearch()

void * xmlListSearch ( xmlList * l,
void * data )

Search the list for an existing value of data

Parameters
la list
dataa search value
Returns
the value associated to data or NULL in case of error

◆ xmlListSize()

int xmlListSize ( xmlList * l)

Get the number of elements in the list.

Parameters
la list
Returns
the number of elements in the list or -1 in case of error

◆ xmlListSort()

void xmlListSort ( xmlList * l)

Sort all the elements in the list.

Parameters
la list

◆ xmlListWalk()

void xmlListWalk ( xmlList * l,
xmlListWalker walker,
void * user )

Walk all the element of the first from first to last and apply the walker function to it.

Parameters
la list
walkera processing function
usera user parameter passed to the walker function