Skip to content

Commit

Permalink
Make atEnd iterators equally regardless of positions.
Browse files Browse the repository at this point in the history
  • Loading branch information
timspainNERSC committed Nov 21, 2024
1 parent 502e126 commit 1af53fd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions core/src/include/Slice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ class SliceIter {
if (m_slice.n() != other.m_slice.n())
return false;
const size_t ndim = m_slice.n();
// if only one isEnd, then the iterators cannot be equal
if (isEnd() != other.isEnd())
return false;
for (size_t dim = 0; dim < ndim; ++dim) {
// Dimension length must match
if (m_dimensions[dim] != other.m_dimensions[dim])
Expand All @@ -121,9 +124,11 @@ class SliceIter {
return false;
if (m_slice.bounds[dim].step != other.m_slice.bounds[dim].step)
return false;
// Position must match
if (current[dim] != other.current[dim])
return false;
// Position must match, if we are not at the end
if (!isEnd()) {
if (current[dim] != other.current[dim])
return false;
}
}
return true;
}
Expand Down

0 comments on commit 1af53fd

Please sign in to comment.