From: Wolfgang Bangerth Date: Wed, 12 May 2004 15:05:22 +0000 (+0000) Subject: Rename the Table::clear function to Table::reset_entries to make its intent clearer. X-Git-Tag: v8.0.0~15183 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=472af764837c8b6875c7bcbb0399f2ab355a3697;p=dealii.git Rename the Table::clear function to Table::reset_entries to make its intent clearer. git-svn-id: https://svn.dealii.org/trunk@9238 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/table.h b/deal.II/base/include/base/table.h index eb4ae087e0..b1a17c19cf 100644 --- a/deal.II/base/include/base/table.h +++ b/deal.II/base/include/base/table.h @@ -773,9 +773,10 @@ class TableBase : public Subscriptor * Set all entries to their * default value (i.e. copy them * over with default constructed - * objects). + * objects). Do not change the + * size of the table, though. */ - void clear (); + void reset_values (); /** * Set the dimensions of this @@ -1960,7 +1961,7 @@ TableBase::operator = (const TableBase& m) template inline void -TableBase::clear () +TableBase::reset_values () { if (n_elements() != 0) std::fill_n (val, n_elements(), T()); @@ -1993,7 +1994,7 @@ TableBase::reinit (const TableIndices &new_sizes) table_size = TableIndices(); return; - }; + } // if new size is nonzero: // if necessary allocate @@ -2005,11 +2006,23 @@ TableBase::reinit (const TableIndices &new_sizes) val_size = new_size; val = new T[val_size]; - }; + } // reinitialize contents of old or - // new memory. - clear (); + // new memory. note that we + // actually need to do this here, + // even in the case that we + // reallocated memory, since per + // C++ standard, clause 5.3.4/15 + // the newly allocated objects are + // only default initialized by + // operator new[] if they are + // non-POD type. In other words, if + // we have a table of doubles, then + // their values after calling 'new + // double[val_size]' is + // indetermined. + reset_values (); } diff --git a/deal.II/lac/include/lac/block_sparse_matrix.templates.h b/deal.II/lac/include/lac/block_sparse_matrix.templates.h index 73b80067ac..50bec5d1aa 100644 --- a/deal.II/lac/include/lac/block_sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/block_sparse_matrix.templates.h @@ -95,7 +95,8 @@ BlockSparseMatrix:: reinit (const BlockSparsityPattern &sparsity) { // first delete previous content of - // the subobjects array + // the subobjects array and delete + // the table completely for (unsigned int r=0; r DeclException0 (ExcSourceEqualsDestination); friend class Accessor; - - private: - void clear (); }; /*@}*/ diff --git a/deal.II/lac/source/block_sparsity_pattern.cc b/deal.II/lac/source/block_sparsity_pattern.cc index 092d1ca3c5..18667288b2 100644 --- a/deal.II/lac/source/block_sparsity_pattern.cc +++ b/deal.II/lac/source/block_sparsity_pattern.cc @@ -68,7 +68,9 @@ BlockSparsityPatternBase:: reinit (const unsigned int n_block_rows, const unsigned int n_block_columns) { - // delete previous content + // delete previous content and + // clean the sub_objects array + // completely for (unsigned int i=0; i