Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: Prefer explicit const designation #7

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Modules/Core/Common/include/itkDerivativeOperator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ DerivativeOperator<TPixel, VDimension, TAllocator>::GenerateCoefficients() -> Co
unsigned int j = 1;
for (; j < w - 1; ++j)
{
PixelRealType next = coeff[j - 1] + coeff[j + 1] - 2 * coeff[j];
const PixelRealType next = coeff[j - 1] + coeff[j + 1] - 2 * coeff[j];
coeff[j - 1] = previous;
previous = next;
}
PixelRealType next = coeff[j - 1] - 2 * coeff[j];
const PixelRealType next = coeff[j - 1] - 2 * coeff[j];
coeff[j - 1] = previous;
coeff[j] = next;
}
Expand All @@ -50,11 +50,11 @@ DerivativeOperator<TPixel, VDimension, TAllocator>::GenerateCoefficients() -> Co
unsigned int j = 1;
for (; j < w - 1; ++j)
{
PixelRealType next = -0.5 * coeff[j - 1] + 0.5 * coeff[j + 1];
const PixelRealType next = -0.5 * coeff[j - 1] + 0.5 * coeff[j + 1];
coeff[j - 1] = previous;
previous = next;
}
PixelRealType next = -0.5 * coeff[j - 1];
const PixelRealType next = -0.5 * coeff[j - 1];
coeff[j - 1] = previous;
coeff[j] = next;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ FloodFilledSpatialFunctionConditionalConstIterator<TImage, TFunction>::IsPixelIn
IndexType tempIndex;
for (unsigned int i = 0; i < dim; ++i)
{
unsigned int counterCopy = counter;
const unsigned int counterCopy = counter;
tempIndex[i] = index[i] + static_cast<int>((counterCopy >> i) & 0x0001);
}

Expand Down Expand Up @@ -164,7 +164,7 @@ FloodFilledSpatialFunctionConditionalConstIterator<TImage, TFunction>::IsPixelIn
IndexType tempIndex;
for (unsigned int i = 0; i < dim; ++i)
{
unsigned int counterCopy = counter;
const unsigned int counterCopy = counter;
tempIndex[i] = index[i] + static_cast<int>((counterCopy >> i) & 0x0001);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ itkArchetypeSeriesFileNamesTest(int argc, char * argv[])
fit->SetArchetype(archetype);
ITK_TEST_SET_GET_VALUE(archetype, fit->GetArchetype());

std::vector<std::string> names = fit->GetFileNames();
const std::vector<std::string> names = fit->GetFileNames();

std::cout << "List of returned filenames: " << std::endl;
for (auto & name : names)
Expand Down
2 changes: 1 addition & 1 deletion Modules/IO/Meta/src/itkMetaImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ MetaImageIO::WriteImageInformation()

// Save out the metadatadictionary key/value pairs as part of
// the metaio header.
std::vector<std::string> keys = metaDict.GetKeys();
const std::vector<std::string> keys = metaDict.GetKeys();
for (auto & key : keys)
{
if (key == ITK_ExperimentDate || key == ITK_VoxelUnits)
Expand Down
4 changes: 2 additions & 2 deletions Modules/Numerics/Statistics/include/itkHistogram.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ Histogram<TMeasurement, TFrequencyContainer>::GetIndex(const MeasurementVectorTy

for (unsigned int dim = 0; dim < measurementVectorSize; ++dim)
{
MeasurementType tempMeasurement = measurement[dim];
IndexValueType begin = 0;
const MeasurementType tempMeasurement = measurement[dim];
IndexValueType begin = 0;
if (tempMeasurement < m_Min[dim][begin])
{
// one of measurement is below the minimum
Expand Down
31 changes: 16 additions & 15 deletions Modules/Numerics/Statistics/include/itkStatisticsAlgorithm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -558,19 +558,19 @@ DownHeap(TSubsample * sample, unsigned int activeDimension, int beginIndex, int
while (true)
{
// location of first child
int largerChild = beginIndex + 2 * (currentNode - beginIndex) + 1;
int leftChild = largerChild;
int rightChild = leftChild + 1;
int largerChild = beginIndex + 2 * (currentNode - beginIndex) + 1;
const int leftChild = largerChild;
const int rightChild = leftChild + 1;
if (leftChild > endIndex - 1)
{
// leaf node
return;
}

const auto initValue = sample->GetMeasurementVectorByIndex(leftChild)[activeDimension];
SampleMeasurementType leftChildValue = initValue;
SampleMeasurementType rightChildValue = initValue;
SampleMeasurementType largerChildValue = initValue;
const auto initValue = sample->GetMeasurementVectorByIndex(leftChild)[activeDimension];
const SampleMeasurementType leftChildValue = initValue;
SampleMeasurementType rightChildValue = initValue;
SampleMeasurementType largerChildValue = initValue;

if (rightChild < endIndex)
{
Expand Down Expand Up @@ -633,14 +633,15 @@ IntrospectiveSortLoop(TSubsample * sample,
}

--depthLimit;
int cut = Partition<TSubsample>(sample,
activeDimension,
beginIndex,
endIndex,
MedianOfThree<SampleMeasurementType>(
sample->GetMeasurementVectorByIndex(beginIndex)[activeDimension],
sample->GetMeasurementVectorByIndex(beginIndex + length / 2)[activeDimension],
sample->GetMeasurementVectorByIndex(endIndex - 1)[activeDimension]));
const int cut =
Partition<TSubsample>(sample,
activeDimension,
beginIndex,
endIndex,
MedianOfThree<SampleMeasurementType>(
sample->GetMeasurementVectorByIndex(beginIndex)[activeDimension],
sample->GetMeasurementVectorByIndex(beginIndex + length / 2)[activeDimension],
sample->GetMeasurementVectorByIndex(endIndex - 1)[activeDimension]));
IntrospectiveSortLoop<TSubsample>(sample, activeDimension, cut, endIndex, depthLimit, sizeThreshold);
endIndex = cut;
length = endIndex - beginIndex;
Expand Down
Loading