Skip to content

Commit

Permalink
ENH: Add cbegin() and cend() member functions to Index, Offset, Size
Browse files Browse the repository at this point in the history
Mirrored the corresponding member functions of `std::array`.

Following commit 549a19c "STYLE: Change aggregate classes to mirror std::array", Hans Johnson, 2018-02-12
  • Loading branch information
N-Dekker authored and hjmjohnson committed Mar 1, 2022
1 parent b85fc62 commit ef44e3f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Modules/Core/Common/include/itkIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ struct ITK_TEMPLATE_EXPORT Index final
std::swap(m_InternalArray, other.m_InternalArray);
}

const_iterator
cbegin() const
{
return &m_InternalArray[0];
}

iterator
begin()
{
Expand All @@ -358,6 +364,12 @@ struct ITK_TEMPLATE_EXPORT Index final
return &m_InternalArray[0];
}

const_iterator
cend() const
{
return &m_InternalArray[VDimension];
}

iterator
end()
{
Expand Down
12 changes: 12 additions & 0 deletions Modules/Core/Common/include/itkOffset.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ struct ITK_TEMPLATE_EXPORT Offset final
std::swap(m_InternalArray, other.m_InternalArray);
}

const_iterator
cbegin() const
{
return &m_InternalArray[0];
}

iterator
begin()
{
Expand All @@ -311,6 +317,12 @@ struct ITK_TEMPLATE_EXPORT Offset final
return &m_InternalArray[0];
}

const_iterator
cend() const
{
return &m_InternalArray[VDimension];
}

iterator
end()
{
Expand Down
12 changes: 12 additions & 0 deletions Modules/Core/Common/include/itkSize.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ struct ITK_TEMPLATE_EXPORT Size final
std::swap(m_InternalArray, other.m_InternalArray);
}

const_iterator
cbegin() const
{
return &m_InternalArray[0];
}

iterator
begin()
{
Expand All @@ -270,6 +276,12 @@ struct ITK_TEMPLATE_EXPORT Size final
return &m_InternalArray[0];
}

const_iterator
cend() const
{
return &m_InternalArray[VDimension];
}

iterator
end()
{
Expand Down

0 comments on commit ef44e3f

Please sign in to comment.