jeudi 4 août 2016

Using std::unique() on a std::vector

Here's my problem : I have a std::vector<std::unordered_set<int>>. Some of those unordered sets are equal but not in the same order (I know order is ambiguous in an unordered_set). To remove duplicates (in the mathematical sense of set, for example {1,3,2} == {3,2,1}) I thought about using std::unique(), but that doesn't work. After searching I even noticed that the data in the vector needs to be sorted, which doesn't make sense in this case. Is there a function that remove duplicates in a std::vector<std::unordered_set<int>>? I could do it myself I just want to know if I missed something in the stl. Also, if you know how to solve this problem using different containers then let me know. Efficiency is not an big issue here, in this context there are no more than 200 elements in that vector.

TLDR; How to I remove duplicates in std::vector<std::unordered_set<int>>?

Aucun commentaire:

Enregistrer un commentaire