From a784dd0c67f6a8c73bbb41efefac74b9e06d736c Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 19 Dec 2016 15:50:20 -0700 Subject: [PATCH] Let IndexSet::nth_index_within_set() call compress(). This follows the pattern of all other const functions of the class. --- doc/news/changes/minor/20161219Bangerth | 6 ++++++ include/deal.II/base/index_set.h | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 doc/news/changes/minor/20161219Bangerth diff --git a/doc/news/changes/minor/20161219Bangerth b/doc/news/changes/minor/20161219Bangerth new file mode 100644 index 0000000000..94887e2bd7 --- /dev/null +++ b/doc/news/changes/minor/20161219Bangerth @@ -0,0 +1,6 @@ +
  • Changed: IndexSet::nth_index_in_set() can now be called without + calling IndexSet::compress() first. +
    + (Wolfgang Bangerth, 2016/12/19) +
  • + diff --git a/include/deal.II/base/index_set.h b/include/deal.II/base/index_set.h index cc3caf0170..67dd11a99c 100644 --- a/include/deal.II/base/index_set.h +++ b/include/deal.II/base/index_set.h @@ -1604,11 +1604,10 @@ inline IndexSet::size_type IndexSet::nth_index_in_set (const unsigned int n) const { - // to make this call thread-safe, compress() must not be called through this - // function - Assert (is_compressed == true, ExcMessage ("IndexSet must be compressed.")); Assert (n < n_elements(), ExcIndexRangeType (n, 0, n_elements())); + compress (); + // first check whether the index is in the largest range Assert (largest_range < ranges.size(), ExcInternalError()); std::vector::const_iterator main_range=ranges.begin()+largest_range; -- 2.39.5