Woolz Image Processing  Version 1.8.3
AlcDLPList

Files

file  AlcDLPList.c
 A general purpose doubly linked circular list of pointers.
 

Data Structures

struct  _AlcDLPItem
 A doubly linked list item. Typedef: AlcDLPItem. More...
 
struct  _AlcDLPList
 A doubly linked list of pointers. Typedef: AlcDLPList. More...
 

Functions

AlcDLPListAlcDLPListNew (AlcErrno *dstErr)
 Creates a list data structure which is required by all the other AlcDLPList functions. More...
 
AlcDLPItemAlcDLPItemNew (void *entry, void(*freeFn)(void *), AlcErrno *dstErr)
 Creates a list item data structure for building into a AlcDLPList list. More...
 
AlcErrno AlcDLPListFree (AlcDLPList *list)
 Free's the given list data structure and any list items. More...
 
AlcErrno AlcDLPListEntryInsert (AlcDLPList *list, AlcDLPItem *insBefore, void *entry, void(*freeFn)(void *))
 Inserts the given entry into the list before the given item. More...
 
AlcErrno AlcDLPListEntryAppend (AlcDLPList *list, AlcDLPItem *appAfter, void *entry, void(*freeFn)(void *))
 Appends the given entry into the list after the given item. More...
 
AlcDLPItemAlcDLPItemUnlink (AlcDLPList *list, AlcDLPItem *item, int freeItem, AlcErrno *dstErr)
 Removes the item from the list, but does not free the item unless the freeItem flag is set. More...
 
AlcErrno AlcDLPItemInsert (AlcDLPList *list, AlcDLPItem *insBefore, AlcDLPItem *newItem)
 Inserts a new item into the list before the given item. More...
 
AlcErrno AlcDLPItemAppend (AlcDLPList *list, AlcDLPItem *appAfter, AlcDLPItem *newItem)
 Appends a new item into the list after the given item. More...
 
AlcErrno AlcDLPItemFree (AlcDLPItem *item)
 Free's the list item which has already been removed from the list. More...
 
AlcErrno AlcDLPListSort (AlcDLPList *list, int(*entryCompFn)(void *, void *))
 Sorts the entire list using the given entry comparison function. More...
 
int AlcDLPListCount (AlcDLPList *list, AlcErrno *dstErr)
 Returns the number of items in the list. More...
 
AlcDLPItemAlcDLPListIterate (AlcDLPList *list, AlcDLPItem *item, AlcDirection dir, int(*iterFn)(AlcDLPList *, AlcDLPItem *, void *), void *iterData, AlcErrno *dstErr)
 Iterates the given function through the list, starting with the given item. The iteration may proceed towards either the head or tail of the list. The iterated function must take the form. More...
 

Detailed Description

Function Documentation

◆ AlcDLPListNew()

AlcDLPList* AlcDLPListNew ( AlcErrno dstErr)

Creates a list data structure which is required by all the other AlcDLPList functions.

Returns
List data structure, or NULL on error.
Parameters
dstErrDestination pointer for error code, may be NULL.

References ALC_ER_ALLOC, ALC_ER_NONE, and AlcCalloc().

Referenced by WlzMakePropertyList().

◆ AlcDLPItemNew()

AlcDLPItem* AlcDLPItemNew ( void *  entry,
void(*)(void *)  freeFn,
AlcErrno dstErr 
)

Creates a list item data structure for building into a AlcDLPList list.

Returns
List item structure, or NULL on error.
Parameters
entryNew list entry.
freeFnFunction that will be called (if not NULL) to free the entry.
dstErrDestination pointer for error code, may be NULL.

References ALC_ER_ALLOC, ALC_ER_NONE, AlcCalloc(), _AlcDLPItem::entry, and _AlcDLPItem::freeFn.

Referenced by AlcDLPListEntryAppend(), and AlcDLPListEntryInsert().

◆ AlcDLPListFree()

AlcErrno AlcDLPListFree ( AlcDLPList list)

Free's the given list data structure and any list items.

Returns
Error code.
Parameters
listThe list data structure.

References ALC_ER_NONE, ALC_ER_NULLPTR, AlcFree(), _AlcDLPItem::entry, _AlcDLPItem::freeFn, _AlcDLPList::head, and _AlcDLPItem::next.

Referenced by WlzFreePropertyList().

◆ AlcDLPListEntryInsert()

AlcErrno AlcDLPListEntryInsert ( AlcDLPList list,
AlcDLPItem insBefore,
void *  entry,
void(*)(void *)  freeFn 
)

Inserts the given entry into the list before the given item.

Parameters
listThe list data structure.
insBeforeGiven item that entry is to be inserted before, if NULL then the item is inserted at the head of the list.
entryNew list entry.
freeFnFunction that will be called (if not NULL) to free the entry should the item be deleted.

References ALC_ER_NONE, ALC_ER_NULLPTR, AlcDLPItemNew(), _AlcDLPList::head, _AlcDLPItem::next, and _AlcDLPItem::prev.

◆ AlcDLPListEntryAppend()

AlcErrno AlcDLPListEntryAppend ( AlcDLPList list,
AlcDLPItem appAfter,
void *  entry,
void(*)(void *)  freeFn 
)

Appends the given entry into the list after the given item.

