]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add operator<() functions to TriaAccessor<0,*,structdim> classes.
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 20 Nov 2018 15:57:50 +0000 (08:57 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 20 Nov 2018 15:57:50 +0000 (08:57 -0700)
include/deal.II/grid/tria_accessor.h
include/deal.II/grid/tria_accessor.templates.h

index 4124892bbf7464c0c60c186ee9fc744fb9325327..fba857e4d717cce2512e53e0c7e9a95033a2e441 100644 (file)
@@ -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;
+
   /**
    * @}
    */
index bbb44552b7faeaefcd01fb5d7e7a6bf4a0849dc8..03fa332247bcc7dd2e57b4d1cdac32b5265b9b33 100644 (file)
@@ -2297,6 +2297,18 @@ TriaAccessor<0, dim, spacedim>::copy_from(const TriaAccessor &t)
 
 
 
+template <int dim, int spacedim>
+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 <int dim, int spacedim>
 inline IteratorState::IteratorStates
 TriaAccessor<0, dim, spacedim>::state() const
@@ -2681,6 +2693,18 @@ TriaAccessor<0, 1, spacedim>::copy_from(const TriaAccessor &t)
 
 
 
+template <int spacedim>
+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 <int spacedim>
 inline IteratorState::IteratorStates
 TriaAccessor<0, 1, spacedim>::state()

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.