本文翻译自:How to check that an element is in a std::set?
How do you check that an element is in a set? 你如何检查元素是否在集合中?
Is there a simpler equivalent of the following code: 是否有更简单的等效代码如下:
myset.find(x) != myset.end()
#1楼
参考:https://stackoom.com/question/78wz/如何检查元素是否在std-set中
#2楼
I was able to write a general contains
function for std::list
and std::vector
, 我能够为std::list
和std::vector
编写一个通用的contains
函数,
template<typename T>
bool contains( const list<T>