sll_pub.h

来自「abstract rtos」· C头文件 代码 · 共 74 行

H
74
字号
#ifndef _UTLSLL_H_#define _UTLSLL_H_#ifdef  __cplusplusextern "C" {#endiftypedef struct SLL_NODE{   struct SLL_NODE *pNext;   U32 ulHandle;}SLL_NODE_S;typedef struct SLL{   SLL_NODE_S Head;        SLL_NODE_S *Tail;       U32         u4_Count; }SLL_S;#define SLL_GET_HANDLE(pNode)	((pNode)->ulHandle)#define SLL_SET_HANDLE(pNode, ulValue)	((pNode)->ulHandle = (U32)(ulValue))#define SLL_Init(pList) \    {\        (pList)->Head.pNext = &(pList)->Head; \        (pList)->Tail       = &(pList)->Head; \        (pList)->u4_Count   = 0;\    }#define SLL_Init_Node(pNode) \        (pNode)->pNext = 0;#define SLL_Add(pList,pNode) \        SLL_Insert_In_Middle((pList),(pList)->Tail,(pNode),&(pList)->Head)#define SLL_Count(pList) ((pList)->u4_Count)#define SLL_First(pList) \        ((SLL_Count((pList)) == 0) ? NULL: (pList)->Head.pNext)#define SLL_Last(pList) \        ((SLL_Count((pList)) == 0) ? NULL : (pList)->Tail)#define SLL_Next(pList,pNode) \        (((pNode) == NULL) ? SLL_First(pList) : \        (((pNode)->pNext == &(pList)->Head) ? NULL : (pNode)->pNext))#define SLL_Is_Node_In_List(pNode) \        (pNode->pNext != NULL)#define SLL_Scan(pList,pNode,TypeCast) \        for(pNode = (TypeCast)(SLL_First((pList))); \            pNode != NULL; \            pNode = (TypeCast)SLL_Next((pList),((SLL_NODE_S *)(pNode))))SLL_NODE_S *SLL_Find(SLL_S *pList, VOID *pKey, S32 (*fnValCmp)(VOID *, SLL_NODE_S *));VOID SLL_Insert_In_Middle (SLL_S *pList, SLL_NODE_S *pPrev, SLL_NODE_S *pMid, SLL_NODE_S *pNext);VOID SLL_Delete_In_Middle (SLL_S *pList, 						   SLL_NODE_S *pPrev,                            SLL_NODE_S *pNode,                            SLL_NODE_S *pNext);VOID SLL_Delete (SLL_S *pList, SLL_NODE_S *pNode);SLL_NODE_S *SLL_Get (SLL_S *pList);VOID SLL_Insert (SLL_S *pList,SLL_NODE_S *pPrev,SLL_NODE_S *pNode);SLL_NODE_S *SLL_Previous (SLL_S *pList,SLL_NODE_S *pNode);VOID SLL_FreeAll (SLL_S *pList, VOID (*fnFree)(VOID *));S32 SLL_Walk(SLL_S *pList, VOID (*fnVisit)(SLL_NODE_S *));#ifdef  __cplusplus}#endif#endif 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?