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
00156 EXTERNRT OSRTDListNode* rtxDListAppendCharArray
00157 (struct OSCTXT* pctxt, OSRTDList* pList, size_t length, char* pData);
00158
00174 EXTERNRT OSRTDListNode* rtxDListAppendNode
00175 (OSRTDList* pList, OSRTDListNode* pListNode);
00176
00196 EXTERNRT OSRTDListNode* rtxDListInsert
00197 (struct OSCTXT* pctxt, OSRTDList* pList, OSSIZE idx, void* pData);
00198
00199 EXTERNRT OSRTDListNode* rtxDListInsertNode
00200 (OSRTDList* pList, OSSIZE idx, OSRTDListNode* pListNode);
00201
00221 EXTERNRT OSRTDListNode* rtxDListInsertBefore
00222 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node, void* pData);
00223
00243 EXTERNRT OSRTDListNode* rtxDListInsertAfter
00244 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node, void* pData);
00245
00259 EXTERNRT OSRTDListNode*
00260 rtxDListFindByIndex (const OSRTDList* pList, OSSIZE idx);
00261
00272 EXTERNRT OSRTDListNode*
00273 rtxDListFindByData (const OSRTDList* pList, void* data);
00274
00285 EXTERNRT int rtxDListFindIndexByData (const OSRTDList* pList, void* data);
00286
00296 EXTERNRT void rtxDListFreeNode
00297 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node);
00298
00307 EXTERNRT void rtxDListRemove (OSRTDList* pList, OSRTDListNode* node);
00308
00317 EXTERNRT void rtxDListFreeNodes (struct OSCTXT* pctxt, OSRTDList* pList);
00318
00328 EXTERNRT void rtxDListFreeAll (struct OSCTXT* pctxt, OSRTDList* pList);
00329
00347 EXTERNRT int rtxDListToArray
00348 (struct OSCTXT* pctxt, OSRTDList* pList, void** ppArray,
00349 OSSIZE* pElemCount, OSSIZE elemSize);
00350
00367 EXTERNRT int rtxDListAppendArray
00368 (struct OSCTXT* pctxt, OSRTDList* pList, void* pArray,
00369 OSSIZE numElements, OSSIZE elemSize);
00370
00386 EXTERNRT int rtxDListAppendArrayCopy
00387 (struct OSCTXT* pctxt, OSRTDList* pList, const void* pArray,
00388 OSSIZE numElements, OSSIZE elemSize);
00389
00405 EXTERNRT int rtxDListToUTF8Str
00406 (struct OSCTXT* pctxt, OSRTDList* pList, OSUTF8CHAR** ppstr, char sep);
00407
00408
00409
00410 typedef int (*PEqualsFunc) (const void* a, const void* b,
00411 const void* sortCtxt);
00412
00413 EXTERNRT OSRTDListNode* rtxDListInsertSorted
00414 (struct OSCTXT* pctxt, OSRTDList* pList, void* pData, PEqualsFunc equalsFunc,
00415 void* sortCtxt);
00416
00417 EXTERNRT OSRTDListNode* rtxDListInsertNodeSorted
00418 (OSRTDList* pList, OSRTDListNode* pListNode, PEqualsFunc equalsFunc,
00419 void* sortCtxt);
00420
00424 #if defined(_MSC_VER)
00425
00426
00427 #pragma warning(disable: 4127)
00428 #endif
00429
00430
00431 #define OSRTDLISTNODESIZE ((sizeof(OSRTDListNode)+7)&(~7))
00432
00433 #define rtxDListAllocNodeAndData(pctxt,type,ppnode,ppdata) do { \
00434 *ppnode = (OSRTDListNode*) \
00435 rtxMemAlloc (pctxt, sizeof(type)+OSRTDLISTNODESIZE); \
00436 if (0 != *ppnode) { \
00437 (*ppnode)->data = (void*)((char*)(*ppnode)+OSRTDLISTNODESIZE); \
00438 *ppdata = (type*)((*ppnode)->data); \
00439 } else { *ppdata = 0; } \
00440 } while (0)
00441
00442 #define rtxDListAppendData(pctxt,pList,pData) do { \
00443 rtxDListAppend(pctxt,pList,pData); \
00444 } while(0);
00445
00446
00447
00448 #define rtxDListFastInit(pList) do { \
00449 if ((pList) != 0) { \
00450 (pList)->head = (pList)->tail = (OSRTDListNode*) 0; \
00451 (pList)->count = 0; } \
00452 } while (0)
00453
00454 #define rtxDListFreeTailNode(pctxt,pList) \
00455 rtxDListFreeNode(pctxt,pList,(pList)->tail)
00456
00457 #define rtxDListFreeHeadNode(pctxt,pList) \
00458 rtxDListFreeNode(pctxt,pList,(pList)->head)
00459
00460
00461
00462 EXTERNRT void rtxDListBufInit (OSRTDListBuf* pBuf,
00463 OSSIZE segSz, void** ppdata, OSSIZE elemSz);
00464
00465 EXTERNRT int rtxDListBufExpand (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
00466
00467 EXTERNRT int rtxDListBufToArray (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
00468
00469 #ifdef __cplusplus
00470 }
00471 #endif
00472
00473 #endif