aboutsummaryrefslogtreecommitdiff
path: root/src/list/operation/higher/filter.h
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-01-30 19:31:30 +0100
committerAdrian Kummerlaender2015-01-30 19:31:30 +0100
commit6291f3ce10aa8ebffa895f21c4ccb91b7349c66a (patch)
treef2fc654693e7c28fe749a7e11a98c22e1c693837 /src/list/operation/higher/filter.h
parente176dbe160eff01d172a11e7a191f756d4c87712 (diff)
downloadTypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.tar
TypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.tar.gz
TypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.tar.bz2
TypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.tar.lz
TypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.tar.xz
TypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.tar.zst
TypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.zip
Implemented `Remove` and `Partition` higher order list functions
* `Remove` is a basic `Filter` alias that negates its predicate * `Partition` builds on both `Remove` and `Filter` to return both the elements satisfying a predicate and those which don't
Diffstat (limited to 'src/list/operation/higher/filter.h')
-rw-r--r--src/list/operation/higher/filter.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/list/operation/higher/filter.h b/src/list/operation/higher/filter.h
index 8788aed..d91735e 100644
--- a/src/list/operation/higher/filter.h
+++ b/src/list/operation/higher/filter.h
@@ -7,7 +7,7 @@
namespace tav {
template <
- template<typename> class Function,
+ template<typename> class Predicate,
typename List
>
class Filter {
@@ -16,16 +16,30 @@ class Filter {
typename Current,
typename Previous
>
- struct function_wrapper {
+ struct predicate_wrapper {
typedef If<
- Function<Current>::type::value,
+ Predicate<Current>::type::value,
Cons<Current, Previous>,
Previous
> type;
};
public:
- typedef typename Fold<function_wrapper, void, List>::type type;
+ typedef typename Fold<predicate_wrapper, void, List>::type type;
+
+};
+
+template <
+ template<typename> class Predicate,
+ typename List
+>
+class Remove {
+ private:
+ template <typename Element>
+ using predicate_negator = Not<Predicate<Element>>;
+
+ public:
+ typedef typename Filter<predicate_negator, List>::type type;
};