Returns
Error code.
Parameters
listThe list data structure.
appAfterGiven item that entry is to be inserted after, if NULL then the item is appended at the tail of the list.
entryNew list entry.
freeFnFunction that will be called (if not NULL) to free the entry should the item be deleted.

References ALC_ER_NONE, ALC_ER_NULLPTR, AlcDLPItemNew(), _AlcDLPList::head, _AlcDLPItem::next, and _AlcDLPItem::prev.

◆ AlcDLPItemUnlink()

AlcDLPItem* AlcDLPItemUnlink ( AlcDLPList list,
AlcDLPItem item,
int  freeItem,
AlcErrno dstErr 
)

Removes the item from the list, but does not free the item unless the freeItem flag is set.

Returns
Next list item after the item removed, NULL on error or if last item removed.
Parameters
listThe list data structure.
itemItem to be removed.
freeItemFree item if non-zero.
dstErrDestination pointer for error code, may be NULL.

References ALC_ER_NONE, ALC_ER_NULLPTR, AlcDLPItemFree(), _AlcDLPList::head, _AlcDLPItem::next, and _AlcDLPItem::prev.

Referenced by WlzRemoveProperty().

◆ AlcDLPItemInsert()

AlcErrno AlcDLPItemInsert ( AlcDLPList list,
AlcDLPItem insBefore,
AlcDLPItem newItem 
)

Inserts a new item into the list before the given item.

Returns
Error code.
Parameters
listThe list data structure.
insBeforeGiven item that entry is to be inserted before, if NULL then the item is inserted at the head of the list.
newItemNew item to insert.

References ALC_ER_NONE, ALC_ER_NULLPTR, _AlcDLPList::head, _AlcDLPItem::next, and _AlcDLPItem::prev.

◆ AlcDLPItemAppend()

AlcErrno AlcDLPItemAppend ( AlcDLPList list,
AlcDLPItem appAfter,
AlcDLPItem newItem 
)

Appends a new item into the list after the given item.

Returns
Error code.
Parameters
listThe list data structure.
appAfterGiven item that entry is to be inserted after, if NULL then the item is appended at the tail of the list.
newItemNew item to insert.

References ALC_ER_NONE, ALC_ER_NULLPTR, _AlcDLPList::head, _AlcDLPItem::next, and _AlcDLPItem::prev.

◆ AlcDLPItemFree()

AlcErrno AlcDLPItemFree ( AlcDLPItem item)

Free's the list item which has already been removed from the list.

Returns
Error code.
Parameters
itemItem to be deleted.

References ALC_ER_NONE, ALC_ER_NULLPTR, AlcFree(), _AlcDLPItem::entry, and _AlcDLPItem::freeFn.

Referenced by AlcDLPItemUnlink().

◆ AlcDLPListSort()

AlcErrno AlcDLPListSort ( AlcDLPList list,
int(*)(void *, void *)  entryCompFn 
)

Sorts the entire list using the given entry comparison function.

Returns
Error code.
Parameters
listThe list data structure.
entryCompFnGiven entry comparison function which must return an integer less than, equal to, or greater than zero to indicate if the first entry is to be considered less than, equal to, or greater than the second.

References ALC_ER_NONE, ALC_ER_NULLPTR, AlcDLPListCount(), and _AlcDLPList::head.

◆ AlcDLPListCount()

int AlcDLPListCount ( AlcDLPList list,
AlcErrno dstErr 
)

Returns the number of items in the list.

Returns
Number of items in list. This is always >= 0.
Parameters
listThe list data structure.
dstErrDestination pointer for error code, may be NULL.

References ALC_ER_NONE, ALC_ER_NULLPTR, _AlcDLPList::head, and _AlcDLPItem::next.

Referenced by AlcDLPListSort().

◆ AlcDLPListIterate()

AlcDLPItem* AlcDLPListIterate ( AlcDLPList list,
AlcDLPItem item,
AlcDirection  dir,
int(*)(AlcDLPList *, AlcDLPItem *, void *)  iterFn,
void *  iterData,
AlcErrno dstErr 
)

Iterates the given function through the list, starting with the given item. The iteration may proceed towards either the head or tail of the list. The iterated function must take the form.

Returns
Last item.
*                 int MyItemCount(AlcDLPList *list,
*                                AlcDLPItem *item,
*                                void *myData)
*                 {
*                   int         *count;
*
*                   if(list && item)
*                   {
*                     count = (int *)myData;
*                     ++*count;
*                   }
*                   return(list->head != item->next);
*                 }
* 

Where the data parameter is the data supplied to this (AlcDLPListIterate) function. The iteration continues until the itterated function returns zero.

Parameters
listThe list data structure.
itemFirst item of iteration which may be NULL to indicate list head (dir == _TO_TAIL) or tail (dir == _TO_HEAD).
dirIteration direction, either towards the head or the tail.
iterFnFunction to be iterated, see example above.
iterDataData supplied to the iterated function.
dstErrDestination pointer for error code, may be NULL.

References ALC_DIRECTION_FWD, ALC_DIRECTION_REV, ALC_ER_NONE, ALC_ER_NULLPTR, ALC_ER_PARAM, _AlcDLPList::head, _AlcDLPItem::next, and _AlcDLPItem::prev.