Skip to content

Commit

Permalink
STYLE: Replace postfix with prefix increment, decrement (++, --)
Browse files Browse the repository at this point in the history
Applied to the root of ITK source tree, at the GNU bash prompt:

    find . \( -iname itk*.cxx -or -iname itk*.hxx -or -iname itk*.h \) -exec perl -pi -w -e 's/  (\w+)\+\+;/  ++$1;/g;' {} \;
    find . \( -iname itk*.cxx -or -iname itk*.hxx -or -iname itk*.h \) -exec perl -pi -w -e 's/  (\w+)\-\-;/  --$1;/g;' {} \;

Excluded itkConceptChecking.h, as it is intended to check both the prefix *and*
the postfix forms. Excluded the unit tests, as they might intentionally test
the postfix forms.

Follow-up to:
pull request #2493
commit f81578b
"STYLE: Replace postfix by prefix increment in `for` loops in Core/Common"
  • Loading branch information
N-Dekker authored and hjmjohnson committed Jul 14, 2022
1 parent 73e883d commit ec510c1
Show file tree
Hide file tree
Showing 225 changed files with 705 additions and 705 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ template <typename TTreeType>
auto
ChildTreeIterator<TTreeType>::Next() -> const ValueType &
{
m_ListPosition++;
++m_ListPosition;
this->m_Position = m_ParentNode->GetChild(m_ListPosition);
if (this->m_Position == nullptr)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ InOrderTreeIterator<TTreeType>::FindNextNode() const
{
return help;
}
childPosition++;
++childPosition;
}

while (parent->HasParent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ LevelOrderTreeIterator<TTreeType>::GetLevel() const
while (node->HasParent() && node != this->m_Root)
{
node = dynamic_cast<TreeNodeType *>(node->GetParent());
level++;
++level;
}
return level;
}
Expand All @@ -178,7 +178,7 @@ LevelOrderTreeIterator<TTreeType>::GetLevel(const TreeNodeType * node) const
while (node->HasParent() && node != this->m_Root)
{
node = dynamic_cast<const TreeNodeType *>(node->GetParent());
level++;
++level;
}
return level;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ PostOrderTreeIterator<TTreeType>::FindSister(TreeNodeType * node) const
{
if (parent->GetChild(childPosition + 1) == nullptr)
{
childPosition++;
++childPosition;
}
else
{
Expand Down Expand Up @@ -206,7 +206,7 @@ PostOrderTreeIterator<TTreeType>::FindMostRightLeaf(TreeNodeType * node) const
itkGenericExceptionMacro(<< "Can't downcast to TreeNodeType *");
}
}
i++;
++i;
} while (helpNode == nullptr && i < childCount);

if (helpNode == nullptr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ PreOrderTreeIterator<TTreeType>::FindNextNode() const
{
return help;
}
childPosition++;
++childPosition;
}
}
return nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ TreeContainer<TValue>::Count() const
it.GoToBegin();
while (!it.IsAtEnd())
{
size++;
++size;
++it;
}
return size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ TreeIteratorBase<TTreeType>::Count()
}
while (this->Next())
{
size++;
++size;
}
return size;
}
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkAnnulusOperator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ AnnulusOperator<TPixel, TDimension, TAllocator>::GenerateCoefficients() -> Coeff
coeffP[i] = annulusV;
sumNotExterior += annulusV;
sumNotExteriorSq += (annulusV * annulusV);
countNotExterior++;
++countNotExterior;
outside[i] = false;
}
else
Expand All @@ -149,7 +149,7 @@ AnnulusOperator<TPixel, TDimension, TAllocator>::GenerateCoefficients() -> Coeff
coeffP[i] = interiorV;
sumNotExterior += interiorV;
sumNotExteriorSq += (interiorV * interiorV);
countNotExterior++;
++countNotExterior;
outside[i] = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkBoundingBox.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ BoundingBox<TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer>::IsI
{
return false;
}
i++;
++i;
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,26 @@ class ITK_TEMPLATE_EXPORT ConstShapedNeighborhoodIterator : private Neighborhood
void
operator++(int)
{
m_ListIterator++;
++m_ListIterator;
}

