【发布时间】:2013-08-08 16:09:45
【问题描述】:
我有一个结构向量如下
struct myStruct{
size_t aID;
int bID;
double tobeUpdated;
};
std::vector<myStruct> myVec;
如何在 C++11 中高效地查找和更新满足 aID == someId && bID == otherID 的 myVec 成员?
【问题讨论】:
-
向量排序了吗?
-
好吧,你可能被线性搜索困住了。
-
您要更新多少个元素?最多一个?还是不止一个?
-
最多有一个元素需要更新。