question about std::distance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm using gcc v3.4.2.

For the first time, I'm attempting to use std::distance and std::advance and am having trouble with at least std::distance.

Basically, I'm trying to deal with duplicates.
In the following code, I want to iterate thru just the non-duplicates.
In my test case, edges has a size of 47 and there are two sets of 4 duplicates each. So I want the for loop to execute 41 times.


typedef std::multiset<DataEdge,ltEdgeDescritor> Edges;
Edges edges;

<populate edges>

for(Edges::iterator iter=edges.begin();
iter!=edges.end(); advance(iter,distance(edges.lower_bound(*iter),edges.upper_bound(*iter)))
{
.....
}


What I find is that my program enters distance and doesn't leave.

Am I somehow misusing distance?

Can someone sugguest an alternate method for me to accomplish what I'm trying to do?


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux