1

Topic: Update of elements using STL

How to update elements using map or set containers? We assume there is a considerable quantity of elements. Or them to update in a range or to update all at once.

2

Re: Update of elements using STL

It is clear nothing. Decrypt more in detail where elements are stored and that with them it is necessary to make.

3

Re: Update of elements using STL

Really, not clearly. Well can be transform or for_each

4

Re: Update of elements using STL

Let's admit in a database at me there are elements which I want to delete

typedef std:: map <std:: string, float> StringFloatMap;
StringFloatMap coll;
StringFloatMap:: iterator pos;
for (pos = coll.begin (); pos! =coll.end () ;) {
if (pos-> second == value) {
coll.erase (pos ++);
} else {++ pos;}
}

And before deleting I want to update

5

Re: Update of elements using STL

If speech about that that before element removal it is necessary to send any request to a DB it is better to send at once "pack" of requests so fulfills than on one faster.

6

Re: Update of elements using STL

And if I take and I interpose the list into the list

list2.splice (find (list2.begin (), list2.end (), X1), list1);

7

Re: Update of elements using STL

benao wrote:

and if I take and I interpose the list into the list

list2.splice (find (list2.begin (), list2.end (), X1), list1);

If you work with a database that you work with a database. All yours  in storage it only the CACHE of the data. And as you manipulate this cache - only you know.

8

Re: Update of elements using STL

for (auto& element:container) element.update ();

or if to speak about map element will be std:: pair and to elements it will be necessary to address as to.first and.second