From: Wolfgang Bangerth Date: Thu, 1 Nov 2018 14:22:40 +0000 (-0600) Subject: Fix (Dynamic)?SparsityPattern::begin() for empty sparsity patterns. X-Git-Tag: v9.1.0-rc1~583^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4b5322c8fb33e007001b3d151d5ac0f7f0c8002;p=dealii.git Fix (Dynamic)?SparsityPattern::begin() for empty sparsity patterns. --- diff --git a/include/deal.II/lac/dynamic_sparsity_pattern.h b/include/deal.II/lac/dynamic_sparsity_pattern.h index 4e21e2a9e4..d05dac7efa 100644 --- a/include/deal.II/lac/dynamic_sparsity_pattern.h +++ b/include/deal.II/lac/dynamic_sparsity_pattern.h @@ -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(); } diff --git a/include/deal.II/lac/sparsity_pattern.h b/include/deal.II/lac/sparsity_pattern.h index 3caaa9d4a7..12c729bc7c 100644 --- a/include/deal.II/lac/sparsity_pattern.h +++ b/include/deal.II/lac/sparsity_pattern.h @@ -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); }