0
我知道防止重复的好方法是使用unordered_set
。但是,当我想要一个unordered_set<vector<string>>
时,此方法似乎不起作用。我怎么能这样做呢?例如,我想阻止<"a", "b", "c">
在我的unordered_set<vector<string>>
中被复制。如何删除C++中类型向量<string>的重复项?
这个unordered_set<vector<string>>
可以在定义的类之外使用吗?
代码:
unordered_set<vector<string>> abc({"apple", "ball", "carrot"});
abc.insert({"apple", "ball", "carrot"});
cout << abc.size() << endl; //abc.size() should be 1
我想我必须自己定义一个散列?不知道该怎么做,虽然 –
你可以发布一个非常小的例子,它增加了{“a”,“b”,“c”}两次,并检查集的大小()? –
它不编译,因为没有为'unordered_set>' –