map<int,string> mp;
mp.insert(pair<int,string>(1,"testOne"));
struct Node
{
int id;
string cnt;
}
vector<Node> vec;
vec.push_back(Node(1,"testOne"))
我觉得这两者妹啥区别,vector我还用得更熟练一点
map<int,string> mp;
mp.insert(pair<int,string>(1,"testOne"));
struct Node
{
int id;
string cnt;
}
vector<Node> vec;
vec.push_back(Node(1,"testOne"))
我觉得这两者妹啥区别,vector我还用得更熟练一点
这两个容器底层的数据结构不同,而且两个容器的一些操作不能共用。比如map不能用push_back,vector不能直接用find操作,需要用到算法的find函数