From b600eac6363e0d96b8143fec713463f0e8a001f9 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 4 Mar 2017 18:58:52 +0100 Subject: [PATCH] Add function algo_reduce --- m-algo.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/m-algo.h b/m-algo.h index 0c11ff0c..51e7eac2 100644 --- a/m-algo.h +++ b/m-algo.h @@ -95,6 +95,19 @@ } \ } \ \ + static inline void M_C(name, _reduce) (type_t dest, \ + container_t l, \ + void (*f)(type_t, type_t const) ) \ + { \ + bool initDone = false; \ + for M_EACH(item, l, cont_oplist) { \ + if (initDone) \ + f(dest, *item); \ + else \ + M_GET_SET type_oplist (dest, *item); \ + } \ + } \ + \ M_IF_METHOD(CMP, type_oplist)( \ static inline type_t *M_C(name, _min) (/*const*/ container_t l) \ { \