OpenClovis Logo

API Usage Examples
Circular List Management

Code Examples. More...

Code Examples.

Code Examples with comments:

// Circular list should be created to use Clist.
// Circular linklist of 256 nodes
ClUint32T maxSize = 256;
rc = clClistCreate(maxSize, dropPolicy, userDeleteCb,
userDestroyCb, &listHead);
if( CL_OK != rc )
{
// Error returned, take appropriate action
}
// Add a node to the start of the list.
ClClistDataT listData = YYYY; /* user data */
rc = clClistFirstNodeAdd(listHead, listData)
if( CL_OK != rc )
{
//Error returned, take appropriate action
}
// Add a node to the end of the list.
ClClistDataT listData = YYYY; /* user data */
rc = clClistLastNodeAdd(listData, listData)
if( CL_OK != rc )
{
// Error returned, take appropriate action
}
// Add a node to after the particular node
ClClistDataT listData = YYYY; /* user data */
ClClistNodeT currentNode = NODE; /* any specific node */
rc = clClistAfterNodeAdd(listData, currentNode, listData)
if( CL_OK != rc )
{
// Error returned, take appropriate action
}
// Add a node to before the particular node
ClClistDataT listData = YYYY; /* user data */
ClClistNodeT currentNode = NODE; /* any specific node */
rc = clClistBeforeNodeAdd(listData, currentNode, listData)
if( CL_OK != rc )
{
// Error returned, take appropriate action
}
// Get the first node of the Clist
rc = clClistFirstNodeGet(listData, &firstNode)
if( CL_OK != rc )
{
// Error returned, take appropriate action
}
// Get the last node of the list
rc = clClistLastNodeGet(listData, &lastNode);
if( CL_OK != rc )
{
// Error returned, take appropriate action
}
// Get the next node of the current node
ClClistNodeT currentNode = NODE; // current node
rc = clClistNextNodeGet(listData, currentNode, &nextNode)
if( CL_OK != rc )
{
// Error returned, take appropriate action
}
// Get the previous node of the current node
rc = clClistPreviousNodeGet(listData, currentNode, &prevNode)
if( CL_OK != rc )
{
// Error returned, take appropriate action
}
// Walk through the list.
rc = clClistWalk(listData, listWalkCb, userArg);
if( CL_OK != rc )
{
// Error returned, take appropriate action
}
// size of the circular list
rc = clClistSizeGet(listData, &size);
if( CL_OK != rc )
{
//Error returned, take appropraite action
}
// Delete the circular list.
rc = clClistDelete(&listData);
if( CL_OK != rc )
{
// Error returned, take appropriate action
}

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen