[Insight-users] STL vector iterator
    Miller, James V (Research) 
    millerjv at crd.ge.com
       
    Wed Aug 11 12:13:35 EDT 2004
    
    
  
For iterators within vectors, I think it is safe to do
if (iter1 < iter2)
I don't think the original STL standard required that vectors be 
contiguous memory (though most implementations use contiguous memory
for vectors). I think their is proposal to the standards committee
to official state vectors will be contiguous memory.
Jim
-----Original Message-----
From: FREDERICPCX [mailto:FREDERICPCX at terra.es]
Sent: Wednesday, August 11, 2004 10:57 AM
To: salah
Cc: insight-users at itk.org
Subject: Re: [Insight-users] STL vector iterator
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
> 
_______________________________________________
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