std::map does not use hashing. std::unordered_map does, but it's C ++ 11. std::map and std::set both use the comparator you provided. Class templates have default values for this comparator, which comes down to comparing operator< , but you can provide your own.
If you don’t need both the key and the value you want to save (it looks like you didn’t), you should just use std::set , as it is more suitable.
The standard does not say which map and set data structures are used under the hood, only that certian actions have certain time difficulties. In fact, in most implementations, I know how to use a tree.
The time complexity does not matter if you use operator[] or insert , but I would use insert or operator[] before I did a search and then insert if the item was not found. Later, two separate searches will be implied to insert an element into the set.
source share