]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix (Dynamic)?SparsityPattern::begin() for empty sparsity patterns.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 1 Nov 2018 14:22:40 +0000 (08:22 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 1 Nov 2018 14:22:40 +0000 (08:22 -0600)
include/deal.II/lac/dynamic_sparsity_pattern.h
include/deal.II/lac/sparsity_pattern.h

index 4e21e2a9e4cafe925807b6e791b0e6cd0fe104fd..d05dac7efae0833d276a6906c0d730ef6e3695d3 100644 (file)
@@ -1037,7 +1037,10 @@ DynamicSparsityPattern::column_number(const size_type row,
 inline DynamicSparsityPattern::iterator
 DynamicSparsityPattern::begin() const
 {
-  return begin(0);
+  if (n_rows() > 0)
+    return begin(0);
+  else
+    return end();
 }
 
 
index 3caaa9d4a78e71565d7d308958668b419153fb44..12c729bc7ccdab7ed9baae48b1e1010b74c264de 100644 (file)
@@ -1254,7 +1254,10 @@ namespace SparsityPatternIterators
 inline SparsityPattern::iterator
 SparsityPattern::begin() const
 {
-  return iterator(this, rowstart[0]);
+  if (n_rows() > 0)
+    return iterator(this, rowstart[0]);
+  else
+    return end();
 }
 
 
@@ -1262,7 +1265,10 @@ SparsityPattern::begin() const
 inline SparsityPattern::iterator
 SparsityPattern::end() const
 {
-  return iterator(this, rowstart[rows]);
+  if (n_rows() > 0)
+    return iterator(this, rowstart[rows]);
+  else
+    return iterator(nullptr, 0);
 }
 
 

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.