Skip to content
Snippets Groups Projects
Commit a1c95798 authored by Carsten Gräser's avatar Carsten Gräser
Browse files

Add a hybrid loop over a sparse range

parent 8fc27230
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -242,6 +242,33 @@ constexpr auto hybridSize(const T& t) ...@@ -242,6 +242,33 @@ constexpr auto hybridSize(const T& t)
/**
* \brief Hybrid for loop over sparse range
*/
template<class... T, class F>
void sparseRangeFor(Dune::MultiTypeBlockMatrix<T...>& range, F&& f)
{
integralRangeFor<std::size_t>(Indices::_0, hybridSize(range), [&](auto&& i) {
f(range[i], i);
});
}
/**
* \brief Hybrid for loop over sparse range
*/
template<class Range, class F>
void sparseRangeFor(Range&& range, F&& f)
{
auto it = range.begin();
auto end = range.end();
for(; it!=end; ++it)
f(*it, it.index());
}
} // namespace Solvers } // namespace Solvers
} // namespace Dune } // namespace Dune
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment