00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028 #ifndef _RTXDLIST_H_
00029 #define _RTXDLIST_H_
00030
00031 #include "rtxsrc/osSysTypes.h"
00032 #include "rtxsrc/rtxExternDefs.h"
00033 #include "rtxsrc/rtxCommonDefs.h"
00034
00053 typedef struct OSRTDListNode {
00054 void* data;
00055 struct OSRTDListNode* next;
00056 struct OSRTDListNode* prev;
00057 } OSRTDListNode;
00058
00065 typedef struct OSRTDList {
00066 OSUINT32 count;
00067 OSRTDListNode* head;
00068 OSRTDListNode* tail;
00069 } OSRTDList;
00070
00071 struct OSCTXT;
00072
00073 typedef struct OSRTDListBuf {
00074 OSUINT32 n;
00075 OSUINT32 nMax;
00076 OSUINT32 nAll;
00077 OSUINT32 firstSegSz;
00078 size_t elemSize;
00079 OSRTDList tmplist;
00080 void** dataArray;
00081 } OSRTDListBuf;
00082
00083 #ifndef DLISTBUF_SEG
00084 #define DLISTBUF_SEG 16
00085 #endif
00086
00087 typedef struct OSRTDListUTF8StrNode {
00088 OSRTDListNode node;
00089 OSUTF8CHAR utf8chars[1];
00090 } OSRTDListUTF8StrNode;
00091
00092 #ifdef __cplusplus
00093 extern "C" {
00094 #endif
00095
00096
00097
00114 EXTERNRTX void rtxDListInit (OSRTDList* pList);
00115
00135 EXTERNRTX OSRTDListNode* rtxDListAppend
00136 (struct OSCTXT* pctxt, OSRTDList* pList, void* pData);
00137
00138 EXTERNRTX OSRTDListNode* rtxDListAppendNode
00139 (OSRTDList* pList, OSRTDListNode* pListNode);
00140
00160 EXTERNRTX OSRTDListNode* rtxDListInsert
00161 (struct OSCTXT* pctxt, OSRTDList* pList, OSUINT32 index, void* pData);
00162
00163 EXTERNRTX OSRTDListNode* rtxDListInsertNode
00164 (OSRTDList* pList, OSUINT32 index, OSRTDListNode* pListNode);
00165
00185 EXTERNRTX OSRTDListNode* rtxDListInsertBefore
00186 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node, void* pData);
00187
00207 EXTERNRTX OSRTDListNode* rtxDListInsertAfter
00208 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node, void* pData);
00209
00223 EXTERNRTX OSRTDListNode*
00224 rtxDListFindByIndex (const OSRTDList* pList, OSUINT32 index);
00225
00236 EXTERNRTX OSRTDListNode*
00237 rtxDListFindByData (const OSRTDList* pList, void* data);
00238
00249 EXTERNRTX int rtxDListFindIndexByData (const OSRTDList* pList, void* data);
00250
00260 EXTERNRTX void rtxDListFreeNode
00261 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node);
00262
00271 EXTERNRTX void rtxDListRemove (OSRTDList* pList, OSRTDListNode* node);
00272
00281 EXTERNRTX void rtxDListFreeNodes (struct OSCTXT* pctxt, OSRTDList* pList);
00282
00292 EXTERNRTX void rtxDListFreeAll (struct OSCTXT* pctxt, OSRTDList* pList);
00293
00311 EXTERNRTX int rtxDListToArray
00312 (struct OSCTXT* pctxt, OSRTDList* pList, void** ppArray,
00313 OSUINT32* pElemCount, size_t elemSize);
00314
00331 EXTERNRTX int rtxDListAppendArray
00332 (struct OSCTXT* pctxt, OSRTDList* pList, void* pArray,
00333 OSUINT32 numElements, size_t elemSize);
00334
00350 EXTERNRTX int rtxDListAppendArrayCopy
00351 (struct OSCTXT* pctxt, OSRTDList* pList, const void* pArray,
00352 OSUINT32 numElements, size_t elemSize);
00353
00369 EXTERNRTX int rtxDListToUTF8Str
00370 (struct OSCTXT* pctxt, OSRTDList* pList, OSUTF8CHAR** ppstr, char sep);
00374
00375 #define OSRTDLISTNODESIZE ((sizeof(OSRTDListNode)+7)&(~7))
00376
00377 #define rtxDListAllocNodeAndData(pctxt,type,ppnode,ppdata) do { \
00378 *ppnode = (OSRTDListNode*) \
00379 rtxMemAlloc (pctxt, sizeof(type)+OSRTDLISTNODESIZE); \
00380 if (0 != *ppnode) { \
00381 (*ppnode)->data = (void*)((char*)(*ppnode)+OSRTDLISTNODESIZE); \
00382 *ppdata = (type*)((*ppnode)->data); \
00383 } else { *ppdata = 0; } \
00384 } while (0)
00385
00386 #define rtxDListAppendData(pctxt,pList,pData) do { \
00387 OSRTDListNode* _node = (OSRTDListNode*) \
00388 (((char*)(pData)) - sizeof(OSRTDListNode)); \
00389 _node->data = pData; \
00390 rtxDListAppendNode (pList, _node); \
00391 } while (0);
00392
00393 #define rtxDListFastInit(pList) do { \
00394 if ((pList) != 0) { \
00395 (pList)->head = (pList)->tail = (OSRTDListNode*) 0; \
00396 (pList)->count = 0; } \
00397 } while (0)
00398
00399
00400
00401 EXTERNRTX void rtxDListBufInit (OSRTDListBuf* pBuf,
00402 OSUINT32 segSz, void** ppdata, size_t elemSz);
00403
00404 EXTERNRTX int rtxDListBufExpand (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
00405
00406 EXTERNRTX int rtxDListBufToArray (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
00407
00408 #ifdef __cplusplus
00409 }
00410 #endif
00411
00412 #endif