wn_slleunlink3
Singly linked list manager
Part of wnsll(3).
Usage
wn_sll el;
wn_sll ll;
wn_sll ll;
wn_sll ll;
wn_sll list;
ptr e;
wn_sll list;
ptr e;
wn_sll *pel;
wn_sll *pel;
ptr contents;
wn_sll list;
int index;
int index;
int index;
wn_sll list;
ptr e;
wn_sll list;
wn_sll *pend,
list;
bool wn_sllempty(list)
wn_sll list;
int wn_sllcount(list)
wn_sll list;
Overview
This package defines a singly linked list type called "wn_sll". Routines and macros operate on lists and elements of lists.
The declaration
wn_sll ll;
declares a list element, which is also a list. The fragment
ll->next
refers to the next linked list element. The fragment
ll->contents
is a pointer associated with the linked list element.
wn_mksll allocates a wn_sll from the current memory group. ll->next and ll->contents are NULL.
wn_sllins inserts e into list list by allocating a list element (from the current memory group), setting its contents to e, and chaining it to the front of list.
wn_slleins chains el to the front of list.
wn_slldel searches list until it finds a list element with contents == e. This element is deleted from the list and freed into the current memory group.
wn_slledel deletes the list element *pel from its containing list by setting "*pel = (*pel)->next;". Then the list element is freed into the current memory group.
wn_slleunlink deletes the list element *pel from its containing list by setting "*pel = (*pel)->next;".
wn_sllindex places the contents of the \fIindex\fPth element of list into contents. Unreasonable values of index are NOT trapped.
wn_slleindex places the \fIindex\fPth element of list into el. Unreasonable values of index are NOT trapped.
wn_sllrev reverses the order of list. Useful because wn_sllins leaves the list reversed from the order of insertion.
wn_sllcpy places a memory-allocated copy of in into out. The memory is allocated from the current memory group.
wn_sllcat concatonates in to the end of out, preserving the order of both. No new memory is allocated.
wn_sllins_sll chains the list in to the front of out.
wn_sllend places the last->next pointer of list into pend.
wn_slllast gets the last element of list.
wn_sllempty returns TRUE iff list is empty.
wn_sllcount returns the number of entries in list.