Skip to content

Commit 3e5a75a

Browse files
committed
ENH: Add ComputeIndex() member function to ImageConstIterator
Provides an alternative to `ImageConstIterator::GetIndex()`, making it more clear that potentially expensive computation is involved.
1 parent 00844a2 commit 3e5a75a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Modules/Core/Common/include/itkImageConstIterator.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,16 +295,24 @@ class ITK_TEMPLATE_EXPORT ImageConstIterator
295295
return (m_Buffer + m_Offset) > (it.m_Buffer + it.m_Offset);
296296
}
297297

298-
/** Get the index. This provides a read only reference to the index.
299-
* This causes the index to be calculated from pointer arithmetic and is
300-
* therefore an expensive operation.
298+
/** Computes the index. Internally calls ImageBase::ComputeIndex, which may be a relatively expensive operation.
301299
* \sa SetIndex */
302300
[[nodiscard]] IndexType
303-
GetIndex() const
301+
ComputeIndex() const
304302
{
305303
return m_Image->ComputeIndex(m_Offset);
306304
}
307305

306+
/** Computes and returns the index. This may be a relatively expensive operation.
307+
* \note It is often preferable for users to call ComputeIndex() directly, to make it more clear that this function
308+
* may be expensive.
309+
* \sa ComputeIndex */
310+
[[nodiscard]] IndexType
311+
GetIndex() const
312+
{
313+
return this->ComputeIndex();
314+
}
315+
308316
/** Set the index. No bounds checking is performed.
309317
* \sa GetIndex */
310318
virtual void

0 commit comments

Comments
 (0)