Scroll to navigation

ici::doc::pod3::lyst(3) ICI library functions ici::doc::pod3::lyst(3)

NAME

lyst - library for manipulating generalized doubly linked lists

SYNOPSIS

    #include "lyst.h"
    typedef int  (*LystCompareFn)(void *s1, void *s2);
    typedef void (*LystCallback)(LystElt elt, void *userdata);
    [see description for available functions]

DESCRIPTION

The "lyst" library uses two types of objects, Lyst objects and LystElt objects. A Lyst knows how many elements it contains, its first and last elements, the memory manager used to create/destroy the Lyst and its elements, and how the elements are sorted. A LystElt knows its content (normally a pointer to an item in memory), what Lyst it belongs to, and the LystElts before and after it in that Lyst.

Create and return a new Lyst object without any elements in it. All operations performed on this Lyst will use the allocation/deallocation functions of the default memory manager "std" (see memmgr(3)). Returns NULL on any failure.
Create and return a new Lyst object without any elements in it. All operations performed on this Lyst will use the allocation/deallocation functions of the specified memory manager (see memmgr(3)). Returns NULL on any failure.
Clear a Lyst, i.e. free all elements of list, calling the Lyst's deletion function if defined, but without destroying the Lyst itself.
Destroy a Lyst. Will free all elements of list, calling the Lyst's deletion function if defined.
Set/get comparison function for specified Lyst. Comparison functions are called with two Lyst element data pointers, and must return a negative integer if first is less than second, 0 if both are equal, and a positive integer if first is greater than second (i.e., same return values as strcmp(3)). The comparison function is used by the lyst_insert(), lyst_search(), lyst_sort(), and lyst_sorted() functions.
Set sort direction (either LIST_SORT_ASCENDING or LIST_SORT_DESCENDING) for specified Lyst. If no comparison function is set, then this controls whether new elements are added to the end or beginning (respectively) of the Lyst when lyst_insert() is called.
Set user deletion function for specified Lyst. This function is automatically called whenever an element of the Lyst is deleted, to perform any user-required processing. When automatically called, the deletion function is passed two arguments: the element being deleted and the userdata pointer specified in the lyst_delete_set() call.
Set user insertion function for specified Lyst. This function is automatically called whenever a Lyst element is inserted into the Lyst, to perform any user-required processing. When automatically called, the insertion function is passed two arguments: the element being inserted and the userdata pointer specified in the lyst_insert_set() call.
Return the number of elements in the Lyst.
Create a new element whose content is the pointer value data and insert it into the Lyst. Uses the Lyst's comparison function to select insertion point, if defined; otherwise adds the new element at the beginning or end of the Lyst, depending on the Lyst sort direction setting. Returns a pointer to the newly created element, or NULL on any failure.
Create a new element and insert it at the beginning/end of the Lyst. If these functions are used when inserting elements into a Lyst with a defined comparison function, then the Lyst may get out of order and future calls to lyst_insert() can put new elements in unpredictable locations. Returns a pointer to the newly created element, or NULL on any failure.
Create a new element and insert it before/after the specified element. If these functions are used when inserting elements into a Lyst with a defined comparison function, then the Lyst may get out of order and future calls to lyst_insert can put new elements in unpredictable locations. Returns a pointer to the newly created element, or NULL on any failure.
Delete the specified element from its Lyst and deallocate its memory. Calls the user delete function if defined.
Return a pointer to the first/last element of a Lyst.
Return a pointer to the element following/preceding the specified element.
Find the first matching element in a Lyst starting with the specified element. Returns NULL if no matches are found. Uses the Lyst's comparison function if defined, otherwise searches from the given element to the end of the Lyst.
Return the Lyst to which the specified element belongs.
Get/set the pointer value content of the specified Lyst element. The set routine returns the element's previous content, and the delete function is not called. If the lyst_data_set() function is used on an element of a Lyst with a defined comparison function, then the Lyst may get out of order and future calls to lyst_insert() can put new elements in unpredictable locations.
Sort the Lyst based on the current comparison function and sort direction. A stable insertion sort is used that is very fast when the elements are already in order.
Determine whether or not the Lyst is sorted based on the current comparison function and sort direction.
Apply the function applyFn automatically to each element in the Lyst. When automatically called, applyFn is passed two arguments: a pointer to an element, and the userdata argument specified in the call to lyst_apply(). applyFn should not delete or reorder the elements in the Lyst.

SEE ALSO

memmgr(3), psm(3)

2016-07-07 perl v5.24.1