From 45934bd2369a259c8bb9f100822e6cf6c5048777 Mon Sep 17 00:00:00 2001 From: bangerth Date: Sat, 13 Nov 2010 01:01:55 +0000 Subject: [PATCH] Make sure we can compare iterator objects. git-svn-id: https://svn.dealii.org/trunk@22715 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/grid/tria_accessor.h | 10 +++++++ .../deal.II/grid/tria_accessor.templates.h | 30 +++++++++++++++++++ tests/deal.II/dof_accessor_01.cc | 2 ++ 3 files changed, 42 insertions(+) diff --git a/deal.II/include/deal.II/grid/tria_accessor.h b/deal.II/include/deal.II/grid/tria_accessor.h index 829bc179fe..b47a171b48 100644 --- a/deal.II/include/deal.II/grid/tria_accessor.h +++ b/deal.II/include/deal.II/grid/tria_accessor.h @@ -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; + /** * @} */ diff --git a/deal.II/include/deal.II/grid/tria_accessor.templates.h b/deal.II/include/deal.II/grid/tria_accessor.templates.h index 21455826f1..e9068436ac 100644 --- a/deal.II/include/deal.II/grid/tria_accessor.templates.h +++ b/deal.II/include/deal.II/grid/tria_accessor.templates.h @@ -2083,6 +2083,36 @@ TriaAccessor<0, 1, spacedim>::operator -- () const +template +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 +inline +bool +TriaAccessor<0, 1, spacedim>::operator != (const TriaAccessor &t) const +{ + return !(*this==t); +} + + + + template inline int diff --git a/tests/deal.II/dof_accessor_01.cc b/tests/deal.II/dof_accessor_01.cc index 5b38de4862..16dfac678b 100644 --- a/tests/deal.II/dof_accessor_01.cc +++ b/tests/deal.II/dof_accessor_01.cc @@ -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()); } -- 2.39.5