目录

operators (unordered_set)

描述 (Description)

这些是unordered_set的关系运算符。

声明 (Declaration)

以下是std :: operators(unordered_set)的声明。

C++11

template <class Key, class Hash, class Pred, class Alloc>
  bool operator== ( const unordered_set<Key,Hash,Pred,Alloc>& lhs,
                    const unordered_set<Key,Hash,Pred,Alloc>& rhs );

参数 (Parameters)

lhs, rhs - unorder list containers。

返回值

如果条件成立则返回true,否则返回false。

异常 (Exceptions)

如果任何元素比较对象抛出异常,则抛出异常。

请注意,无效参数会导致未定义的行为。

时间复杂

恒定时间。

例子 (Example)

以下示例显示了std ::运算符的用法。

#include <iostream>
#include <string>
#include <unordered_set>
int main () {
   std::unordered_set<std::string>
      a = {"goole","yahoo","verizon"},
      b = {"goole","verizon","yahoo"},
      c = {"verizon","goole","yahoo","oracle"};
   if (a==b) std::cout << "a and b are equal\n";
   if (b!=c) std::cout << "b and c are not equal\n";
   return 0;
}

让我们编译并运行上面的程序,这将产生以下结果 -

a and b are equal
b and c are not equal
↑回到顶部↑
WIKI教程 @2018