From ab2bbaef3fb82891a2015d2614fe48699e2f7a4e Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 26 Jun 2014 09:03:04 -0700 Subject: [PATCH] feat(util/list_fn): add remove function Signed-off-by: Leonardo de Moura --- src/util/list_fn.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util/list_fn.h b/src/util/list_fn.h index 3178be61f3..246c62f0f6 100644 --- a/src/util/list_fn.h +++ b/src/util/list_fn.h @@ -176,6 +176,12 @@ list filter(list const & l, P && p) { } } +/** \brief Remove all occurrences of \c a from \c l */ +template +list remove(list const & l, T const & a) { + return filter(l, [&](T const & v) { return a != v; }); +} + /** \brief Remove the last element that satisfies \c p. */ template list remove_last(list const & l, P && p) {