<hash_set> 运算符

operator!=
operator!= (hash_multiset)
operator==
operator== (hash_multiset)

operator!=

注意

此 API 已废弃不用。 替代项为 unordered_set 类

测试运算符左侧的 hash_set 对象是否不等于右侧的 hash_set 对象。

bool operator!=(const hash_set <Key, Traits, Allocator>& left, const hash_set <Key, Traits, Allocator>& right);

参数

left
一个 hash_set 类型的对象。

right
一个 hash_set 类型的对象。

返回值

如果 hash_set 不相等,则为 true;如果 hash_set 相等,则为 false

备注

hash_set 对象之间的比较基于其元素的成对比较。 如果两个 hash_set 具有的元素数目相等且对应元素具有相同的值,则这两个 hash_set 相等。 否则,它们不相等。

<hash_map><hash_set> 头文件的成员位于 stdext 命名空间中。

示例

// hash_set_op_ne.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_set <int> hs1, hs2, hs3;
   int i;

   for ( i = 0 ; i < 3 ; i++ )
   {
      hs1.insert ( i );
      hs2.insert ( i * i );
      hs3.insert ( i );
   }

   if ( hs1 != hs2 )
      cout << "The hash_sets hs1 and hs2 are not equal." << endl;
   else
      cout << "The hash_sets hs1 and hs2 are equal." << endl;

   if ( hs1 != hs3 )
      cout << "The hash_sets hs1 and hs3 are not equal." << endl;
   else
      cout << "The hash_sets hs1 and hs3 are equal." << endl;
}
The hash_sets hs1 and hs2 are not equal.
The hash_sets hs1 and hs3 are equal.

operator==

注意

此 API 已废弃不用。 替代项为 unordered_set 类

测试运算符左侧的 hash_set 对象是否等于右侧的 hash_set 对象。

bool operator!==(const hash_set <Key, Traits, Allocator>& left, const hash_set <Key, Traits, Allocator>& right);

参数

left
一个 hash_set 类型的对象。

right
一个 hash_set 类型的对象。

返回值

如果运算符左侧的 hash_set 等于运算符右侧的 hash_set,则为 true,否则为 false

注解

hash_set 对象之间的比较基于其元素的成对比较。 如果两个 hash_set 具有的元素数目相等且对应元素具有相同的值,则这两个 hash_set 相等。 否则,它们不相等。

示例

// hash_set_op_eq.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_set <int> s1, s2, s3;
   int i;

   for ( i = 0 ; i < 3 ; i++ )
   {
      s1.insert ( i );
      s2.insert ( i * i );
      s3.insert ( i );
   }

   if ( s1 == s2 )
      cout << "The hash_sets s1 and s2 are equal." << endl;
   else
      cout << "The hash_sets s1 and s2 are not equal." << endl;

   if ( s1 == s3 )
      cout << "The hash_sets s1 and s3 are equal." << endl;
   else
      cout << "The hash_sets s1 and s3 are not equal." << endl;
}
The hash_sets s1 and s2 are not equal.
The hash_sets s1 and s3 are equal.

operator!= (hash_multiset)

注意

此 API 已废弃不用。 替代项为 unordered_set 类

测试运算符左侧的 hash_multiset 对象是否不等于右侧的 hash_multiset 对象。

bool operator!=(const hash_multiset <Key, Traits, Allocator>& left, const hash_multiset <Key, Traits, Allocator>& right);

参数

left
一个 hash_multiset 类型的对象。

right
一个 hash_multiset 类型的对象。

返回值

如果 hash_multiset 不相等,则为 true;如果 hash_multiset 相等,则为 false

注解

hash_multiset 对象之间的比较基于其元素的成对比较。 如果两个 hash_multiset 具有的元素数目相等且对应元素具有相同的值,则这两个 hash_multiset 相等。 否则,它们不相等。

示例

// hashset_op_ne.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multiset <int> hs1, hs2, hs3;
   int i;

   for ( i = 0 ; i < 3 ; i++ )
   {
      hs1.insert ( i );
      hs2.insert ( i * i );
      hs3.insert ( i );
   }

   if ( hs1 != hs2 )
      cout << "The hash_multisets hs1 and hs2 are not equal." << endl;
   else
      cout << "The hash_multisets hs1 and hs2 are equal." << endl;

   if ( hs1 != hs3 )
      cout << "The hash_multisets hs1 and hs3 are not equal." << endl;
   else
      cout << "The hash_multisets hs1 and hs3 are equal." << endl;
}
The hash_multisets hs1 and hs2 are not equal.
The hash_multisets hs1 and hs3 are equal.

operator== (hash_multiset)

注意

此 API 已废弃不用。 替代项为 unordered_set 类

测试运算符左侧的 hash_multiset 对象是否等于右侧的 hash_multiset 对象。

bool operator!==(const hash_multiset <Key, Traits, Allocator>& left, const hash_multiset <Key, Traits, Allocator>& right);

参数

left
一个 hash_multiset 类型的对象。

right
一个 hash_multiset 类型的对象。

返回值

如果运算符左侧的 hash_multiset 等于运算符右侧的 hash_multiset,则为 true,否则为 false

备注

hash_multiset 对象之间的比较基于其元素的成对比较。 如果两个 hash_multiset 具有的元素数目相等且对应元素具有相同的值,则这两个 hash_multiset 相等。 否则,它们不相等。

示例

// hash_multiset_op_eq.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multiset <int> s1, s2, s3;
   int i;

   for ( i = 0 ; i < 3 ; i++ )
   {
      s1.insert ( i );
      s2.insert ( i * i );
      s3.insert ( i );
   }

   if ( s1 == s2 )
      cout << "The hash_multisets s1 and s2 are equal." << endl;
   else
      cout << "The hash_multisets s1 and s2 are not equal." << endl;

   if ( s1 == s3 )
      cout << "The hash_multisets s1 and s2 are equal." << endl;
   else
      cout << "The hash_multisets s1 and s2 are not equal." << endl;
}
The hash_multisets s1 and s2 are not equal.
The hash_multisets s1 and s2 are equal.

另请参阅

<hash_set>