1 #ifndef CombineTools_Algorithm_h
2 #define CombineTools_Algorithm_h
5 #include "boost/range/begin.hpp"
6 #include "boost/range/end.hpp"
7 #include "boost/regex.hpp"
8 #include "boost/range/algorithm_ext/erase.hpp"
11 template <
typename Range,
typename Predicate>
13 r.erase(std::remove_if(r.begin(), r.end(), p), r.end());
16 template<
typename Range,
typename Predicate>
17 bool any_of(
const Range &r, Predicate p) {
18 return std::any_of(boost::begin(r), boost::end(r), p);
21 template<
typename Range,
typename T>
23 return std::find(boost::begin(r), boost::end(r), p) != boost::end(r);
28 template<
typename R,
typename T>
29 bool contains(
const std::initializer_list<R> &r, T p) {
30 return std::find(boost::begin(r), boost::end(r), p) != boost::end(r);
35 for (
auto const& rgx : r)
36 if (regex_match(p, rgx))
return true;
40 template <
typename Input,
typename Filter,
typename Converter>
43 boost::remove_erase_if(in, [&](
typename Input::value_type
const& p) {
48 template <
typename Input,
typename Filter,
typename Converter>
51 std::vector<boost::regex> rgx;
52 for (
auto const& ele : filter) rgx.emplace_back(ele);
53 boost::remove_erase_if(in, [&](
typename Input::value_type
const& p) {
58 template <
typename Input,
typename Filter,
typename Converter,
typename Funcarg>
61 boost::remove_erase_if(in, [&](
typename Input::value_type
const& p) {
66 template <
typename Input,
typename Filter,
typename Converter,
typename Funcarg>
69 std::vector<boost::regex> rgx;
70 for (
auto const& ele : filter) rgx.emplace_back(ele);
71 boost::remove_erase_if(in, [&](
typename Input::value_type
const& p) {
void FilterContainingRgx(Input &in, Filter const &filter, Converter fn, bool cond)
void FilterContaining(Input &in, Filter const &filter, Converter fn, bool cond)
bool contains_rgx(const std::vector< boost::regex > &r, T p)
bool contains(const Range &r, T p)
bool any_of(const Range &r, Predicate p)
void erase_if(Range &r, Predicate p)