Export _splice_back methods.
Add _push_move & _pop_move methods for dual push list.
This commit is contained in:
1 parent
53a79e3170
commit
00c5e3544f
2 files changed
+45
No files matched your search
@@ -91,6 +91,7 @@ typedef struct ilist_head_s {
|
|||||||
OPLIST(oplist), \
|
OPLIST(oplist), \
|
||||||
PUSH(M_C(name,_push_back)), \
|
PUSH(M_C(name,_push_back)), \
|
||||||
POP(M_C(name,_pop_back)) \
|
POP(M_C(name,_pop_back)) \
|
||||||
|
SPLICE_BACK(M_C(name,_splice_back)) \
|
||||||
,M_IF_METHOD(NEW, oplist)(NEW(M_GET_NEW oplist),) \
|
,M_IF_METHOD(NEW, oplist)(NEW(M_GET_NEW oplist),) \
|
||||||
,M_IF_METHOD(DEL, oplist)(DEL(M_GET_DEL oplist),) \
|
,M_IF_METHOD(DEL, oplist)(DEL(M_GET_DEL oplist),) \
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -792,6 +792,22 @@
|
|||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static inline void \
|
static inline void \
|
||||||
|
M_C(name, _push_back_move)(list_t v, type *x) \
|
||||||
|
{ \
|
||||||
|
assert (x != NULL); \
|
||||||
|
type *data = M_C(name, _push_back_raw)(v); \
|
||||||
|
if (M_UNLIKELY (data == NULL)) \
|
||||||
|
return; \
|
||||||
|
M_DO_INIT_MOVE (oplist, *data, *x); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static inline void \
|
||||||
|
M_C(name, _push_move)(list_t v, type *x) \
|
||||||
|
{ \
|
||||||
|
M_C(name, _push_move)(v, x); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static inline void \
|
||||||
M_C(name, _pop_back)(type *data, list_t v) \
|
M_C(name, _pop_back)(type *data, list_t v) \
|
||||||
{ \
|
{ \
|
||||||
LISTI_DUAL_PUSH_CONTRACT(v); \
|
LISTI_DUAL_PUSH_CONTRACT(v); \
|
||||||
@@ -811,6 +827,24 @@
|
|||||||
LISTI_DUAL_PUSH_CONTRACT(v); \
|
LISTI_DUAL_PUSH_CONTRACT(v); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
static inline void \
|
||||||
|
M_C(name, _pop_move)(type *data, list_t v) \
|
||||||
|
{ \
|
||||||
|
LISTI_DUAL_PUSH_CONTRACT(v); \
|
||||||
|
assert (v->back != NULL); \
|
||||||
|
assert (data != NULL); \
|
||||||
|
struct M_C(name, _s) *tofree = v->back; \
|
||||||
|
M_DO_INIT_MOVE (oplist, *data, tofree->data); \
|
||||||
|
v->back = tofree->next; \
|
||||||
|
M_C(name,_int_del)(tofree); \
|
||||||
|
/* Update front too if the list became empty */ \
|
||||||
|
/* This C code shall generate branchless code */ \
|
||||||
|
struct M_C(name, _s) *front = v->front; \
|
||||||
|
front = (front == tofree) ? NULL : front; \
|
||||||
|
v->front = front; \
|
||||||
|
LISTI_DUAL_PUSH_CONTRACT(v); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
static inline const type * \
|
static inline const type * \
|
||||||
M_C(name, _front)(list_t v) \
|
M_C(name, _front)(list_t v) \
|
||||||
{ \
|
{ \
|
||||||
@@ -850,6 +884,16 @@
|
|||||||
M_GET_INIT_SET oplist(*data, x); \
|
M_GET_INIT_SET oplist(*data, x); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
static inline void \
|
||||||
|
M_C(name, _push_front_move)(list_t v, type *x) \
|
||||||
|
{ \
|
||||||
|
assert (x != NULL); \
|
||||||
|
type *data = M_C(name, _push_front_raw)(v); \
|
||||||
|
if (M_UNLIKELY (data == NULL)) \
|
||||||
|
return; \
|
||||||
|
M_DO_INIT_MOVE (oplist, *data, *x); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
static inline type * \
|
static inline type * \
|
||||||
M_C(name, _push_front_new)(list_t v) \
|
M_C(name, _push_front_new)(list_t v) \
|
||||||
{ \
|
{ \
|
||||||
|
|||||||
Reference in new issue
Block a user