OpenClovis Logo

API Usage Examples

Code Examples.

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
}
ClPtrT ClClistNodeT
The type of the handle for the circular node.
Definition: clClistApi.h:88
ClRcT clClistPreviousNodeGet(CL_IN ClClistT listHead, CL_IN ClClistNodeT currentNode, CL_OUT ClClistNodeT *pPreviousNode)
Returns next node from the list.
ClRcT clClistLastNodeGet(CL_IN ClClistT listHead, CL_OUT ClClistNodeT *pLastNode)
Returns last node from the list.
ClRcT clClistNextNodeGet(CL_IN ClClistT listHead, CL_IN ClClistNodeT currentNode, CL_OUT ClClistNodeT *pNextNode)
Returns next node from the list.
ClRcT clClistAfterNodeAdd(CL_IN ClClistT listHead, CL_IN ClClistNodeT currentNode, CL_IN ClClistDataT userData)
Adds a node after a specified node in the list.
ClPtrT ClClistT
The type of the handle for the circular list.
Definition: clClistApi.h:83
ClRcT clClistSizeGet(CL_IN ClClistT listHead, CL_OUT ClUint32T *pSize)
Returns number of data elements (nodes) in the list.
ClRcT clClistBeforeNodeAdd(CL_IN ClClistT listHead, CL_IN ClClistNodeT currentNode, CL_IN ClClistDataT userData)
Adds a node before a specified node in the list.
ClRcT clClistWalk(CL_IN ClClistT listHead, CL_IN ClClistWalkCallbackT fpUserWalkCallBack, CL_IN void *userArg)
Walks through the list.
ClPtrT ClClistDataT
The type of the handle for the user-data.
Definition: clClistApi.h:93
ClRcT clClistDelete(CL_IN ClClistT *pListHead)
Destroys the list.
ClRcT clClistCreate(CL_IN ClUint32T maxSize, CL_IN ClClistDropPolicyT dropPolicy, CL_IN ClClistDeleteCallbackT fpUserDeleteCallBack, CL_IN ClClistDeleteCallbackT fpUserDestroyCallBack, CL_OUT ClClistT *pListHead)
Creates a Circular Linked List.
ClRcT clClistFirstNodeAdd(CL_IN ClClistT listHead, CL_IN ClClistDataT userData)
Adds a node at the beginning of the list.
ClRcT clClistFirstNodeGet(CL_IN ClClistT listHead, CL_IN ClClistNodeT *pFirstNode)
Returns the first node from the list.
ClRcT clClistLastNodeAdd(CL_IN ClClistT listHead, CL_IN ClClistDataT userData)
Adds a node at the end of the list.
#define CL_OK
Every thing is OK.
Definition: clCommonErrors.h:68
#define CL_HANDLE_INVALID_VALUE
Defines.
Definition: clHandleApi.h:95

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