]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add empty() function to deal.II/lac/vector.h and use it instead of size() == 0 17644/head
authorFernando Herrera <cafeherval@gmail.com>
Tue, 13 Aug 2024 20:14:08 +0000 (14:14 -0600)
committerFernando Herrera <cafeherval@gmail.com>
Sun, 1 Sep 2024 19:48:16 +0000 (13:48 -0600)
Co-authored-by: Sanjeeb Poudel <paudelsanjeeb@gmail.com>
examples/step-28/step-28.cc
examples/step-39/step-39.cc
include/deal.II/lac/vector.h
source/numerics/data_out_stack.cc

index 4b3452850a41355799714b7b889ff029404b2f60..e0e55e9ccd00a7f671dce073b745d1e5c61ff935 100644 (file)
@@ -591,7 +591,7 @@ namespace Step28
 
     system_rhs.reinit(n_dofs);
 
-    if (solution.size() == 0)
+    if (solution.empty())
       {
         solution.reinit(n_dofs);
         solution_old.reinit(n_dofs);
index 48227bb32bf1b93df61cdb1ba0be08d461a42618..d7f2b54eefe2e7c84251a323d5dfceec76249dbb 100644 (file)
@@ -1010,7 +1010,7 @@ namespace Step39
     for (unsigned int s = 0; s < n_steps; ++s)
       {
         deallog << "Step " << s << std::endl;
-        if (estimates.block(0).size() == 0)
+        if (estimates.block(0).empty())
           triangulation.refine_global(1);
         else
           {
index b385674b8707bd2698b0450922565d3ad0699a6e..fbd184ab71c4732fd164b45488350f633122ec67 100644 (file)
@@ -287,6 +287,13 @@ public:
    */
   virtual ~Vector() override = default;
 
+
+  /**
+   * This function is equivalent to writing <code>size() == 0</code>.
+   */
+  bool
+  empty() const;
+
   /**
    * This function does nothing but exists for compatibility with the parallel
    * vector classes.
@@ -1392,6 +1399,12 @@ Vector<Number>::operator!=(const Vector<Number2> &v) const
 }
 
 
+template <typename Number>
+inline bool
+Vector<Number>::empty() const
+{
+  return this->size() == 0;
+}
 
 template <typename Number>
 inline void
index e64b1f5f3dea4b051666fe42f76ce185335168b6..ed293102c4938658f60730d187ad1ae15abfe66e 100644 (file)
@@ -60,11 +60,11 @@ DataOutStack<dim, spacedim>::new_parameter_value(const double p,
   for (typename std::vector<DataVector>::const_iterator i = dof_data.begin();
        i != dof_data.end();
        ++i)
-    Assert(i->data.size() == 0, ExcDataNotCleared());
+    Assert(i->data.empty(), ExcDataNotCleared());
   for (typename std::vector<DataVector>::const_iterator i = cell_data.begin();
        i != cell_data.end();
        ++i)
-    Assert(i->data.size() == 0, ExcDataNotCleared());
+    Assert(i->data.empty(), ExcDataNotCleared());
 }
 
 

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.