]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add ConstraintMatrix::get_lines() that returns a range of line iterators
authorMatthias Maier <tamiko@43-1.org>
Tue, 8 Aug 2017 16:58:50 +0000 (11:58 -0500)
committerMatthias Maier <tamiko@43-1.org>
Tue, 8 Aug 2017 23:54:04 +0000 (18:54 -0500)
include/deal.II/lac/constraint_matrix.h
source/lac/constraint_matrix.cc

index 233fd53b911f6905ef30a12cb3a09423e27ee2f7..4a8cda20e04dd051d3701b8e50a16994b07cb858 100644 (file)
@@ -26,6 +26,8 @@
 #include <deal.II/lac/vector.h>
 #include <deal.II/lac/vector_element_access.h>
 
+#include <boost/range/iterator_range.hpp>
+
 #include <vector>
 #include <set>
 #include <utility>
@@ -1178,6 +1180,28 @@ public:
   };
 
 
+  /**
+   * Typedef for the iterator type that is used in the LineRange container.
+   */
+  typedef std::vector<ConstraintLine>::const_iterator const_iterator;
+
+
+  /**
+   * Typedef for the return type used by get_lines().
+   */
+  typedef boost::iterator_range<const_iterator> 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 <code>[this->begin(),
+   * this->end())</code> of line entries.
+   */
+  const LineRange get_lines() const;
+
 
   /**
    * Exception
index f9aa08942c468db113cbc4f1d00c25b66d30ce30..b00e08cee61389fd0c1c28843ecae344943ce96d 100644 (file)
@@ -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<size_type> &lines)
 {

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.