Can set_intersection be used with hash_set in C++?

后端 未结 3 1374
遇见更好的自我
遇见更好的自我 2021-01-22 03:09

I am calculating intersection, union and differences of sets. I have a typedef of my set type:

typedef set node_set;

When it i

3条回答
  •  心在旅途
    2021-01-22 03:39

    I'm going to go with no. Keep in mind hash_set isn't standard C++ and never will be, it's an older extension that's no longer supported. The newer "hash maps" are called unordered_set and unordered_map, available in TR1, Boost, and C++0x.

    The reason it's a no is that set_intersection requires the input data to be sorted. Contrarily, the reason a hash map is so quick is it gives up ordering. This is obviously more pronounced under the name unordered_set. So the precondition cannot be reliably met.

提交回复
热议问题