]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Make sure we can compare iterator objects.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 13 Nov 2010 01:01:55 +0000 (01:01 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 13 Nov 2010 01:01:55 +0000 (01:01 +0000)
git-svn-id: https://svn.dealii.org/trunk@22715 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/grid/tria_accessor.h
deal.II/include/deal.II/grid/tria_accessor.templates.h
tests/deal.II/dof_accessor_01.cc

index 829bc179fe7ce527618fa5c34ea73334471ba194..b47a171b4828686b6fbd79f954d83e5947b923de 100644 (file)
@@ -1776,6 +1776,16 @@ class TriaAccessor<0, 1, spacedim>
                                      *  iterators.
                                      */
     void operator -- () const;
+                                    /**
+                                     *  Compare for equality.
+                                     */
+    bool operator == (const TriaAccessor &) const;
+
+                                    /**
+                                     * Compare for inequality.
+                                     */
+    bool operator != (const TriaAccessor &) const;
+
                                     /**
                                      * @}
                                      */
index 21455826f1b0db98e220a6e2c292cd356d39f9e9..e9068436acec3ce4c01781a8bca43d4feab1d13a 100644 (file)
@@ -2083,6 +2083,36 @@ TriaAccessor<0, 1, spacedim>::operator -- () const
 
 
 
+template <int spacedim>
+inline
+bool
+TriaAccessor<0, 1, spacedim>::operator == (const TriaAccessor &t) const
+{
+  const bool result = ((tria == t.tria)
+                      &&
+                      (global_vertex_index == t.global_vertex_index));
+                                  // if we point to the same vertex,
+                                  // make sure we know the same about
+                                  // it
+  if (result == true)
+    Assert (vertex_kind == t.vertex_kind, ExcInternalError());
+
+  return result;
+}
+
+
+
+template <int spacedim>
+inline
+bool
+TriaAccessor<0, 1, spacedim>::operator != (const TriaAccessor &t) const
+{
+  return !(*this==t);
+}
+
+
+
+
 template <int spacedim>
 inline
 int
index 5b38de4862dcc455d6873e01789f4497612ea96b..16dfac678b1897c8eb865f20b07ba4db4cf54bd2 100644 (file)
@@ -55,6 +55,8 @@ void test ()
     face = dof_handler.begin_active()->face(0);
   face = cell->face(0);
   deallog << cell->face(0) << ' ' << face << std::endl;
+  Assert (cell->face(0) == face, ExcInternalError());
+  Assert (!(cell->face(0) != face), ExcInternalError());
 }
 
 

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.