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"
00052 typedef struct OSRTDListNode {
00053 void* data;
00054 struct OSRTDListNode* next;
00055 struct OSRTDListNode* prev;
00056 } OSRTDListNode;
00057
00064 typedef struct OSRTDList {
00065 OSSIZE count;
00066 OSRTDListNode* head;
00067 OSRTDListNode* tail;
00068 } OSRTDList;
00069
00070 struct OSCTXT;
00071
00072 typedef struct OSRTDListBuf {
00073 OSSIZE n;
00074 OSSIZE nMax;
00075 OSSIZE nAll;
00076 OSSIZE firstSegSz;
00077 OSSIZE elemSize;
00078 OSRTDList tmplist;
00079 void** dataArray;
00080 } OSRTDListBuf;
00081
00082 #ifndef DLISTBUF_SEG
00083 #define DLISTBUF_SEG 16
00084 #endif
00085
00086 typedef struct OSRTDListUTF8StrNode {
00087 OSRTDListNode node;
00088 OSUTF8CHAR utf8chars[1];
00089 } OSRTDListUTF8StrNode;
00090
00091 #ifdef __cplusplus
00092 extern "C" {
00093 #endif
00094
00095
00096
00113 EXTERNRT void rtxDListInit (OSRTDList* pList);
00114
00134 EXTERNRT OSRTDListNode* rtxDListAppend
00135 (struct OSCTXT* pctxt, OSRTDList* pList, void* pData);
00136
00137 EXTERNRT OSRTDListNode* rtxDListAppendNode
00138 (OSRTDList* pList, OSRTDListNode* pListNode);
00139
00159 EXTERNRT OSRTDListNode* rtxDListInsert
00160 (struct OSCTXT* pctxt, OSRTDList* pList, OSSIZE idx, void* pData);
00161
00162 EXTERNRT OSRTDListNode* rtxDListInsertNode
00163 (OSRTDList* pList, OSSIZE idx, OSRTDListNode* pListNode);
00164
00184 EXTERNRT OSRTDListNode* rtxDListInsertBefore
00185 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node, void* pData);
00186
00206 EXTERNRT OSRTDListNode* rtxDListInsertAfter
00207 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node, void* pData);
00208
00222 EXTERNRT OSRTDListNode*
00223 rtxDListFindByIndex (const OSRTDList* pList, OSSIZE idx);
00224
00235 EXTERNRT OSRTDListNode*
00236 rtxDListFindByData (const OSRTDList* pList, void* data);
00237
00248 EXTERNRT int rtxDListFindIndexByData (const OSRTDList* pList, void* data);
00249
00259 EXTERNRT void rtxDListFreeNode
00260 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node);
00261
00270 EXTERNRT void rtxDListRemove (OSRTDList* pList, OSRTDListNode* node);
00271
00280 EXTERNRT void rtxDListFreeNodes (struct OSCTXT* pctxt, OSRTDList* pList);
00281
00291 EXTERNRT void rtxDListFreeAll (struct OSCTXT* pctxt, OSRTDList* pList);
00292
00310 EXTERNRT int rtxDListToArray
00311 (struct OSCTXT* pctxt, OSRTDList* pList, void** ppArray,
00312 OSSIZE* pElemCount, OSSIZE elemSize);
00313
00330 EXTERNRT int rtxDListAppendArray
00331 (struct OSCTXT* pctxt, OSRTDList* pList, void* pArray,
00332 OSSIZE numElements, OSSIZE elemSize);
00333
00349 EXTERNRT int rtxDListAppendArrayCopy
00350 (struct OSCTXT* pctxt, OSRTDList* pList, const void* pArray,
00351 OSSIZE numElements, OSSIZE elemSize);
00352
00368 EXTERNRT int rtxDListToUTF8Str
00369 (struct OSCTXT* pctxt, OSRTDList* pList, OSUTF8CHAR** ppstr, char sep);
00370
00371
00372
00373 typedef int (*PEqualsFunc) (const void* a, const void* b,
00374 const void* sortCtxt);
00375
00376 EXTERNRT OSRTDListNode* rtxDListInsertSorted
00377 (struct OSCTXT* pctxt, OSRTDList* pList, void* pData, PEqualsFunc equalsFunc,
00378 void* sortCtxt);
00379
00380 EXTERNRT OSRTDListNode* rtxDListInsertNodeSorted
00381 (OSRTDList* pList, OSRTDListNode* pListNode, PEqualsFunc equalsFunc,
00382 void* sortCtxt);
00383
00387 #if defined(_MSC_VER)
00388
00389
00390 #pragma warning(disable: 4127)
00391 #endif
00392
00393
00394 #define OSRTDLISTNODESIZE ((sizeof(OSRTDListNode)+7)&(~7))
00395
00396 #define rtxDListAllocNodeAndData(pctxt,type,ppnode,ppdata) do { \
00397 *ppnode = (OSRTDListNode*) \
00398 rtxMemAlloc (pctxt, sizeof(type)+OSRTDLISTNODESIZE); \
00399 if (0 != *ppnode) { \
00400 (*ppnode)->data = (void*)((char*)(*ppnode)+OSRTDLISTNODESIZE); \
00401 *ppdata = (type*)((*ppnode)->data); \
00402 } else { *ppdata = 0; } \
00403 } while (0)
00404
00405 #define rtxDListAppendData(pctxt,pList,pData) do { \
00406 OSRTDListNode* _node = (OSRTDListNode*) \
00407 (((char*)(pData)) - sizeof(OSRTDListNode)); \
00408 _node->data = pData; \
00409 rtxDListAppendNode (pList, _node); \
00410 } while (0);
00411
00412 #define rtxDListFastInit(pList) do { \
00413 if ((pList) != 0) { \
00414 (pList)->head = (pList)->tail = (OSRTDListNode*) 0; \
00415 (pList)->count = 0; } \
00416 } while (0)
00417
00418 #define rtxDListFreeTailNode(pctxt,pList) \
00419 rtxDListFreeNode(pctxt,pList,(pList)->tail)
00420
00421 #define rtxDListFreeHeadNode(pctxt,pList) \
00422 rtxDListFreeNode(pctxt,pList,(pList)->head)
00423
00424
00425
00426 EXTERNRT void rtxDListBufInit (OSRTDListBuf* pBuf,
00427 OSSIZE segSz, void** ppdata, OSSIZE elemSz);
00428
00429 EXTERNRT int rtxDListBufExpand (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
00430
00431 EXTERNRT int rtxDListBufToArray (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
00432
00433 #ifdef __cplusplus
00434 }
00435 #endif
00436
00437 #endif