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

Gaetan Lehmann gaetan.lehmann at jouy.inra.fr
Mon Jun 6 04:25:50 EDT 2005


On Fri, 03 Jun 2005 18:12:01 +0200, Brad King <brad.king at kitware.com>  
wrote:

> Miller, James V (Research) wrote:
>> For storage and searching lexicographically, I can understand the  
>> motivation.  But since it does not have a geometic meaning, I hesitate  
>> to put it into Index.  The whole purpose of Index to provide a link  
>> between a geometric space and the linear address
>> space an image uses to store its pixels.
>>  Can we provide function objects (that people will have to go out
>> of their way to use) to provide a lexicographically ordering of Indices?
>
> Sure:
>
> template <unsigned int VDimension>
> struct IndexLexicographicCompare
> {
>    bool operator()(Index<VDimension> const& l,
>                    Index<VDimension> const& r) const
>      {
>      ...
>      }
> };
>
> std::set< Index<D>, IndexLexicographicCompare<D> > myIndexSet;
>

It's a little bit more complicated than with operator<, but it's more  
simple than nothing, and the name clearly define for what it is defined :-)

Is it possible to define the type in Index ? So we can use it like :

std::set< IndexType, IndexType::LexicographicCompare > myIndexSet;

-- 
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