From 51cb41667da60aa044a9999dbb660946aa959ac3 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 8 Aug 2017 11:58:50 -0500 Subject: [PATCH] Add ConstraintMatrix::get_lines() that returns a range of line iterators --- include/deal.II/lac/constraint_matrix.h | 24 ++++++++++++++++++++++++ source/lac/constraint_matrix.cc | 7 +++++++ 2 files changed, 31 insertions(+) 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) { -- 2.39.5