Fix prototype of _reduce : dest may not be an array. It is therefore
needed to pass a pointer. Add _map_reduce method.
This commit is contained in:
1 parent
6cee535ccd
commit
75db40a4ff
1 file changed
+23
-3
@@ -127,21 +127,41 @@
|
|||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static inline void M_C(name, _reduce) (type_t dest, \
|
static inline void M_C(name, _reduce) (type_t *dest, \
|
||||||
container_t l, \
|
container_t l, \
|
||||||
void (*f)(type_t, type_t const) ) \
|
void (*f)(type_t, type_t const) ) \
|
||||||
{ \
|
{ \
|
||||||
bool initDone = false; \
|
bool initDone = false; \
|
||||||
for M_EACH(item, l, cont_oplist) { \
|
for M_EACH(item, l, cont_oplist) { \
|
||||||
if (initDone) \
|
if (initDone) \
|
||||||
f(dest, *item); \
|
f(*dest, *item); \
|
||||||
else { \
|
else { \
|
||||||
M_GET_SET type_oplist (dest, *item); \
|
M_GET_SET type_oplist (*dest, *item); \
|
||||||
initDone = true; \
|
initDone = true; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
static inline void M_C(name, _map_reduce) (type_t *dest, \
|
||||||
|
container_t l, \
|
||||||
|
void (*r)(type_t, type_t const), \
|
||||||
|
void (*m)(type_t, type_t const) ) \
|
||||||
|
{ \
|
||||||
|
bool initDone = false; \
|
||||||
|
type_t tmp; \
|
||||||
|
M_GET_INIT type_oplist (tmp); \
|
||||||
|
for M_EACH(item, l, cont_oplist) { \
|
||||||
|
m(tmp, *item); \
|
||||||
|
if (initDone) \
|
||||||
|
r(*dest, tmp); \
|
||||||
|
else { \
|
||||||
|
M_GET_SET type_oplist (*dest, tmp); \
|
||||||
|
initDone = true; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
M_GET_CLEAR type_oplist (tmp); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
M_IF_METHOD(CMP, type_oplist)( \
|
M_IF_METHOD(CMP, type_oplist)( \
|
||||||
static inline type_t *M_C(name, _min) (/*const*/ container_t l) \
|
static inline type_t *M_C(name, _min) (/*const*/ container_t l) \
|
||||||
{ \
|
{ \
|
||||||
|
|||||||
Reference in new issue
Block a user