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

Brad King brad.king at kitware.com
Tue Jun 7 09:17:24 EDT 2005


Gaetan Lehmann wrote:
> 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;

This is now implemented:

/cvsroot/Insight/Insight/Code/Common/itkIndex.h,v  <--  itkIndex.h
new revision: 1.50; previous revision: 1.49

I've added the typedef in Index also.

-Brad


More information about the Insight-developers mailing list