目录

operator>=

描述 (Description)

C ++函数std::queue::operator》=测试第一个队列是否大于或等于其他队列。 通过将相应的运算符应用于基础容器来完成比较。

声明 (Declaration)

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

C++98

template <class T, class Container>
bool operator>= (const queue<T,Container>& q1, const queue<T,Container>& q2);

参数 (Parameters)

  • q1 - 第一个队列对象。

  • q2 - 第二个队列对象。

返回值

如果第一个队列大于或等于第二个队列,则返回true,否则返回false。

异常 (Exceptions)

该成员函数从不抛出异常。

时间复杂

线性即O(n)

例子 (Example)

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

#include <iostream>
#include <queue>
using namespace std;
int main(void) {
   queue<int> q1, q2;
   for (int i = 0; i < 5; ++i) {
      q1.push(i);
      q2.push(i);
   }
   if (q1 >= q2)
      cout << "q1 is greater than or equal to q2." << endl;
   q2.emplace(6);
   if (!(q1 >= q2))
      cout << "q1 is not greater than or equal to q2." << endl;
   return 0;
}

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

q1 is greater than or equal to q2.
q1 is not greater than or equal to q2.
↑回到顶部↑
WIKI教程 @2018