From: Matthias Maier Date: Tue, 8 Aug 2017 16:58:50 +0000 (-0500) Subject: Add ConstraintMatrix::get_lines() that returns a range of line iterators X-Git-Tag: v9.0.0-rc1~1333^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51cb41667da60aa044a9999dbb660946aa959ac3;p=dealii.git Add ConstraintMatrix::get_lines() that returns a range of line iterators --- diff --git a/include/deal.II/lac/constraint_matrix.h b/include/deal.II/lac/constraint_matrix.h index 233fd53b91..4a8cda20e0 100644 --- a/include/deal.II/lac/constraint_matrix.h +++ b/include/deal.II/lac/constraint_matrix.h @@ -26,6 +26,8 @@ #include #include +#include + #include #include #include @@ -1178,6 +1180,28 @@ public: }; + /** + * Typedef for the iterator type that is used in the LineRange container. + */ + typedef std::vector::const_iterator const_iterator; + + + /** + * Typedef for the return type used by get_lines(). + */ + typedef boost::iterator_range LineRange; + + + /** + * Return a range object containing (const) iterators to all line entries + * stored in the ConstraintMatrix. Such a range is useful to initialize + * range-based for loops as supported by C++11. + * + * @return A range object for the half open range [this->begin(), + * this->end()) of line entries. + */ + const LineRange get_lines() const; + /** * Exception diff --git a/source/lac/constraint_matrix.cc b/source/lac/constraint_matrix.cc index f9aa08942c..b00e08cee6 100644 --- a/source/lac/constraint_matrix.cc +++ b/source/lac/constraint_matrix.cc @@ -97,6 +97,13 @@ ConstraintMatrix::ConstraintLine::memory_consumption () const +const ConstraintMatrix::LineRange ConstraintMatrix::get_lines() const +{ + return boost::make_iterator_range(lines.begin(), lines.end()); +} + + + void ConstraintMatrix::add_lines (const std::set &lines) {