Skip to main content

Module list

Module list 

Source
Expand description

Linked list — public xmlList API (§85 Phase 1).

Implements libxml2’s linked list.

§UPSTREAM-PARITY

The linked list supports:

  • Create/delete with custom deallocator
  • Push front/back, pop front/back
  • Insert/append at arbitrary positions
  • Search with custom comparator
  • Walk with callback
  • Remove first/last/all matching entries
  • Clear
  • Empty/front/back/size queries
  • Sort, reverse, reverse splice, merge

§Phase 1 status

Complete — all list operations are implemented.

Structs§

List
The linked list struct.

Functions§

link_get_data
Return the data stored in a link (upstream list.c xmlLinkGetData).
list_append
Append data to the end of the list (alias for push_back).
list_back
Get the data at the back of the list.
list_clear
Clear the list (remove all elements).
list_copy
Copy a list with a data copier (upstream list.c xmlListCopy): each node’s data is copied through copier (returns a fresh pointer or NULL on failure). The result replaces the target list l’s content. Returns 0 on success, -1 on error.
list_create
Create a new linked list.
list_delete
Delete a linked list and all its nodes.
list_dup
Duplicate a list (upstream list.c xmlListDup): a shallow copy using the same deallocator/comparator; node data pointers are copied as-is. Returns the new list or NULL on allocation failure.
list_empty
Check if the list is empty.
list_end
Return the last element of a list (upstream list.c xmlListEnd): the data of the last node, or NULL.
list_front
Get the data at the front of the list.
list_insert
Insert data into the sorted position.
list_merge
Merge two sorted lists into one.
list_pop_back
Pop data from the back of the list.
list_pop_front
Pop data from the front of the list.
list_push_back
Push data to the back of the list.
list_push_front
Push data to the front of the list.
list_remove_all
Remove all matching elements.
list_remove_first
Remove the first matching element.
list_remove_last
Remove the last matching element.
list_reverse
Reverse the list in-place.
list_reverse_search
Reverse-search a list with the comparator (upstream list.c xmlListReverseSearch): scans from the back, returns the first (from the end) matching node’s data, or NULL.
list_reverse_splice
Reverse splice: move all elements from l2 to the front of l1 in reverse order.
list_reverse_walk
Walk a list in reverse with a walker callback (upstream list.c xmlListReverseWalk).
list_search
Search the list for data matching the given key.
list_size
Get the number of elements in the list.
list_sort
Sort the list in-place using the comparator.
list_walk
Walk the list, calling the walker function for each element.

Type Aliases§

xmlListDataCompare
Data comparator function. Returns 0 if equal, non-zero if different.
xmlListDeallocator
Deallocator function for list data.
xmlListWalker
Walker function for xmlListWalk.