Is there a way to intersect/diff a std::map and a std::set?
Posted
by
Jack
on Stack Overflow
See other posts from Stack Overflow
or by Jack
Published on 2012-04-10T14:30:06Z
Indexed on
2012/04/10
17:29 UTC
Read the original article
Hit count: 167
I'm wondering if there a way to intersect or make the differences between two structures defined as std::set<MyData*>
and std::map<MyData*, MyValue>
with standard algorithms (like std::set_intersect
)
The problem is that I need to compute the difference between the set and the keyset of the map but I would like to avoid reallocating it (since it's something that is done many times per second with large data structures). Is there a way to obtain a "key view" of the std::map
? After all what I'm looking is to consider just the keys when doing the set operation so from an implementation point it should be possible but I haven't been able to find anything.
© Stack Overflow or respective owner