From: bangerth Date: Thu, 15 Oct 2009 20:21:01 +0000 (+0000) Subject: Add add_indices. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ec4e2e93737d3be0508778928256e64875cbfc5;p=dealii-svn.git Add add_indices. git-svn-id: https://svn.dealii.org/trunk@19888 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/index_set.h b/deal.II/base/include/base/index_set.h index 180fe7cf3e..a9afa1a034 100644 --- a/deal.II/base/include/base/index_set.h +++ b/deal.II/base/include/base/index_set.h @@ -85,6 +85,17 @@ class IndexSet */ void add_index (const unsigned int index); + /** + * Add a whole set of indices + * described by dereferencing + * every element of the the + * iterator range + * [begin,end). + */ + template + void add_indices (const ForwardIterator &begin, + const ForwardIterator &end); + /** * Return whether the specified * index is an element of the @@ -245,15 +256,7 @@ IndexSet::add_range (const unsigned int begin, ExcIndexRange (begin, 0, end)); if (begin != end) - { - // if it turns out to be a - // single element then add that - // separately - if (end == begin+1) - add_index (begin); - else - ranges.insert (Range(begin,end)); - } + ranges.insert (Range(begin,end)); } @@ -270,6 +273,35 @@ IndexSet::add_index (const unsigned int index) +template +inline +void +IndexSet::add_indices (const ForwardIterator &begin, + const ForwardIterator &end) +{ + // insert each element of the + // range. if some of them happen to + // be consecutive, merge them to a + // range + for (ForwardIterator p=begin; p