c++ - Find and update an element in C++11 vector of structs -


i have vector of struct follows

struct mystruct{     size_t aid;     int bid;     double tobeupdated; };  std::vector<mystruct> myvec; 

how can find , update member of myvec satisfies aid == someid && bid == otherid in efficient way in c++11?

assumes 1 updated.

// search size_t aid = 5; int bid = 7;  find_if(vec.begin(), vec.end(), [aid, bid](const mystruct& obj) { return obj.aid == aid && obj.bid == bid; }); 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -