Boost logo

Boost Users :

Subject: [Boost-users] Graph Library Random Access Iterators?
From: Theodore McCormack (guzbit_at_[hidden])
Date: 2010-03-06 07:21:03


Hello all,
I am trying to iterate through a list of edges in the boost graph library,
but i would like to advance more than one at a time or be able to use random
access to an edge in the set. For example:

Currently, to find the edge at index in the edge set I have to iterate
through all the edges:

Edge e;
int count = 0;
for (edge_range_t er = edges(graph); er.first != er.second; er.first++)
{
e = (*er.first);
if (count == index)
 break;
count++;
}
return e;

I would like something like:

Edge e;
edge_range_t er = edges(graph);
e = (*er[index].first);
return e;

Is there a way to index with iterators?

Regards



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net