]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Copy data inside the vector
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 4 Dec 2013 12:37:13 +0000 (12:37 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 4 Dec 2013 12:37:13 +0000 (12:37 +0000)
git-svn-id: https://svn.dealii.org/trunk@31875 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/constraint_matrix.templates.h

index 177580497bbfb36ce73a7ec91bee6cd741c92053..9566ded08346e267dc74406df0f5e4f131bbad71 100644 (file)
@@ -1307,14 +1307,17 @@ namespace internals
       const size_type my_length = individual_size[index];
       if (my_length == row_length)
         {
-          // no space left, need to double row_length
-          std::vector<std::pair<size_type,double> >
-            new_data(2*individual_size.size()*row_length*2);
-          for (size_type i=0; i<individual_size.size(); ++i)
-            std::copy(&data[i*row_length], &data[i*row_length]+
-                      individual_size[i],
-                      &new_data[i*row_length*2]);
-          data.swap(new_data);
+          AssertDimension(data.size(), individual_size.size()*row_length);
+          // no space left in this row, need to double row_length and
+          // rearrange the data items
+          data.resize(2*data.size());
+          for (size_type i=individual_size.size(); i>0; )
+            {
+              --i;
+              std::move_backward(&data[i*row_length],
+                                 &data[i*row_length]+individual_size[i],
+                                 &data[i*row_length*2]+individual_size[i]);
+            }
           row_length *= 2;
         }
       data[index*row_length+my_length] = pair;

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.