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

xmlList * | xmlListCreate (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 ?
xmlLink * | xmlListFront (xmlList *l)
| Get the first element in the list.
xmlLink * | xmlListEnd (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
xmlList * | xmlListDup (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.

Copyright
  See Copyright for the status of this software.

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

  data0 | the first data
  data1 | the 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

  lk | the data to deallocate

## xmlListWalker

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

Callback function used when walking a list with xmlListWalk.

Parameters

  data | the data found in the list
  user | extra 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

  lk | a 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

  l | a list
  data | the 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

  l | a list

## xmlListCopy()

int xmlListCopy | ( | xmlList * | cur,
|  | xmlList * | old )

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

Parameters

  cur | the new list
  old | the 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

  deallocator | an optional deallocator function
  compare | an 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

  l | a list

## xmlListDup()

xmlList * xmlListDup | ( | xmlList * | old | ) |

Duplicate the list.

Parameters

  old | the list

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

## xmlListEmpty()

int xmlListEmpty | ( | xmlList * | l | ) |

Is the list empty ?

Parameters

  l | a 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

  l | a list

Returns
  the last element in the list, or NULL

## xmlListFront()

xmlLink * xmlListFront | ( | xmlList * | l | ) |

Get the first element in the list.

Parameters

  l | a 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

  l | a list
  data | the 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

  l1 | the original list
  l2 | the new list

## xmlListPopBack()

void xmlListPopBack | ( | xmlList * | l | ) |

Removes the last element in the list.

Parameters

  l | a list

## xmlListPopFront()

void xmlListPopFront | ( | xmlList * | l | ) |

Removes the first element in the list.

Parameters

  l | a list

## xmlListPushBack()

int xmlListPushBack | ( | xmlList * | l,
|  | void * | data )

add the new data at the end of the list

Parameters

  l | a list
  data | new 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

  l | a list
  data | new 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

  l | a list
  data | list 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

  l | a list
  data | list 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

  l | a list
  data | list 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

  l | a list

## xmlListReverseSearch()

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

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

Parameters

  l | a list
  data | a 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

  l | a list
  walker | a processing function
  user | a user parameter passed to the walker function

## xmlListSearch()

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

Search the list for an existing value of data.

Parameters

  l | a list
  data | a 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

  l | a 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

  l | a 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

  l | a list
  walker | a processing function
  user | a user parameter passed to the walker function