Commit 0bada6a3 authored by Konstantinos Chatzilygeroudis's avatar Konstantinos Chatzilygeroudis
Browse files

Added parallel foreach..Useful for traversing containers with not normal iterators

parent 574e7db0
......@@ -8,6 +8,7 @@
#include <tbb/concurrent_vector.h>
#include <tbb/task_scheduler_init.h>
#include <tbb/parallel_for.h>
#include <tbb/parallel_for_each.h>
#include <tbb/parallel_sort.h>
#include <tbb/parallel_reduce.h>
#include <tbb/blocked_range.h>
......@@ -81,6 +82,18 @@ namespace limbo {
#endif
}
// parallel for_each
template <typename Iterator, typename F>
inline void for_each(Iterator begin, Iterator end, const F& f)
{
#ifdef USE_TBB
tbb::parallel_for_each(begin, end, f);
#else
for (Iterator i = begin; i != end; ++i)
f(*i);
#endif
}
template <typename T, typename F, typename C>
T max(const T& init, int num_steps, const F& f, const C& comp)
{
......
Supports Markdown
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