T
Tony Young
Hi,
I have a multimap container. I want to eliminate all "duplicate"
elements. By duplicate I mean something like (3, 4), (4, 3) and (4, 3),
in which I want to eliminate any two of these three. The most
straightforward way I can think of is to first swap every member such
that every member has its key smaller than its value. Then loop thru
the multipmap and erase duplicates (please see the loop below). Is
there a more automatic way to achieve this? Thanks for any input.
// swap first
.....
//
for (it=m.begin(); it!=m.end()
{
IT itUB = m.upper_bound(it->first);
copy(it, itUB, inserter(mAux, mAux.begin()));
it = itUB;
}
m.swap(mAux);
Tony
I have a multimap container. I want to eliminate all "duplicate"
elements. By duplicate I mean something like (3, 4), (4, 3) and (4, 3),
in which I want to eliminate any two of these three. The most
straightforward way I can think of is to first swap every member such
that every member has its key smaller than its value. Then loop thru
the multipmap and erase duplicates (please see the loop below). Is
there a more automatic way to achieve this? Thanks for any input.
// swap first
.....
//
for (it=m.begin(); it!=m.end()
{
IT itUB = m.upper_bound(it->first);
copy(it, itUB, inserter(mAux, mAux.begin()));
it = itUB;
}
m.swap(mAux);
Tony