Skip to content

Commit 47106cb

Browse files
fix iterator comparison
1 parent 7e31693 commit 47106cb

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

include/osp/graph_implementations/eigen_matrix_adapter/eigen_sparse_iterator.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ class EigenCSRRange {
7272
return temp;
7373
}
7474

75-
bool operator==(const Iterator &other) const {return it_ == other.it_;}
76-
bool operator!=(const Iterator &other) const { return not (*this == other);}
75+
inline bool operator==(const Iterator &other) const {
76+
return (it_ && other.it_ && it_.index() == other.it_.index()) || ((not it_) && (not other.it_));
77+
}
78+
79+
inline bool operator!=(const Iterator &other) const { return not(*this == other); }
7780
};
7881

7982
EigenCSRRange(const Graph &graph, EigenIdxType idx) : graph_(graph), index_(idx) {}
@@ -132,8 +135,11 @@ class EigenCSCRange {
132135
return temp;
133136
}
134137

135-
bool operator==(const Iterator &other) const {return it_ == other.it_;}
136-
bool operator!=(const Iterator &other) const { return not (*this == other);}
138+
inline bool operator==(const Iterator &other) const {
139+
return (it_ && other.it_ && it_.index() == other.it_.index()) || ((not it_) && (not other.it_));
140+
}
141+
142+
inline bool operator!=(const Iterator &other) const { return not(*this == other); }
137143
};
138144

139145
EigenCSCRange(const Graph &graph, EigenIdxType idx) : graph_(graph), index_(idx) {}

0 commit comments

Comments
 (0)