Sack Library Documentation
|
#define LIST_FORALL( l, i, t, v ) if(((v)=(t)NULL),(l)) \ for( ((i)=0); ((i) < ((l)->Cnt))? \ (((v)=(t)(PTRSZVAL)(l)->pNode[i]),1):(((v)=(t)NULL),0); (i)++ ) if( v )
This is a iterator which can be used to check each member in a PLIST.
This initializes the parameters passed to the macro so that if the list is NULL or empty, then p will be set to NULL. If there are no non-nulll members in the list, p will be set to NULL. If you break in the loop, like in the case of searching the list for something, then p will be non-null at the end of the loop.
POINTER p; // the pointer to receive the list member pointer (should be a user type) INDEX idx; // indexer PLIST pList; // some list. LIST_FORALL( pList, idx, POINTER, p ) { // p will never be NULL here. // each link stored in the list is set to p here.. // this is a way to remove this item from the list... SetLink( &pList, idx, NULL ); if( some condition ) break; }
Another example that uses data and searches..
Copyright (c) 2000+. All rights reserved.
|
What do you think about this topic? Send feedback!
|