如何检查元素是否在集合中?
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()
在许多 STL 容器(例如 std::map
、std::set<)中检查是否存在的典型方法/code>, ... 是:
The typical way to check for existence in many STL containers such as std::map
, std::set
, ... is:
const bool is_in = container.find(element) != container.end();
这篇关于如何检查元素是否在 std::set 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!