#ifndef _MYLIST_HH__ #define _MYLIST_HH__ #include typedef enum { PLFALSE, PLTRUE } PLBOOL; typedef struct PtrList_tag PtrList; /* Creation and deletion */ PtrList * ListNew( void ); PtrList * ListNewWithPageSize( size_t pagesize ); PtrList * ListNewCopy( const PtrList * other ); void ListDeleteList( PtrList * ); /* Counts the items */ size_t ListNumberOfItems( const PtrList * ); /* Item accessors */ void * ListItemAt( const PtrList *, size_t idx ); void ListSetItemAt( PtrList *, size_t idx, void * ptr ); /* List manipulation */ void ListAppendItem( PtrList *, void * item ); void ListInsertItemAt( PtrList *, size_t idx, void * item ); void * ListRemoveItemAt( PtrList *, size_t idx ); void ListSwapItemsAt( PtrList *, size_t a_idx, size_t b_idx ); /* Actions on pointer of particular value */ void ListRemoveItem( PtrList *, void * item ); PLBOOL ListGetIndexOfItem( const PtrList *, const void * item, size_t * idx ); /* Remove all items from list */ void ListErase( PtrList * list ); /* Copy another list */ void ListCopyList( PtrList * list, const PtrList * other ); /* Special freeing utility */ void ListFreeItemsInListAndErase( PtrList * ); /* Sort and Search */ typedef int (*ListSortComparison)( const void *, const void * ); void ListSortListAccordingTo( PtrList *, ListSortComparison ); typedef PLBOOL (*ListCondition)( const void * ); void * ListFirstItemSuchThat( const PtrList *, ListCondition ); PLBOOL ListFindFirstIndexSuchThat( const PtrList *, ListCondition condition, size_t * idx ); #endif