Skip to content

Commit

Permalink
Simplified iterators using operator<=>
Browse files Browse the repository at this point in the history
  • Loading branch information
FeatherAntennae committed Nov 2, 2024
1 parent fbb97ad commit 49a1ae2
Showing 1 changed file with 5 additions and 30 deletions.
35 changes: 5 additions & 30 deletions discregrid/include/Discregrid/mesh/entity_iterators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -148,7 +136,6 @@ class IncidentFaceIterator {
typedef Halfedge &reference;
// -----------------------------------------------


typedef IncidentFaceIterator _Mytype;

value_type operator*() { return m_h; }
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 49a1ae2

Please sign in to comment.