|
Boost Users : |
From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2005-04-21 20:21:05
On Apr 9, 2005, at 8:12 PM, qyang_at_[hidden] wrote:
> EdgeDescriptor Edge;
> Edge = *(edges(G).first + n); //n is an int
> remove_edge(Edge, G);
> ==================================================
>
> I got compilation errors at line "Edge = *(edges(G).first + n);".
>
> I have to use the following code in order to compile the code and to
> run
> it correctly:
> ==================================================
> //typedef stuff
> ...
>
> EdgeDescriptor Edge;
> EdgeIterator edge_iter;
> edge_iter = edges(G).first;
> for(int i = 0; i < n; i++) {
> edge_iter++;}
> Edge = *edge_iter;
> remove_edge(Edge, G);
> ==================================================
>
> Basically, you have to use a for() loop to increment the edge_iterator
> varialbe. Is it possible just to use one addition(the first code)
> instead
> of n additions(the second code) to increment the iterator?
Not in general. You can use std::advance(edge_iter, n); to move
edge_iter forward n steps.
Doug
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