[Insight-users] STL vector iterator

FREDERICPCX FREDERICPCX at terra.es
Wed Aug 11 10:56:49 EDT 2004


Hello Zein,

if your vector is called v, maybe you can simply use something like
the following:

if (distance(v.begin(), iter1) < distance(v.begin(), iter2) { ...

Beware that calling some methods on the STL containers can invalidate
their related iterators. More in Chapter 23 of the 1997 C++ Public
Review Document: http://anubis.dkuug.dk/jtc1/sc22/open/n2356/

Hope this helps,

Frederic

----- Mensaje Original -----
De: "salah" <salah at gris.uni-tuebingen.de>
Fecha: Miercoles, Agosto 11, 2004 4:38 pm
Asunto: [Insight-users] STL vector iterator

> Hello,
> 
> I am using two iterators to point to two different positions on an STL
> vector. I want to decide which iterator is advancing more that the 
> other.is it meaningful to just compare the two iterator? i.e. 
> something like this
> 
>   typedef std::vector< ...... > VectorType;
>   VectorType::iterator  iter1, iter2;
>   ....
>   ....
>   if (iter1  < iter2) {
>      ....
>      ....
>   } 
> 
> or something else is needed. This comparison does not seem 
> to work by me.
> 
> Thanks,
> Zein
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 




More information about the Insight-users mailing list