Skip to content

Latest commit

 

History

History
65 lines (48 loc) · 1.27 KB

op_not_equal.md

File metadata and controls

65 lines (48 loc) · 1.27 KB

operator!=

  • set[meta header]
  • std[meta namespace]
  • function template[meta id-type]
namespace std {
  // operator==により、以下の演算子が使用可能になる (C++20)
  template <class Key, class Compare, class Allocator>
  bool
    operator!=(const set<Key,Compare,Allocator>& x,
               const set<Key,Compare,Allocator>& y); // (1) C++03
}

概要

xy が等しくないかどうかの判定を行う。

パラメータ

  • x, y
    比較するコンテナ。

戻り値

二つのコンテナが等しくない場合に true, そうでない場合に false

計算量

size() に対して線形時間。ただし、xyのサイズが異なる場合は定数時間。

#include <iostream>
#include <set>

int main()
{
  std::set<int> s1, s2;
  s1.insert(10);
  s1.insert(20);
  s1.insert(30);
  s2 = s1;

  std::cout << (s1 != s2) << std::endl;

  s2.insert(40);

  std::cout << (s1 != s2) << std::endl;
}
  • !=[color ff0000]
  • insert[link insert.md]

出力

0
1

参照