From e176dbe160eff01d172a11e7a191f756d4c87712 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 30 Jan 2015 19:07:22 +0100 Subject: Separated `Map` and `Filter` * there is no reason to keep them in the same header --- src/list/generator/higher/list_tabulate.h | 2 +- src/list/operation/higher/filter.h | 34 +++++++++++++++++++ src/list/operation/higher/map.h | 33 ++++++++++++++++++ src/list/operation/higher/misc.h | 56 ------------------------------- src/list/operation/higher/query.h | 2 +- test.cc | 3 +- 6 files changed, 71 insertions(+), 59 deletions(-) create mode 100644 src/list/operation/higher/filter.h create mode 100644 src/list/operation/higher/map.h delete mode 100644 src/list/operation/higher/misc.h diff --git a/src/list/generator/higher/list_tabulate.h b/src/list/generator/higher/list_tabulate.h index 9eee599..dd2914a 100644 --- a/src/list/generator/higher/list_tabulate.h +++ b/src/list/generator/higher/list_tabulate.h @@ -2,7 +2,7 @@ #define TYPEASVALUE_SRC_LIST_GENERATOR_HIGHER_LIST_TABULATE_H_ #include "list/generator/iota.h" -#include "list/operation/higher/misc.h" +#include "list/operation/higher/map.h" namespace tav { diff --git a/src/list/operation/higher/filter.h b/src/list/operation/higher/filter.h new file mode 100644 index 0000000..8788aed --- /dev/null +++ b/src/list/operation/higher/filter.h @@ -0,0 +1,34 @@ +#ifndef TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FILTER_H_ +#define TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FILTER_H_ + +#include "fold.h" +#include "conditional/if.h" + +namespace tav { + +template < + template class Function, + typename List +> +class Filter { + private: + template < + typename Current, + typename Previous + > + struct function_wrapper { + typedef If< + Function::type::value, + Cons, + Previous + > type; + }; + + public: + typedef typename Fold::type type; + +}; + +} + +#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FILTER_H_ diff --git a/src/list/operation/higher/map.h b/src/list/operation/higher/map.h new file mode 100644 index 0000000..1c577ca --- /dev/null +++ b/src/list/operation/higher/map.h @@ -0,0 +1,33 @@ +#ifndef TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_MAP_H_ +#define TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_MAP_H_ + +#include "fold.h" +#include "conditional/if.h" + +namespace tav { + +template < + template class Function, + typename List +> +class Map { + private: + template < + typename Current, + typename Previous + > + struct function_wrapper { + typedef Cons< + typename Function::type, + Previous + > type; + }; + + public: + typedef typename Fold::type type; + +}; + +} + +#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_MAP_H_ diff --git a/src/list/operation/higher/misc.h b/src/list/operation/higher/misc.h deleted file mode 100644 index feec7de..0000000 --- a/src/list/operation/higher/misc.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_MISC_H_ -#define TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_MISC_H_ - -#include "fold.h" -#include "conditional/if.h" - -namespace tav { - -template < - template class Function, - typename List -> -class Map { - private: - template < - typename Current, - typename Previous - > - struct function_wrapper { - typedef Cons< - typename Function::type, - Previous - > type; - }; - - public: - typedef typename Fold::type type; - -}; - -template < - template class Function, - typename List -> -class Filter { - private: - template < - typename Current, - typename Previous - > - struct function_wrapper { - typedef If< - Function::type::value, - Cons, - Previous - > type; - }; - - public: - typedef typename Fold::type type; - -}; - -} - -#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_MISC_H_ diff --git a/src/list/operation/higher/query.h b/src/list/operation/higher/query.h index c6eabc7..198ffa5 100644 --- a/src/list/operation/higher/query.h +++ b/src/list/operation/higher/query.h @@ -2,7 +2,7 @@ #define TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_QUERY_H_ #include "fold.h" -#include "misc.h" +#include "map.h" #include "operation/math.h" #include "operation/logic.h" diff --git a/test.cc b/test.cc index cf99e8e..e7817f0 100644 --- a/test.cc +++ b/test.cc @@ -7,7 +7,8 @@ #include "list/list.h" #include "list/operation/reverse.h" #include "list/operation/contains.h" -#include "list/operation/higher/misc.h" +#include "list/operation/higher/map.h" +#include "list/operation/higher/filter.h" #include "list/operation/higher/query.h" #include "list/generator/iota.h" #include "list/generator/make_list.h" -- cgit v1.2.3