C++ 如何在c++;
我有以下形式的一系列地图:C++ 如何在c++;,c++,C++,我有以下形式的一系列地图: std::map<std::string, std::vector<std::string>> result[SIZE] 只需循环遍历数组中的所有maps,如下所示: int i = 0; for (; i < SIZE; ++i) { auto it = result[i].find(value); if (it != result[i].end() { // you've found value
std::map<std::string, std::vector<std::string>> result[SIZE]
只需循环遍历数组中的所有
map
s,如下所示:
int i = 0;
for (; i < SIZE; ++i) {
auto it = result[i].find(value);
if (it != result[i].end() {
// you've found value in result[i] at iterator it
}
}
inti=0;
对于(;i
毫不奇怪,它是访问数组中的元素和访问映射中的元素的组合。您声明“在此映射内”,但它是大小不同的映射。您是否通过说“此”映射来假设result[]数组中的所有映射的键都是唯一的?它实际上是大小不同的、完全独立的映射。
int i = 0;
for (; i < SIZE; ++i) {
auto it = result[i].find(value);
if (it != result[i].end() {
// you've found value in result[i] at iterator it
}
}