What is the difference between set and hashset in C++ STL?

前端 未结 5 735
时光说笑
时光说笑 2021-02-02 09:31

When should I choose one over the other? Are there any pointers that you would recommend for using the right STL containers?

5条回答
  •  情歌与酒
    2021-02-02 10:00

    Another thing to keep in mind is that with hash_set you have to provide the hash function, whereas a set only requires a comparison function ('<') which is easier to define (and predefined for native types).

提交回复
热议问题