From: apo Date: Fri, 22 Jul 2005 16:12:28 +0000 (+0000) Subject: To implement operator < in order to provide lexicographical comparision of std::set... X-Git-Tag: BR-D5-38-2003_D2005-12-09~151 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b9656e3a030dbe4f967f454c57ae8cc27db03cf6;p=modules%2Fvisu.git To implement operator < in order to provide lexicographical comparision of std::set container for defined SharedPtr instances --- diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index ee0b46e8..39c5b5e9 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -132,13 +132,10 @@ namespace VISU{ //--------------------------------------------------------------- - struct TSubProfileLess - { - bool - operator()(const PSubProfile& theLeft, const PSubProfile& theRight) const; - }; + bool + operator<(const PSubProfile& theLeft, const PSubProfile& theRight); - typedef std::set TProfileKey; + typedef std::set TProfileKey; typedef std::map TProfileMap; @@ -161,13 +158,10 @@ namespace VISU{ //--------------------------------------------------------------- - struct TGaussSubMeshLess - { - bool - operator()(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight) const; - }; + bool + operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight); - typedef std::set TGaussKey; + typedef std::set TGaussKey; typedef std::map TGaussMeshMap; diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 9670e120..341c70f3 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -128,12 +128,13 @@ namespace VISU //--------------------------------------------------------------- bool - TSubProfileLess - ::operator()(const PSubProfile& theLeft, const PSubProfile& theRight) const + operator<(const PSubProfile& theLeft, const PSubProfile& theRight) { PSubProfileImpl aLeft(theLeft), aRight(theRight); + if(aLeft->myGeom != aRight->myGeom) return aLeft->myGeom < aRight->myGeom; + return aLeft->myName < aRight->myName; } @@ -156,8 +157,7 @@ namespace VISU //--------------------------------------------------------------- bool - TGaussSubMeshLess:: - operator()(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight) const + operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight) { PGaussImpl aLeft(theLeft->myGauss), aRight(theRight->myGauss); @@ -167,7 +167,7 @@ namespace VISU if(aLeft->myName != aRight->myName) return aLeft->myName < aRight->myName; - return TSubProfileLess()(theLeft->mySubProfile,theRight->mySubProfile); + return theLeft->mySubProfile < theRight->mySubProfile; }