]> https://gitweb.dealii.org/ - dealii.git/commitdiff
SparsityPattern::Iterator - add a constructor for initalizing an iterator from an...
authorMatthias Maier <tamiko@43-1.org>
Thu, 28 Feb 2019 20:23:12 +0000 (14:23 -0600)
committerMatthias Maier <tamiko@43-1.org>
Thu, 28 Feb 2019 20:23:12 +0000 (14:23 -0600)
When trying to increment a sparsity pattern iterator:

  auto iterator = sparsity_pattern.begin();
  iterator++;

The corresponding function in LinearIndexIterator:

  template <class DerivedIterator, class AccessorType>
  inline DerivedIterator
  LinearIndexIterator<DerivedIterator, AccessorType>::operator++(int)
  {
    const DerivedIterator copy(this->accessor);
    operator+=(1);
    return copy;
  }

creates a copy that is initialized by the accessor. Thus, we need a
constructor that can create an interator from an accessor.

include/deal.II/lac/sparsity_pattern.h

index 89c507a31e1643eb615d3a19d496f12bdddcd43b..573c6c29475bbe9c6fa533bada2c941c0d76f29e 100644 (file)
@@ -298,6 +298,12 @@ namespace SparsityPatternIterators
      * the zeroth row).
      */
     Iterator(const SparsityPattern *sp, const std::size_t linear_index);
+
+    /**
+     * Constructor. Create an iterator into the sparsity pattern @p sp for
+     * a given accessor.
+     */
+    Iterator(const Accessor &accessor);
   };
 } // namespace SparsityPatternIterators
 
@@ -1272,6 +1278,13 @@ namespace SparsityPatternIterators
                             const std::size_t      linear_index)
     : LinearIndexIterator<Iterator, Accessor>(Accessor(sp, linear_index))
   {}
+
+
+  inline Iterator::Iterator(const Accessor &accessor)
+    : LinearIndexIterator<Iterator, Accessor>(accessor)
+  {}
+
+
 } // namespace SparsityPatternIterators
 
 

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.