目录

operator>=

描述 (Description)

C ++函数std::map::operator》=测试第一个映射是否大于或等于其他映射。

运算符> =按顺序比较元素,比较在第一次不匹配时停止。

声明 (Declaration)

以下是std :: map :: operator> = function form std :: map header的声明。

C++98

template <class Key, class T, class Compare, class Alloc>
bool operator>= ( const map<Key,T,Compare,Alloc>& m1,
                  const map<Key,T,Compare,Alloc>& m2);

参数 (Parameters)

  • m1 - 第一个地图对象。

  • m2 - 第二个地图对象。

返回值

如果第一个map大于或等于second,则返回true,否则返回false。

异常 (Exceptions)

此函数不会抛出异常。

时间复杂

线性即O(n)

例子 (Example)

以下示例显示了std :: map :: operator> = function的用法。

#include <iostream>
#include <map>
using namespace std;
int main(void) {
   map<char, int> m1;
   map<char, int> m2;
   m1.emplace('a', 1);
   m2.emplace('a', 1);
   if (m1 >= m2)
      cout << "Map m1 is greater than or equal to m2." << endl;
   m2.emplace('b', 2);
   if (!(m1 >= m2))
      cout << "Map m1 is not greater than or equal to m2." << endl;
   return 0;
}

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

Map m1 is greater than or equal to m2.
Map m1 is not greater than or equal to m2.
↑回到顶部↑
WIKI教程 @2018