Skip to content

Latest commit

 

History

History
63 lines (47 loc) · 1.27 KB

op_less.md

File metadata and controls

63 lines (47 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 multiset<Key,Compare,Allocator>& x,
              const multiset<Key,Compare,Allocator>& y); // (1) C++03
}

概要

multisetにおいて、左辺が右辺より小さいかの判定を行う。

パラメータ

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

戻り値

lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
  • lexicographical_compare[link /reference/algorithm/lexicographical_compare.md]
  • begin()[link begin.md]
  • end()[link end.md]

計算量

size() に対して線形時間。

#include <iostream>
#include <set>

int main ()
{
  std::multiset<int> s1 = {1, 2, 3};
  std::multiset<int> s2 = {4, 5, 6};

  std::cout << std::boolalpha;

  std::cout << (s1 < s2) << std::endl;
}
  • <[color ff0000]

出力

true

参照