"John" <we**********@yahoo.com> wrote in message

news:11**********************@g14g2000cwa.googlegr oups.com...

stupid me. I was thinking if the sets were disjoint (non-overlapping).

You are absolutely right.

Here is a better formulation of my question, I have two maps M1,M2.

I would like to do the set_union type operation on it. I can of course

make a set and put the data inside it using pair. Any other ideas

on how to do this more naturally? can maps be unioned?

If you want the union to a separate set from M1 and M2, you can do the

following:

map<key, value, comp> M1plus2;

set_union(M1.begin(), M1.end(), M2.begin(), M2.end(), inserter(M1plus2,

M1plus2.end()), M1plus2.value_comp());

This finishes in O(M1.size() + M2.size()), because it always inserts new

elements at the end of the output map.

Joe Gottman