void
operator--(int)
{
m_ListIterator--;
--m_ListIterator;
}

const ConstIterator &
operator++()
{
m_ListIterator++;
++m_ListIterator;
return *this;
}

const ConstIterator &
operator--()
{
m_ListIterator--;
--m_ListIterator;
return *this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::ActivateIndex(Neigh
{
while (n > *it)
{
it++;
++it;
if (it == m_ActiveIndexList.end())
{
break;
Expand Down Expand Up @@ -96,7 +96,7 @@ ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::DeactivateIndex(Nei
{
while (n != *it)
{
it++;
++it;
if (it == m_ActiveIndexList.end())
{
return;
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkConstSliceIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ConstSliceIterator
ConstSliceIterator
operator++()
{
m_Pos++;
++m_Pos;
return *this;
}

Expand All @@ -93,7 +93,7 @@ class ConstSliceIterator
{
ConstSliceIterator ans = *this;

m_Pos++;
++m_Pos;
return ans;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ template <typename TStructureType>
void
CorrespondenceDataStructureIterator<TStructureType>::GoToNext()
{
m_CorrespondingListIterator++;
++m_CorrespondingListIterator;

if (m_CorrespondingListIterator == m_CorrespondingListPointer->end())
{
Expand All @@ -63,15 +63,15 @@ template <typename TStructureType>
void
CorrespondenceDataStructureIterator<TStructureType>::GoToNextBaseGroup()
{
m_SecondaryListIterator++;
++m_SecondaryListIterator;
if (m_SecondaryListIterator != m_SecondaryListPointer->end())
{
m_CorrespondingListPointer = &(*m_SecondaryListIterator);
m_CorrespondingListIterator = m_CorrespondingListPointer->begin();
}
else if (m_SecondaryListIterator == m_SecondaryListPointer->end())
{
m_NodeListIterator++;
++m_NodeListIterator;

if (m_NodeListIterator != m_NodeListPointer->end())
{
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkExtractImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ ExtractImageFilter<TInputImage, TOutputImage>::SetExtractionRegion(InputImageReg
{
outputSize[nonzeroSizeCount] = inputSize[i];
outputIndex[nonzeroSizeCount] = extractRegion.GetIndex()[i];
nonzeroSizeCount++;
++nonzeroSizeCount;
}
}

Expand Down Expand Up @@ -194,7 +194,7 @@ ExtractImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()
++nonZeroCount2;
}
}
nonZeroCount++;
++nonZeroCount;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ ExtractImageFilterCopyRegion(const typename BinaryUnsignedIntDispatch<T1, T2>::F
{
destIndex[dim] = srcIndex[count];
destSize[dim] = srcSize[count];
count++;
++count;
}
}
destRegion.SetIndex(destIndex);
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkImageConstIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class ITK_TEMPLATE_EXPORT ImageConstIterator
ind[i] += (static_cast<IndexValueType>(size[i]) - 1);
}
m_EndOffset = m_Image->ComputeOffset(ind);
m_EndOffset++;
++m_EndOffset;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class ITK_TEMPLATE_EXPORT ImageRandomConstIteratorWithIndex : public ImageConstI
operator++()
{
this->RandomJump();
m_NumberOfSamplesDone++;
++m_NumberOfSamplesDone;
return *this;
}

Expand All @@ -200,7 +200,7 @@ class ITK_TEMPLATE_EXPORT ImageRandomConstIteratorWithIndex : public ImageConstI
operator--()
{
this->RandomJump();
m_NumberOfSamplesDone--;
--m_NumberOfSamplesDone;
return *this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class ITK_TEMPLATE_EXPORT ImageRandomConstIteratorWithOnlyIndex : public ImageCo
operator++()
{
this->RandomJump();
m_NumberOfSamplesDone++;
++m_NumberOfSamplesDone;
return *this;
}

Expand All @@ -202,7 +202,7 @@ class ITK_TEMPLATE_EXPORT ImageRandomConstIteratorWithOnlyIndex : public ImageCo
operator--()
{
this->RandomJump();
m_NumberOfSamplesDone--;
--m_NumberOfSamplesDone;
return *this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class ITK_TEMPLATE_EXPORT ImageRandomNonRepeatingConstIteratorWithIndex : public
Self &
operator++()
{
m_NumberOfSamplesDone++;
++m_NumberOfSamplesDone;
this->UpdatePosition();
return *this;
}
Expand All @@ -317,7 +317,7 @@ class ITK_TEMPLATE_EXPORT ImageRandomNonRepeatingConstIteratorWithIndex : public
Self &
operator--()
{
m_NumberOfSamplesDone--;
--m_NumberOfSamplesDone;
this->UpdatePosition();
return *this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ MersenneTwisterRandomVariateGenerator::Initialize(const IntegerType seed)
for (i = 1; i < MersenneTwisterRandomVariateGenerator::StateVectorLength; ++i)
{
*s++ = (1812433253UL * (*r ^ (*r >> 30)) + i) & 0xffffffffUL;
r++;
++r;
}
reload();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ printnb(const TIteratorType & nb, bool full)
if ((count % sz) == 0)
std::cout << std::endl;
++it;
count++;
++count;
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkOctree.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Octree<TPixel, ColorTableSize, MappingFunctionType>::BuildFromBuffer(const void
while (width < maxSize)
{
width *= 2;
depth++;
++depth;
}
this->SetDepth(depth);
this->SetWidth(width);
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkShapedNeighborhoodIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ namespace itk
*
\code
i = it.End();
i--;
--i;
while (i != it.Begin())
{
i.Set(i.Get() + 1.0);
i--;
--i;
}
i.Set(i.Get() + 1.0);
\endcode
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkSimpleFilterWatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class ITKCommon_EXPORT SimpleFilterWatcher
if (m_Process)
{
std::lock_guard<std::mutex> outputSerializer(m_ProgressOutput);
m_Steps++;
++m_Steps;
if (!m_Quiet)
{
std::cout << " | " << m_Process->GetProgress() << std::flush;
Expand Down Expand Up @@ -231,7 +231,7 @@ class ITKCommon_EXPORT SimpleFilterWatcher
ShowIteration()
{
std::cout << " #" << std::flush;
m_Iterations++;
++m_Iterations;
}

/** Callback method to show the StartEvent */
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkSliceIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class SliceIterator
SliceIterator
operator++()
{
m_Pos++;
++m_Pos;
return *this;
}

Expand All @@ -89,7 +89,7 @@ class SliceIterator
{
SliceIterator ans = *this;

m_Pos++;
++m_Pos;
return ans;
}

Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkSobelOperator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ SobelOperator<TPixel, VDimension, TAllocator>::Fill(const CoefficientVector & co
pos = center + z * this->GetStride(2) + y * this->GetStride(1) + x * this->GetStride(0);
this->operator[](pos) = static_cast<TPixel>(coeff[i]);

i++;
++i;
}
}
}
Expand All @@ -61,7 +61,7 @@ SobelOperator<TPixel, VDimension, TAllocator>::Fill(const CoefficientVector & co
pos = center + y * this->GetStride(1) + x * this->GetStride(0);
this->operator[](pos) = static_cast<TPixel>(coeff[i]);

i++;
++i;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkSparseFieldLayer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ SparseFieldLayer<TNodeType>::SplitRegions(int num) const -> RegionListType
region.first = position;
while ((j < regionsize) && (position != last))
{
j++;
++j;
++position;
}
region.last = position;
Expand Down
Loading

0 comments on commit ec510c1

Please sign in to comment.