From 49a1ae2ee1e95ca6310fcefbac14f16fcff6c2b9 Mon Sep 17 00:00:00 2001 From: FeatherAntennae Date: Sat, 2 Nov 2024 13:52:33 -0400 Subject: [PATCH] Simplified iterators using operator<=> --- .../Discregrid/mesh/entity_iterators.hpp | 35 +++---------------- 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/discregrid/include/Discregrid/mesh/entity_iterators.hpp b/discregrid/include/Discregrid/mesh/entity_iterators.hpp index a14ea5e..8c18625 100755 --- a/discregrid/include/Discregrid/mesh/entity_iterators.hpp +++ b/discregrid/include/Discregrid/mesh/entity_iterators.hpp @@ -13,7 +13,6 @@ class TriangleMesh; class FaceContainer; class FaceIterator { public: - // ITERATOR TRAITS ------------------------------- /// One of the @link iterator_tags tag types@endlink. typedef std::random_access_iterator_tag iterator_category; @@ -33,12 +32,7 @@ class FaceIterator { reference operator*(); - bool operator<(_Mytype const &other) const { return m_index < other.m_index; } - bool operator==(_Mytype const &other) const { - return m_index == other.m_index; - } - - bool operator!=(_Mytype const &other) const { return !(*this == other); } + auto operator<=>(const _Mytype &other) const { return m_index <=> other.m_index; } inline _Mytype &operator++() { ++m_index; @@ -70,9 +64,9 @@ class FaceIterator { unsigned int m_index; TriangleMesh *m_mesh; }; + class FaceConstIterator { public: - // ITERATOR TRAITS ------------------------------- /// One of the @link iterator_tags tag types@endlink. typedef std::random_access_iterator_tag iterator_category; @@ -92,12 +86,7 @@ class FaceConstIterator { reference operator*(); - bool operator<(_Mytype const &other) const { return m_index < other.m_index; } - bool operator==(_Mytype const &other) const { - return m_index == other.m_index; - } - - bool operator!=(_Mytype const &other) const { return !(*this == other); } + auto operator<=>(const _Mytype &other) const { return m_index <=> other.m_index; } inline _Mytype &operator++() { ++m_index; @@ -134,7 +123,6 @@ class IncidentFaceContainer; class IncidentFaceIterator { public: - // ITERATOR TRAITS ------------------------------- /// One of the @link iterator_tags tag types@endlink. typedef std::forward_iterator_tag iterator_category; @@ -148,7 +136,6 @@ class IncidentFaceIterator { typedef Halfedge &reference; // ----------------------------------------------- - typedef IncidentFaceIterator _Mytype; value_type operator*() { return m_h; } @@ -170,7 +157,6 @@ class VertexContainer; class VertexIterator { public: - // ITERATOR TRAITS ------------------------------- /// One of the @link iterator_tags tag types@endlink. typedef std::random_access_iterator_tag iterator_category; @@ -184,19 +170,13 @@ class VertexIterator { typedef Eigen::Vector3d &reference; // ----------------------------------------------- - typedef VertexIterator _Mytype; VertexIterator() = delete; reference operator*(); - bool operator<(_Mytype const &other) const { return m_index < other.m_index; } - bool operator==(_Mytype const &other) const { - return m_index == other.m_index; - } - - bool operator!=(_Mytype const &other) const { return !(*this == other); } + auto operator<=>(const _Mytype &other) const { return m_index <=> other.m_index; } inline _Mytype &operator++() { ++m_index; @@ -251,12 +231,7 @@ class VertexConstIterator { reference operator*(); - bool operator<(_Mytype const &other) const { return m_index < other.m_index; } - bool operator==(_Mytype const &other) const { - return m_index == other.m_index; - } - - bool operator!=(_Mytype const &other) const { return !(*this == other); } + auto operator<=>(const _Mytype &other) const { return m_index <=> other.m_index; } inline _Mytype &operator++() { ++m_index;