[Insight-developers] add operator< and operator> support in itk::Index

Gaetan Lehmann gaetan.lehmann at jouy.inra.fr
Fri Jun 3 09:05:04 EDT 2005


Hi,

Is it possible to add support for < operator in Index class ? (and for >,  
to be consistent)
The goal is to be able to put Index objects in stl set without having to  
write extra code.

code to add can be :
   /** Compare two indices. */
   bool
   operator<(const Self &vec) const
     {
     for (unsigned int i=0; i < VIndexDimension; i++)
       {
          if (m_Index[i] < vec.m_Index[i])
            { return true; }
          else if (m_Index[i] > vec.m_Index[i])
            { return false; }
       }
     return false;
     }

Regards,

Gaetan

-- 
Gaetan Lehmann <gaetan.lehmann at jouy.inra.fr>
Tel: +33 1 34 65 29 66
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
Web: http://voxel.jouy.inra.fr


More information about the Insight-developers mailing list