ici::doc::pod3::lyst(3)
π NAME π
lyst β the library for manipulating generalized doubly linked lists, bestie. that's it. that's the whole vibe. β¨
πΈ SYNOPSIS πΈ
#include "lyst.h"
typedef int (*LystCompareFn)(void *s1, void *s2);
typedef void (*LystCallback)(LystElt elt, void *userdata);
[see description for available functions]
π¦ DESCRIPTION π¦
okay so the lyst library runs on two types of objects and honestly they're giving main character energy in different ways: Lyst objects and LystElt objects.
A Lyst literally knows everything about itself: 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. self-aware queen. π
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. it knows its neighbors. it knows its place in the world. we love a grounded icon. π«Ά
β¨ the functions, in order, no skips β¨
Lyst lyst_create(void)β 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"(seememmgr(3)). ReturnsNULLon any failure.Lyst lyst_create_using(unsigned memmgrId)β 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 (seememmgr(3)). ReturnsNULLon any failure.void lyst_clear(Lyst list)β Clear a Lyst, i.e. free all elements of list, calling the Lyst's deletion function if defined, but without destroying the Lyst itself. it clears the room but the building stays standing. πvoid lyst_destroy(Lyst list)β Destroy a Lyst. Will free all elements of list, calling the Lyst's deletion function if defined. this one takes the whole thing out. πvoid lyst_compare_set(Lyst list, LystCompareFn compareFn)LystCompareFn lyst_compare_get(Lyst list)β 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,0if both are equal, and a positive integer if first is greater than second (i.e., same return values asstrcmp(3)). The comparison function is used by thelyst_insert(),lyst_search(),lyst_sort(), andlyst_sorted()functions.void lyst_direction_set(Lyst list, LystSortDirection direction)β Set sort direction (eitherLIST_SORT_ASCENDINGorLIST_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 whenlyst_insert()is called. yes bestie, the direction literally flips where things land. π₯void lyst_delete_set(Lyst list, LystCallback deleteFn, void *userdata)β 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 thelyst_delete_set()call.void lyst_insert_set(Lyst list, LystCallback insertFn, void *userdata)β 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 thelyst_insert_set()call.unsigned long lyst_length(Lyst list)β Return the number of elements in the Lyst. headcount, bestie. πLystElt lyst_insert(Lyst list, void *data)β 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, orNULLon any failure.LystElt lyst_insert_first(Lyst list, void *data)LystElt lyst_insert_last(Lyst list, void *data)β 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 tolyst_insert()can put new elements in unpredictable locations. Returns a pointer to the newly created element, orNULLon any failure.
β οΈ bestie, read that again: defined comparison function + these two = the Lyst may get out of order, and later lyst_insert() calls can drop new elements in unpredictable locations. chaos. not the cute kind. π
LystElt lyst_insert_before(LystElt element, void *data)LystElt lyst_insert_after(LystElt element, void *data)β 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 tolyst_insertcan put new elements in unpredictable locations. Returns a pointer to the newly created element, orNULLon any failure.
β οΈ same warning, same energy: comparison function defined + insert before/after = potential out-of-order Lyst and unpredictable lyst_insert placement. fr fr. π
void lyst_delete(LystElt element)β Delete the specified element from its Lyst and deallocate its memory. Calls the user delete function if defined.LystElt lyst_first(Lyst list)LystElt lyst_last(Lyst list)β Return a pointer to the first/last element of a Lyst.LystElt lyst_next(LystElt element)LystElt lyst_prev(LystElt element)β Return a pointer to the element following/preceding the specified element.LystElt lyst_search(LystElt element, void *searchValue)β Find the first matching element in a Lyst starting with the specified element. ReturnsNULLif no matches are found. Uses the Lyst's comparison function if defined, otherwise searches from the given element to the end of the Lyst.Lyst lyst_lyst(LystElt element)β Return the Lyst to which the specified element belongs. found family check. π₯Ήvoid* lyst_data(LystElt element)void* lyst_data_set(LystElt element, void *data)β 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 thelyst_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 tolyst_insert()can put new elements in unpredictable locations.
β οΈ yeah, it's the warning again, third time's the charm:lyst_data_set()on a sorted Lyst = out of order, unpredictablelyst_insert()behavior. no cap. π
void lyst_sort(Lyst list)β 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. lowkey the glow-up function. βint lyst_sorted(Lyst list)β Determine whether or not the Lyst is sorted based on the current comparison function and sort direction.void lyst_apply(Lyst list, LystCallback applyFn, void *userdata)β 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 tolyst_apply(). applyFn should not delete or reorder the elements in the Lyst.
π« do NOT delete or reorder elements inside applyFn. just vibe. look, don't touch. π
π SEE ALSO π
and that's the whole page, bestie!! π this was ici::doc::pod3::lyst(3) from the ICI library functions manual, and the page itself is stamped perl v5.24.1 and dated 2016-07-07 β iconic vintage behavior, we respect the elders. now go sort something. slay. β¨ππ¦
π¦ where this page comes from
- ubuntu jammy: ion-doc 3.2.1+dfsg-1.1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms