getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] (no subject)


From: Andriy Andreykiv
Subject: [Getfem-commits] (no subject)
Date: Mon, 18 Mar 2019 06:54:26 -0400 (EDT)

branch: upgrading_getfem_to_cpp14
commit cead721abe2c3fa0ebbf32654e8df732e01fce6e
Author: aa <address@hidden>
Date:   Mon Mar 18 11:54:14 2019 +0100

    more concise comparison
---
 src/getfem/bgeot_rtree.h | 44 ++++++--------------------------------------
 1 file changed, 6 insertions(+), 38 deletions(-)

diff --git a/src/getfem/bgeot_rtree.h b/src/getfem/bgeot_rtree.h
index 630d030..d26f5f8 100644
--- a/src/getfem/bgeot_rtree.h
+++ b/src/getfem/bgeot_rtree.h
@@ -48,42 +48,10 @@ namespace bgeot {
     base_node min, max;
   };
 
-  /** Wraps "const box_index *" but overloads
-   *  comparison operators based on id and not
-   *  addresses. This ensures deterministic ordering in sets.
-   */
-  struct box_index_ptr {
-    box_index_ptr(const box_index *p)
-      : p_{p}
-    {}
-
-    box_index_ptr(const box_index_ptr&) = default;
-
-    bool operator < (const box_index_ptr &bptr) const {
-      return p_->id < bptr.p_->id;
-    }
-
-    bool operator == (const box_index_ptr &bptr) const {
-      return p_->id == bptr.p_->id;
-    }
-
-    bool operator != (const box_index_ptr &bptr) const {
-      return !(*this == bptr);
+  struct box_index_compare {
+    bool operator()(const box_index *plhs, const box_index *prhs) const {
+      return plhs->id < prhs->id;
     }
-
-    operator const box_index *() const {
-      return p_;
-    }
-
-    const box_index * operator->() const {
-      return p_;
-    }
-
-    const box_index& operator*() const {
-      return *p_;
-    }
-
-    const box_index *p_;
   };
 
   struct rtree_elt_base {
@@ -103,9 +71,9 @@ namespace bgeot {
    */
   class rtree {
   public:
-    typedef std::deque<box_index> box_cont;
-    typedef std::vector<const box_index*> pbox_cont;
-    typedef std::set<box_index_ptr> pbox_set;
+    using box_cont = std::deque<box_index> ;
+    using pbox_cont = std::vector<const box_index*>;
+    using pbox_set = std::set<const box_index *, box_index_compare>;
 
     rtree() = default;
     rtree(const rtree&) = delete;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]