From: Martin H. <mh...@us...> - 2005-04-12 07:53:02
|
Update of /cvsroot/opengtoolkit/serial/c_source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7141/c_source Modified Files: plist.cpp plist.h Log Message: Implemented ListGetNextHandle() and ListGetNextElement(), so we can retrieve all elements/handles of the list. Index: plist.cpp =================================================================== RCS file: /cvsroot/opengtoolkit/serial/c_source/plist.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** plist.cpp 20 Jan 2005 16:49:45 -0000 1.1 --- plist.cpp 12 Apr 2005 07:52:53 -0000 1.2 *************** *** 643,646 **** --- 643,682 ---- } + /* ListGetNextElement + * + * Returns the next element of the list + * + * parameter + * pList list pointer + * pElement element pointer + * + * return + * the next elements data pointer + * + */ + void * ListGetNextElement(PLIST pList, void *pElement) + { + PLINK pLink; + unsigned long i; + + if (pList == NULL) + return NULL; + + for ( + i = 0, pLink=GetHeadOfList(pList); + i < GetListLength(pList) && pLink->pElement != pElement; + i++) + { + pLink = GetNextLink(pLink); + } + + if (i >= GetListLength(pList)) + return NULL; + + pLink = GetNextLink(pLink); + + return pLink->pElement; + } + /* ListGetFirstHandle * *************** *** 661,664 **** --- 697,736 ---- } + /* ListGetNextHandle + * + * Returns the next handle of the list + * + * parameter + * pList list pointer + * hElement element handle + * + * return + * the next elements handle + * + */ + void * ListGetNextHandle(PLIST pList, void *hElement) + { + PLINK pLink; + unsigned long i; + + if (pList == NULL) + return NULL; + + for ( + i = 0, pLink=GetHeadOfList(pList); + i < GetListLength(pList) && pLink != hElement; + i++) + { + pLink = GetNextLink(pLink); + } + + if (i >= GetListLength(pList)) + return NULL; + + pLink = GetNextLink(pLink); + + return pLink; + } + /* ListFindElement * Index: plist.h =================================================================== RCS file: /cvsroot/opengtoolkit/serial/c_source/plist.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** plist.h 18 Mar 2005 23:23:06 -0000 1.2 --- plist.h 12 Apr 2005 07:52:53 -0000 1.3 *************** *** 60,64 **** --- 60,66 ---- void * ListGetElement(PLIST pList, void *hElement); void * ListGetFirstElement(PLIST pList); + void * ListGetNextElement(PLIST pList, void *pElement); void * ListGetFirstHandle(PLIST pList); + void * ListGetNextHandle(PLIST pList, void *hElement); //information and check |