/*------------------------------------------------------------------*/ /* list.h */ /*------------------------------------------------------------------*/ #ifndef LIST_INCLUDED #define LIST_INCLUDED typedef struct List *List_T; typedef struct ListIter *ListIter_T; typedef struct ListIterR *ListIterR_T; extern List_T List_new(); /* Return a new List_T. */ extern void List_free(List_T oList); /* Free oList. */ extern unsigned long List_length(List_T oList); /* Return the number of items in oList. */ extern void *List_getFirst(List_T oList); /* Return the first item in oList. Checked runtime error: oList is empty. */ extern void *List_getLast(List_T oList); /* Return the last item in oList. Checked runtime error: oList is empty. */ extern void List_addFirst(List_T oList, void *pvItem); /* Add pvItem to the beginning of oList. */ extern void List_addLast(List_T oList, void *pvItem); /* Add pvItem to the end of oList. */ extern void List_removeFirst(List_T oList); /* Remove the first item of oList. Checked runtime error: oList is empty. */ extern void List_removeLast(List_T oList); /* Remove the last item of oList. Checked runtime error: oList is empty. */ extern void List_map(List_T oList, void (*pfApply)(void **ppvItem, void *pvExtra), void *pvExtra); /* Call (*pfApply)(&pvItem, pvExtra) for each item pvItem of oList. Checked runtime error: pfApply is null. */ extern void List_toArray(List_T oList, void **ppvArray); /* Fill array ppvArray with all items of oList. ppvArray must be large enough to hold all items. Checked runtime error: ppvArray is NULL. */ extern ListIter_T ListIter_new(List_T oList); /* Return a new ListIter_T that can iterate over oList from front to back. */ extern void ListIter_free(ListIter_T oListIter); /* Free oListIter. */ extern int ListIter_hasNext(ListIter_T oListIter); /* Return 1 (TRUE) iff the List_T over which oListIter is iterating has a next item. */ extern void *ListIter_next(ListIter_T oListIter); /* Return the next item of the List_T over which oListIter is iterating. */ extern ListIterR_T ListIterR_new(List_T oList); /* Return a new ListIterR_T that can iterate over oList from back to front. */ extern void ListIterR_free(ListIterR_T oListIterR); /* Free oListIterR. */ extern int ListIterR_hasPrevious(ListIterR_T oListIterR); /* Return 1 (TRUE) iff the List_T over which oListIterR is iterating has a previous item. */ extern void *ListIterR_previous(ListIterR_T oListIterR); /* Return the previous item of the List_T over which oListIterR is iterating. */ /* Checked runtime errors: oList is NULL. oListIter is NULL. oListIterR is NULL. */ #endif