Commit 39dd0466 authored by Dominik Charousset's avatar Dominik Charousset

Add convenience algorithms for filters

parent 5aa1818e
......@@ -19,6 +19,8 @@
#ifndef CAF_BROADCAST_SCATTERER_HPP
#define CAF_BROADCAST_SCATTERER_HPP
#include <algorithm>
#include "caf/buffered_scatterer.hpp"
#include "caf/outbound_path.hpp"
......@@ -73,6 +75,36 @@ public:
return state_map_[slot].filter;
}
/// Returns whether all filters satisfy the predicate as if applying
/// `std::all_of`.
template <class UnaryPredicate>
bool all_filters(UnaryPredicate predicate) {
return std::all_of(state_map_.begin(), state_map_.end(),
[&](const typename state_map_type::value_type& kvp) {
return predicate(kvp.second);
});
}
/// Returns whether any filter satisfies the predicate as if applying
/// `std::any_of`.
template <class UnaryPredicate>
bool any_filter(UnaryPredicate predicate) {
return std::any_of(state_map_.begin(), state_map_.end(),
[&](const typename state_map_type::value_type& kvp) {
return predicate(kvp.second);
});
}
/// Returns whether no filter satisfies the predicate as if applying
/// `std::none_of`.
template <class UnaryPredicate>
bool no_filter(UnaryPredicate predicate) {
return std::none_of(state_map_.begin(), state_map_.end(),
[&](const typename state_map_type::value_type& kvp) {
return predicate(kvp.second);
});
}
/// Returns the broadcast states for all paths.
state_map_type& states() {
return state_map_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment