00001 #ifndef __DS_LIST_H__
00002 #define __DS_LIST_H__
00003
00004 #include "ds_common.h"
00005
00006 #ifdef __cplusplus
00007 extern "C" {
00008 #endif
00009
00011 typedef struct Node {
00012 struct Node *pNext;
00013 struct Node *pPrev;
00017 int index;
00018 void *pData;
00019 } Node;
00020
00022 typedef struct ListWorkspace {
00023 Node *pNodes;
00024 bool *pUsage;
00025 int iNext;
00026 int iSize;
00027 } ListWorkspace;
00028
00030 typedef struct List {
00031 long lSize;
00032 ListWorkspace WS;
00033 Node *pHead;
00034 Node *pTail;
00035 } List;
00036
00056 List* ListCreate(int iWSSize);
00068 void ListDestroy(List *pList);
00080 Node* ListPushFront(List *pList, void *pData);
00092 Node* ListPushBack(List *pList, void *pData);
00105 Node* ListInsertBefore(List *pList, Node *pNode, void *pData);
00118 Node* ListInsertAfter(List *pList, Node *pNode, void *pData);
00144 Node* ListFind(Node *pStart, void *pData, bool bDirection);
00153 void ListRemove(List *pList, Node *pNode);
00154
00158 #define ListPopBack(pList) ListRemove(pList, pList->pTail)
00159
00162 #define ListPopFront(pList) ListRemove(pList, pList->pHead)
00163
00164 #ifdef __cplusplus
00165 }
00166 #endif
00167
00168 #endif