Search code examples
c++stlsetunordered-set

When to use std::unordered_set instead of std::set?


I am studying STL (containers at the moment) and was puzzled about when to use std::set and std::unordered_set and what reasons for doing this?


Solution

  • std::set sorts the elements while std::unordered_set leaves the elements as is. If you are required have all the elements sorted out, you should use std::set.