Hello everyone,
I don’t know how doable it is, but I think it would be nice to be able to use SMP tools on iterators / ranges. This is especially useful for containers that are not indexed like arrays (std::map
or std::set
for instance).
Here’s an example on how it could work with iterators in the worker:
template<class IteratorT>
void operator()(IteratorT begin, IteratorT end)
{
for(IteratorT it = begin; it != end; ++it)
{
// Do stuff
}
}
This could be called using vtkSMPTools::For(container.begin(), container.end(), worker);
With ranges (maybe more optional, as iterators could do the same thing). Note that the range would likely be a proxy range that internally uses iterators from the input container:
template<class RangeT>
void operator()(RangeT& range)
{
for(auto& element : range)
{
// Do stuff
}
}
This could be called using vtkSMPTools::For(container, worker);