35 #define IB_OFFSETOF(T, F) \
36 (reinterpret_cast<byte*>(&(T)->F) - reinterpret_cast<byte*>(T))
49 template <
typename TYPE>
51 typedef TYPE elem_type;
58 #define UT_LIST_BASE_NODE_T(TYPE) ut_list_base<TYPE>
75 template <
typename TYPE>
82 #define UT_LIST_NODE_T(TYPE) ut_list_node<TYPE>
89 template <
typename Type>
93 ut_a(offset <
sizeof(elem));
96 reinterpret_cast<byte*>(&elem) + offset));
103 #define UT_LIST_INIT(BASE)\
106 (BASE).start = NULL;\
115 template <
typename List,
typename Type>
125 elem_node.
next = list.start;
127 if (list.start != 0) {
131 ut_ad(list.start != &elem);
133 base_node.
prev = &elem;
150 #define UT_LIST_ADD_FIRST(NAME, LIST, ELEM) \
151 ut_list_prepend(LIST, *ELEM, IB_OFFSETOF(ELEM, NAME))
158 template <
typename List,
typename Type>
168 elem_node.
prev = list.end;
174 ut_ad(list.end != &elem);
176 base_node.
next = &elem;
181 if (list.start == 0) {
193 #define UT_LIST_ADD_LAST(NAME, LIST, ELEM)\
194 ut_list_append(LIST, *ELEM, IB_OFFSETOF(ELEM, NAME))
202 template <
typename List,
typename Type>
210 ut_ad(&elem1 != &elem2);
215 elem2_node.
prev = &elem1;
218 if (elem1_node.
next != NULL) {
222 next_node.
prev = &elem2;
225 elem1_node.
next = &elem2;
227 if (list.end == &elem1) {
240 #define UT_LIST_INSERT_AFTER(NAME, LIST, ELEM1, ELEM2)\
241 ut_list_insert(LIST, *ELEM1, *ELEM2, IB_OFFSETOF(ELEM1, NAME))
243 #ifdef UNIV_LIST_DEBUG
247 # define UT_LIST_REMOVE_CLEAR(N) \
248 (N).next = (Type*) -1; \
254 # define UT_LIST_REMOVE_CLEAR(N)
262 template <
typename List,
typename Type>
271 ut_a(list.count > 0);
273 if (elem_node.
next != NULL) {
279 list.end = elem_node.
prev;
282 if (elem_node.
prev != NULL) {
288 list.start = elem_node.
next;
301 #define UT_LIST_REMOVE(NAME, LIST, ELEM) \
302 ut_list_remove(LIST, *ELEM, IB_OFFSETOF(ELEM, NAME))
309 #define UT_LIST_GET_NEXT(NAME, N)\
317 #define UT_LIST_GET_PREV(NAME, N)\
325 #define UT_LIST_GET_LEN(BASE)\
332 #define UT_LIST_GET_FIRST(BASE)\
339 #define UT_LIST_GET_LAST(BASE)\
349 template <
typename List,
class Functor>
354 List::elem_type::*node,
359 for (
typename List::elem_type* elem = list.start;
361 elem = (elem->*node).next, ++count) {
366 ut_a(count == list.count);
374 template <
typename List,
class Functor>
379 List::elem_type::*node,
386 for (
typename List::elem_type* elem = list.end;
388 elem = (elem->*node).prev, ++count) {
393 ut_a(count == list.count);
402 #define UT_LIST_VALIDATE(NAME, TYPE, LIST, FUNCTOR) \
403 ut_list_validate(LIST, &TYPE::NAME, FUNCTOR)
405 #define UT_LIST_CHECK(NAME, TYPE, LIST) \
406 ut_list_validate(LIST, &TYPE::NAME, NullValidate())