C++ Deque 库 - operator< 函数
描述
C++ 函数 std::deque::operator< 测试第一个双端队列是否小于其他队列。
声明
以下是 std::deque::operator< 的声明。 函数形式 std::deque 标头。
C++98
template <class T, class Alloc> bool operator< (const deque<T,Alloc>& first, const deque<T,Alloc>& second);
参数
first − 第一个双端队列对象。
second − 相同类型的第二个双端队列对象。
返回值
如果第一个双端队列小于第二个,则返回 true,否则返回 false。
异常
此成员函数从不抛出异常。
时间复杂度
线性,即 O(n)
示例
以下示例显示了 std::deque::operator< 函数的用法。
#include <iostream>
#include <deque>
using namespace std;
int main(void) {
deque<int> d1 = {1, 2, 3};
deque<int> d2 = {1, 2, 3, 4, 5};
if (d1 < d2)
cout << "Deque d1 is less than d2." << endl;
d2.assign(1, 1);
if (!(d1 < d2))
cout << "Deque d1 is not less than d2." << endl;
return 0;
}
让我们编译并运行上面的程序,这将产生以下结果 −
Deque d1 is less than d2. Deque d1 is not less than d2.

