From: Wolfgang Bangerth Date: Tue, 20 Nov 2018 15:57:50 +0000 (-0700) Subject: Add operator<() functions to TriaAccessor<0,*,structdim> classes. X-Git-Tag: v9.1.0-rc1~547^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10a5fff580cb5bc5d72cca3da0c0ce5f9ecba0f4;p=dealii.git Add operator<() functions to TriaAccessor<0,*,structdim> classes. --- diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index 4124892bbf..fba857e4d7 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -360,10 +360,14 @@ protected: operator=(const TriaAccessorBase &); /** - * Ordering of accessors. If #structure_dimension is less than #dimension, - * we simply compare the index of such an object. If #structure_dimension - * equals #dimension, we compare the level() first, and the index() only if - * levels are equal. + * Comparison operator for accessors. This operator is used when comparing + * iterators into objects of a triangulation, for example when putting + * them into a `std::map`. + * + * If #structure_dimension is less than #dimension, we simply compare the + * index of such an object because faces and edges do not have levels. If + * #structure_dimension equals #dimension, we compare the level first, and + * the index only if levels are equal. */ bool operator<(const TriaAccessorBase &other) const; @@ -2065,6 +2069,17 @@ protected: void copy_from(const TriaAccessor &); + /** + * Comparison operator for accessors. This operator is used when comparing + * iterators into objects of a triangulation, for example when putting + * them into a `std::map`. + * + * This operator simply compares the global index of the vertex the + * current object points to. + */ + bool + operator<(const TriaAccessor &other) const; + /** * Pointer to the triangulation we operate on. */ @@ -2257,6 +2272,17 @@ public: bool operator!=(const TriaAccessor &) const; + /** + * Comparison operator for accessors. This operator is used when comparing + * iterators into objects of a triangulation, for example when putting + * them into a `std::map`. + * + * This operator simply compares the global index of the vertex the + * current object points to. + */ + bool + operator<(const TriaAccessor &other) const; + /** * @} */ diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index bbb44552b7..03fa332247 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -2297,6 +2297,18 @@ TriaAccessor<0, dim, spacedim>::copy_from(const TriaAccessor &t) +template +inline bool +TriaAccessor<0, dim, spacedim>:: +operator<(const TriaAccessor<0, dim, spacedim> &other) const +{ + Assert(tria == other.tria, TriaAccessorExceptions::ExcCantCompareIterators()); + + return (global_vertex_index < other.global_vertex_index); +} + + + template inline IteratorState::IteratorStates TriaAccessor<0, dim, spacedim>::state() const @@ -2681,6 +2693,18 @@ TriaAccessor<0, 1, spacedim>::copy_from(const TriaAccessor &t) +template +inline bool +TriaAccessor<0, 1, spacedim>:: +operator<(const TriaAccessor<0, 1, spacedim> &other) const +{ + Assert(tria == other.tria, TriaAccessorExceptions::ExcCantCompareIterators()); + + return (global_vertex_index < other.global_vertex_index); +} + + + template inline IteratorState::IteratorStates TriaAccessor<0, 1, spacedim>::state()