in-place set_union/difference/etc ...
27 Feb
2002
27 Feb
'02
9:30 p.m.
Does anyone know of any existing standard tool [an insert iteartor or something equivalent] that can allow one to perform union, difference, etc on sets and maps in-place. E.g. instead of using set<MyClass> s1, s2, temp; set_union( s1.begin(), s1.end(), s2.begin(), s2.end(), inserter(temp, temp.begin())); temp.swap(s2); i'd like to do, say: copy(s1.begin(), s1.end(), my_unioner(s2, s2.begin())); which will do s2 = s1 + s2 in LINEAR time. It's pretty simple to write an inserter like that, but I am just wondering if there is one already ... or something similar. Thanks!
8308
Age (days ago)
8308
Last active (days ago)
0 comments
1 participants
participants (1)
-
ivan_dobrianov