]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce a flag is_compressed.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 15 Oct 2009 20:25:37 +0000 (20:25 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 15 Oct 2009 20:25:37 +0000 (20:25 +0000)
git-svn-id: https://svn.dealii.org/trunk@19890 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/index_set.h
deal.II/base/source/index_set.cc

index a9afa1a03443b2aa1ac3727a1521b2a411abb452..0a565c5b5b8b09248256b0324ddaffa5b9a9a7ce 100644 (file)
@@ -181,6 +181,21 @@ class IndexSet
                                      */
     mutable std::set<Range, RangeComparison> ranges;
 
+                                    /**
+                                     * True if compress() has been
+                                     * called after the last change
+                                     * in the set of indices.
+                                     *
+                                     * The variable is marked
+                                     * "mutable" so that it can be
+                                     * changed by compress(), though
+                                     * this of course doesn't change
+                                     * anything about the external
+                                     * representation of this index
+                                     * set.
+                                     */
+    mutable bool is_compressed;
+
                                     /**
                                      * The overall size of the index
                                      * range. Elements of this index
@@ -210,6 +225,7 @@ IndexSet::RangeComparison::operator() (const Range &range_1,
 inline
 IndexSet::IndexSet ()
                :
+               is_compressed (true),
                index_space_size (0)
 {}
 
@@ -218,6 +234,7 @@ IndexSet::IndexSet ()
 inline
 IndexSet::IndexSet (const unsigned int size)
                :
+               is_compressed (true),
                index_space_size (size)
 {}
 
@@ -231,6 +248,7 @@ IndexSet::set_size (const unsigned int sz)
          ExcMessage ("This function can only be called if the current "
                      "object does not yet contain any elements."));
   index_space_size = sz;
+  is_compressed = true;
 }
 
 
@@ -256,7 +274,10 @@ IndexSet::add_range (const unsigned int begin,
          ExcIndexRange (begin, 0, end));
 
   if (begin != end)
-    ranges.insert (Range(begin,end));
+    {
+      ranges.insert (Range(begin,end));
+      is_compressed = false;
+    }
 }
 
 
@@ -269,6 +290,7 @@ IndexSet::add_index (const unsigned int index)
          ExcIndexRange (index, 0, index_space_size));
 
   ranges.insert (Range(index, index+1));
+  is_compressed = false;
 }
 
 
index 8838800216a7939368d40c6a895b0b2ecaebd069..3b24d4136036ea6a184b4057193112bc8bd47225 100644 (file)
@@ -18,6 +18,8 @@ DEAL_II_NAMESPACE_OPEN
 void
 IndexSet::compress () const
 {
+  if (is_compressed == true)
+    return;
                                   // see if any of the
                                   // contiguous ranges can be
                                   // merged. since they are sorted by
@@ -73,6 +75,8 @@ IndexSet::compress () const
                                        last_index));
        }
     }
+
+  is_compressed = true;
 }
 
 

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.