[Insight-developers] add operator< and
operator> support initk::Index
Gaetan Lehmann
gaetan.lehmann at jouy.inra.fr
Wed Jun 8 09:52:48 EDT 2005
On Tue, 07 Jun 2005 15:17:24 +0200, Brad King <brad.king at kitware.com>
wrote:
> 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
I use it, and everything is ok :-)
Thanks !
--
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