[Insight-users] Defining a map of IndexTypes

Luis Ibanez luis.ibanez at kitware.com
Tue Oct 27 22:10:55 EDT 2009


Hi Matthias,

You are mis-constructing the map type.

The code that you need is like the following:

--------------------------------------------------------------------------
#include "itkImage.h"

template <class TImageType>
class TEST
{
typedef typename    TImageType::IndexType       IndexType;

struct ltstr
{
  bool operator()(const IndexType& lhs, const IndexType& rhs) const
    {
    //y1 is lower y2
    if(lhs[1]<rhs[1])return true;
    //y1==y2 and x1 < x2
    if((lhs[1]==rhs[1])&&(lhs[0]<rhs[0]))return true;
    //else
    return false;
    }
};


std::map<IndexType, bool, ltstr> recursionPoints;

};

int main()
{
return 0;
}



Note that the comparator, the third template argument
of the std::map is actually a class, that has a method
operator().

More at:
http://www.sgi.com/tech/stl/Map.html


      Regards,


             Luis


---------------------------------
On Tue, Oct 27, 2009 at 12:00 PM, Matthias Dodt
<matthias.dodt at mdc-berlin.de> wrote:
> Hi there!
>
> I want to store IndexTypes in a map (as keys). I got the following code:
>          ...
>
>           typedef typename    TImageType::IndexType       IndexType;
>
>           bool fless(const IndexType& lhs, const IndexType& rhs) const
>           {
>             //y1 is lower y2
>             if(lhs[1]<rhs[1])return true;
>             //y1==y2 and x1 < x2
>             if((lhs[1]==rhs[1])&&(lhs[0]<rhs[0]))return true;
>             //else
>             return false;
>           }
>
>           typedef bool (*comp_t)( IndexType const &, IndexType const & );
>
>           std::map<IndexType, bool, comp_t> recursionPoints(fless);
>
> ...
>
> Anyway- i get an error saying that fless has no type. I think the problem is
> that IndexType is a template type...
>
> thanks!
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list