From b8fcb573a0c15a9ccda539b42ad4429cf6173a17 Mon Sep 17 00:00:00 2001 From: emv Date: Fri, 18 Oct 2019 14:35:24 +0300 Subject: [PATCH] Using size_t instead of int (where possible) in INTERP_KERNEL. --- src/INTERP_KERNEL/DirectedBoundingBox.cxx | 6 +++--- .../InterpKernelGeo2DAbstractEdge.cxx | 4 ++-- src/INTERP_KERNEL/Interpolation1D0D.cxx | 4 ++-- src/INTERP_KERNEL/Interpolation3D1D.cxx | 4 ++-- .../InterpolationPlanarTestSuite.hxx | 16 ++++++++-------- src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx | 2 +- src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx | 8 ++++---- src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx | 12 ++++++------ src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx | 2 +- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/INTERP_KERNEL/DirectedBoundingBox.cxx b/src/INTERP_KERNEL/DirectedBoundingBox.cxx index 8c06642f9..3fdf8ce06 100644 --- a/src/INTERP_KERNEL/DirectedBoundingBox.cxx +++ b/src/INTERP_KERNEL/DirectedBoundingBox.cxx @@ -617,7 +617,7 @@ namespace INTERP_KERNEL getCorners( corners, &cornerBox->_minmax[0] ); double globCorner[3]; - for ( int iC = 0, nC = corners.size()/_dim; iC < nC; ++iC) + for ( std::size_t iC = 0, nC = corners.size()/_dim; iC < nC; ++iC) { cornerBox->fromLocalCS( &corners[iC*_dim], globCorner ); mmBox.addPointToBox( globCorner ); @@ -649,7 +649,7 @@ namespace INTERP_KERNEL getCorners( cornersOther, box ); DirectedBoundingBox mmBox((double*)0,0,_dim); //!< empty box with CS == this->_axes mmBox._axes = this->_axes; - for ( int iC = 0, nC = cornersOther.size()/_dim; iC < nC; ++iC) + for ( std::size_t iC = 0, nC = cornersOther.size()/_dim; iC < nC; ++iC) mmBox.addPointToBox( &cornersOther[iC*_dim] ); if ( isMinMaxOut( &mmBox._minmax[0], &this->_minmax[0], _dim )) @@ -662,7 +662,7 @@ namespace INTERP_KERNEL getCorners( cornersThis, &_minmax[0] ); DirectedBoundingBox mmBox((double*)0,0,_dim); //!< initailized _minmax double globCorner[3]; - for ( int iC = 0, nC = cornersThis.size()/_dim; iC < nC; ++iC) + for ( std::size_t iC = 0, nC = cornersThis.size()/_dim; iC < nC; ++iC) { fromLocalCS( &cornersThis[iC*_dim], globCorner ); for ( int i = 0; i < (int)_dim; ++i ) diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx index 2c5551988..bd12d34fd 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx @@ -107,11 +107,11 @@ void IteratorOnComposedEdge::insertElemEdges(ComposedEdge *elems, bool changeMyS *_deep_it=*iter; _deep_it++; iter++; - int sizeOfMyList=myListToInsert->size(); + std::size_t sizeOfMyList=myListToInsert->size(); _list_handle->insert(_deep_it,iter,myListToInsert->end()); if(!changeMySelf) { - for(int i=0;i::max(); for(int idim=0; idim deque1, std::deque< double > deque2, double epsilon) { - int size1 = deque1.size(); - int size2 = deque2.size(); + std::size_t size1 = deque1.size(); + std::size_t size2 = deque2.size(); bool are_equal = size1 == size2; if(are_equal) - for(int i = 0; i < size1 && are_equal; i++) + for(std::size_t i = 0; i < size1 && are_equal; i++) are_equal = fabs(deque1[i] - deque2[i]) < epsilon; return are_equal; @@ -72,19 +72,19 @@ namespace INTERP_TEST bool checkVectorsEqual(std::vector< double > vect1, std::vector< double > vect2, double epsilon) { - int size1 = vect1.size(); - int size2 = vect2.size(); + std::size_t size1 = vect1.size(); + std::size_t size2 = vect2.size(); bool are_equal = size1 == size2; if(are_equal) - for(int i = 0; i < size1 && are_equal; i++) + for(std::size_t i = 0; i < size1 && are_equal; i++) are_equal = fabs(vect1[i] - vect2[i]) < epsilon; return are_equal; } void dequePrintOut(std::deque< double > deque1) { - for(int i = 0; i< (int)deque1.size(); i++) + for(std::size_t i = 0; i< deque1.size(); i++) { std::cerr << deque1[i] << " "; } @@ -92,7 +92,7 @@ namespace INTERP_TEST } void vectPrintOut(std::vector< double > vect) { - for(int i = 0; i< (int)vect.size(); i++) + for(std::size_t i = 0; i< vect.size(); i++) { std::cerr << vect[i] << " "; } diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx index 1ee95f1ae..91184f47a 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx @@ -1629,7 +1629,7 @@ MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DTetraTargetMesh(const double i int MEDCouplingBasicsTest::countNonZero(const std::vector< std::map >& matrix) { - int ret=0.; + int ret=0; for(std::vector< std::map >::const_iterator iter=matrix.begin();iter!=matrix.end();iter++) for(std::map::const_iterator iter2=(*iter).begin();iter2!=(*iter).end();iter2++) if (!INTERP_KERNEL::epsilonEqual((*iter2).second, 0.)) ret +=1; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx index 65b3a6c5e..bcaf814dc 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx @@ -1219,7 +1219,7 @@ void MEDCouplingBasicsTest1::testFindCommonNodes() // targetMesh=build3DTargetMesh_1(); bool areNodesMerged; - unsigned int time=targetMesh->getTimeOfThis(); + std::size_t time=targetMesh->getTimeOfThis(); o2n=targetMesh->mergeNodes(1e-10,areNodesMerged,newNbOfNodes); targetMesh->updateTime(); CPPUNIT_ASSERT(time==targetMesh->getTimeOfThis()); @@ -1818,7 +1818,7 @@ void MEDCouplingBasicsTest1::testOperationsOnFields3() void MEDCouplingBasicsTest1::testOperationsOnFields4() { MEDCouplingUMesh *m=build2DTargetMesh_1(); - int nbOfCells=m->getNumberOfCells(); + std::size_t nbOfCells=m->getNumberOfCells(); MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,CONST_ON_TIME_INTERVAL); f1->setMesh(m); DataArrayDouble *array=DataArrayDouble::New(); @@ -2234,13 +2234,13 @@ void MEDCouplingBasicsTest1::testGetValueOn1() { MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); MEDCouplingFieldDouble *fieldOnCells=MEDCouplingFieldDouble::New(ON_CELLS); - int nbOfCells=targetMesh->getNumberOfCells(); + std::size_t nbOfCells=targetMesh->getNumberOfCells(); fieldOnCells->setMesh(targetMesh); DataArrayDouble *array=DataArrayDouble::New(); array->alloc(nbOfCells,2); fieldOnCells->setArray(array); double *tmp=array->getPointer(); - for(int i=0;idecrRef(); // diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx index 8fdca210a..cd7ca7559 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx @@ -636,8 +636,8 @@ void MEDCouplingBasicsTest2::testRenumberCellsForFields() MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); f->setMesh(m); DataArrayDouble *arr=DataArrayDouble::New(); - int nbOfCells=m->getNumberOfCells(); - arr->alloc(nbOfCells,3); + + arr->alloc(m->getNumberOfCells(),3); f->setArray(arr); arr->decrRef(); const double values1[15]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.}; @@ -883,13 +883,13 @@ void MEDCouplingBasicsTest2::testCheckGeoEquivalWith() bool isExcep=false; try { mesh1->checkGeoEquivalWith(mesh2,0,1e-12,cellCor,nodeCor);//deepEqual fails } - catch(INTERP_KERNEL::Exception& e) { isExcep=true; } + catch(INTERP_KERNEL::Exception&) { isExcep=true; } CPPUNIT_ASSERT(isExcep); isExcep=false; CPPUNIT_ASSERT(cellCor==0); CPPUNIT_ASSERT(nodeCor==0); try { mesh1->checkGeoEquivalWith(mesh2,1,1e-12,cellCor,nodeCor);//fastEqual has detected something } - catch(INTERP_KERNEL::Exception& e) { isExcep=true; } + catch(INTERP_KERNEL::Exception&) { isExcep=true; } CPPUNIT_ASSERT(isExcep); isExcep=false; CPPUNIT_ASSERT(cellCor==0); CPPUNIT_ASSERT(nodeCor==0); @@ -931,7 +931,7 @@ void MEDCouplingBasicsTest2::testCheckGeoEquivalWith2() void MEDCouplingBasicsTest2::testCopyTinyStringsFromOnFields() { MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); - int nbOfCells=m->getNumberOfCells(); + std::size_t nbOfCells=m->getNumberOfCells(); MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME); f->setMesh(m); CPPUNIT_ASSERT_EQUAL(5,f->getNumberOfMeshPlacesExpected()); @@ -1107,7 +1107,7 @@ void MEDCouplingBasicsTest2::testChangeUnderlyingMesh1() void MEDCouplingBasicsTest2::testGetMaxValue1() { MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); - int nbOfCells=m->getNumberOfCells(); + std::size_t nbOfCells=m->getNumberOfCells(); MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME); f->setMesh(m); DataArrayDouble *a1=DataArrayDouble::New(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx index 550dfd02e..743fef5d5 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx @@ -734,7 +734,7 @@ void MEDCouplingBasicsTest4::testGetValueOn2() MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); f->setMesh(m); DataArrayDouble *arr=DataArrayDouble::New(); - int nbOfCells=m->getNumberOfCells(); + std::size_t nbOfCells=m->getNumberOfCells(); arr->alloc(nbOfCells,3); f->setArray(arr); arr->decrRef(); -- 2.39.2