00001 #ifndef __si_std_listt_h__eb634e8a_92f0_4ae9_8246_7289de8737a8
00002 #define __si_std_listt_h__eb634e8a_92f0_4ae9_8246_7289de8737a8
00003
00023 #include <si_std/list.h>
00024
00025
00029 #define sm_nodePtr(it)\
00030 (it)->priv_.node
00031
00041 #define sm_listIteratorDecl(T)\
00042 typedef sc_listIterator T##ListIterator;\
00043 static void T##ListIterator_init(T##ListIterator* I)\
00044 { sm_nodePtr(I) = NULL; }\
00045 static T* T##ListIterator_get(T##ListIterator* I)\
00046 { return (T*)(sm_nodePtr(I)+1); }\
00047 static void T##ListIterator_next(T##ListIterator* I)\
00048 { sm_nodePtr(I) = sm_nodePtr(I)->next; }\
00049 static void T##ListIterator_prev(T##ListIterator* I)\
00050 { sm_nodePtr(I) = sm_nodePtr(I)->prev; }\
00051 static s_bool T##ListIterator_isEnd(T##ListIterator* I)\
00052 { return ( (sm_nodePtr(I) == NULL) || (sm_nodePtr(I)->next == NULL) ) \
00053 ? seTrue : seFalse; }
00054
00062 #define sm_listDecl(T)\
00063 sm_listIteratorDecl(T);\
00064 typedef sc_list T##List;\
00065 typedef s_int32 (*T##ListNode_compare)(T* pLHS, T* pRHS);\
00066 sc_status T##List_construct(T##List* pl,\
00067 s_int32 initialCapacity, s_int32 maxCapacity);\
00068 sc_status T##List_destruct(T##List* pl);\
00069 sc_status T##List_assign(T##List* pl, T##List* prhs);\
00070 \
00071 sc_status T##List_getBegin(T##List* pl, T##ListIterator* pit);\
00072 sc_status T##List_getEnd(T##List* pl, T##ListIterator* pit);\
00073 sc_status T##List_getIsEmpty(T##List* pl, s_bool* pb);\
00074 \
00075 sc_status T##List_clear(T##List* pl);\
00076 sc_status T##List_insert(T##List* pl, T##ListIterator* it, T* nt);\
00077 sc_status T##List_erase(T##List* pl, T##ListIterator* it);\
00078 sc_status T##List_remove(T##List* pl, T##ListIterator* it);\
00079 \
00080 sc_status T##List_pushBack(T##List* pl, T* pnt);\
00081 sc_status T##List_pushFront(T##List* pl, T* pnt);\
00082 sc_status T##List_popBack(T##List* pl, T* pnt);\
00083 sc_status T##List_popFront(T##List* pl, T* pnt);\
00084 \
00085 sc_status T##List_front(T##List* pl, T** pnt);\
00086 sc_status T##List_back(T##List* pl, T** pnt);\
00087 \
00088 sc_status T##List_getSize(T##List* pl, s_uint32* sz);\
00089
00090
00104 #define sm_listImpl(T)\
00105 sc_status T##List_construct(T##List* pl,\
00106 s_int32 icap, s_int32 mcap)\
00107 { \
00108 static const sc_listNodeDescriptor lv = { sizeof(T), \
00109 (sc_listNode_constructCopyf)T##_constructCopy,\
00110 (sc_listNode_assignf)T##_assign,\
00111 (sc_listNode_destructf)T##_destruct }; \
00112 return sc_list_construct(pl,&lv,icap,mcap); \
00113 }\
00114 sc_status T##List_destruct(T##List* pl)\
00115 { return sc_list_destruct(pl); }\
00116 sc_status T##List_getBegin(T##List* pl, T##ListIterator* pit)\
00117 { return sc_list_getBegin(pl,pit); }\
00118 sc_status T##List_getEnd(T##List* pl, T##ListIterator* pit)\
00119 { return sc_list_getEnd(pl,pit); }\
00120 sc_status T##List_getIsEmpty(T##List* pl, s_bool* pb)\
00121 { return sc_list_getIsEmpty(pl,pb); }\
00122 \
00123 sc_status T##List_insert(T##List* pl, T##ListIterator* it, T* nt)\
00124 { return sc_list_insert(pl,it,nt); }\
00125 sc_status T##List_erase(T##List* pl, T##ListIterator* it)\
00126 { return sc_list_erase(pl, it); }\
00127 sc_status T##List_remove(T##List* pl, T##ListIterator* it)\
00128 { return sc_list_remove(pl,it); }\
00129 sc_status T##List_clear(T##List* pl)\
00130 { return sc_list_clear(pl); }\
00131 \
00132 sc_status T##List_pushBack(T##List* pl, T* pnt)\
00133 { return sc_list_pushBack(pl,pnt); }\
00134 sc_status T##List_pushFront(T##List* pl, T* pnt)\
00135 { return sc_list_pushFront(pl,pnt); }\
00136 \
00137 sc_status T##List_popBack(T##List* pl, T* pnt)\
00138 { return sc_list_popBack(pl,pnt); }\
00139 sc_status T##List_popFront(T##List* pl, T* pnt)\
00140 { return sc_list_popFront(pl,pnt); }\
00141 \
00142 sc_status T##List_front(T##List* pl, T** ppnt)\
00143 { return sc_list_front(pl,(void**)ppnt); }\
00144 sc_status T##List_back(T##List* pl, T** ppnt)\
00145 { return sc_list_back(pl,(void**)ppnt); }\
00146 \
00147 sc_status T##List_getSize(T##List* pl, s_uint32* sz)\
00148 { return sc_list_getSize(pl,sz); }\
00149
00150
00151
00152
00153 #endif