+ 4

Is it safe to ignore set?

Hi Below is my understanding ( Correct me if it is wrong ): - SET is implemented using RED BLACK tree.... Hence element in it will be sorted as per tree form not in ascending or descending order (so no specific requirement of sorting can be fulfilled). - UNORDERED SET is implemented using HASHING and hence your element is not sorted. - UNORDERED SET takes O(long n) time for insertion , deletion or search. - SET takes O(1) time for insertion , deletion or search. Having said above all, can we go with UNORDERED SET each time instead of choosing between SET and UNORDERED SET? Is this safe to assume or am I missing something?

7th Jul 2020, 5:18 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 Respuestas
+ 5
Can include this.. The Unordered_set allows only unique keys, for duplicate keys unordered_multiset should be used. Rest all are perfect :)
7th Jul 2020, 4:01 PM
Aditya
Aditya - avatar
+ 4
Multisets are kind of associative containers same to set, which has exception that multiple elements can have same values. But I also do l much about it's specification over unordered one :(
7th Jul 2020, 4:10 PM
Aditya
Aditya - avatar
+ 3
Aditya , yeah it's true... Definitely, we need multi version of set and map both for normal and unordered scenario. But I could not find specific use case where one should chose set over unordered_set
7th Jul 2020, 4:04 PM
Ketan Lalcheta
Ketan Lalcheta - avatar