Примечание.
Для доступа к этой странице требуется авторизация. Вы можете попробовать войти или изменить каталоги.
Для доступа к этой странице требуется авторизация. Вы можете попробовать изменить каталоги.
оператор!=
Проверяет неравенство объекта queue слева от оператора объекту queue справа от оператора.
bool operator!=(const queue <Type, Container>& left, const queue <Type, Container>& right);
Параметры
left
Объект типа queue.
right
Объект типа queue.
Возвращаемое значение
true Значение , если очереди не равны; false Значение
Замечания
Сравнение объектов-очередей основывается на попарном сравнении их элементов. Две очереди равны, если они содержат одинаковое количество элементов, а их соответствующие элементы имеют одинаковые значения. В противном случае они не равны.
Пример
// queue_op_ne.cpp
// compile with: /EHsc
#include <queue>
#include <list>
#include <iostream>
int main( )
{
using namespace std;
// Declares queues with list base containers
queue <int, list<int> > q1, q2, q3;
// The following line would have caused an error because vector
// does not support pop_front( ) and so cannot be adapted
// by queue as a base container
// queue <int, vector<int> > q1, q2, q3;
q1.push( 1 );
q2.push( 1 );
q2.push( 2 );
q3.push( 1 );
if ( q1 != q2 )
cout << "The queues q1 and q2 are not equal." << endl;
else
cout << "The queues q1 and q2 are equal." << endl;
if ( q1 != q3 )
cout << "The queues q1 and q3 are not equal." << endl;
else
cout << "The queues q1 and q3 are equal." << endl;
}
The queues q1 and q2 are not equal.
The queues q1 and q3 are equal.
operator<
Проверяет, меньше ли объект queue слева от оператора, чем объект queue справа от оператора.
bool operator<(const queue <Type, Container>& left, const queue <Type, Container>& right);
Параметры
left
Объект типа queue.
right
Объект типа queue.
Возвращаемое значение
true Значение , если очередь в левой части оператора меньше и не равна очереди справа от оператора; в противном случае false.
Замечания
Сравнение объектов-очередей основывается на попарном сравнении их элементов. Отношение "меньше" между двумя объектами-очередями основывается на сравнении первой пары неравных элементов.
Пример
// queue_op_lt.cpp
// compile with: /EHsc
#include <queue>
#include <iostream>
int main( )
{
using namespace std;
// Declares queues with default deque base container
queue <int> q1, q2, q3;
q1.push( 1 );
q1.push( 2 );
q2.push( 5 );
q2.push( 10 );
q3.push( 1 );
q3.push( 2 );
if ( q1 < q2 )
cout << "The queue q1 is less than the queue q2." << endl;
else
cout << "The queue q1 is not less than the queue q2." << endl;
if ( q1 < q3 )
cout << "The queue q1 is less than the queue q3." << endl;
else
cout << "The queue q1 is not less than the queue q3." << endl;
}
The queue q1 is less than the queue q2.
The queue q1 is not less than the queue q3.
operator<=
Проверяет, меньше ли объект queue слева от оператора, чем объект queue справа от оператора, или равен ему.
bool operator<=(const queue <Type, Container>& left, const queue <Type, Container>& right);
Параметры
left
Объект типа queue.
right
Объект типа queue.
Возвращаемое значение
true Значение , если очередь в левой части оператора строго меньше очереди в правой части оператора; в противном случае false.
Замечания
Сравнение объектов-очередей основывается на попарном сравнении их элементов. Отношение "меньше или равно" между двумя объектами-очередями основывается на сравнении первой пары неравных элементов.
Пример
// queue_op_le.cpp
// compile with: /EHsc
#include <queue>
#include <iostream>
int main( )
{
using namespace std;
queue <int> q1, q2, q3;
q1.push( 5 );
q1.push( 10 );
q2.push( 1 );
q2.push( 2 );
q3.push( 5 );
q3.push( 10 );
if ( q1 <= q2 )
cout << "The queue q1 is less than or equal to "
<< "the queue q2." << endl;
else
cout << "The queue q1 is greater than "
<< "the queue q2." << endl;
if ( q1 <= q3 )
cout << "The queue q1 is less than or equal to "
<< "the queue q3." << endl;
else
cout << "The queue q1 is greater than "
<< "the queue q3." << endl;
}
The queue q1 is greater than the queue q2.
The queue q1 is less than or equal to the queue q3.
operator==
Проверяет равенство объекта-очереди слева от оператора объекту-очереди справа от оператора.
bool operator==(const queue <Type, Container>& left, const queue <Type, Container>& right);
Параметры
left
Объект типа queue.
right
Объект типа queue.
Возвращаемое значение
true Значение , если очереди не равны; false Значение
Замечания
Сравнение объектов-очередей основывается на попарном сравнении их элементов. Две очереди равны, если они содержат одинаковое количество элементов, а их соответствующие элементы имеют одинаковые значения. В противном случае они не равны.
Пример
// queue_op_eq.cpp
// compile with: /EHsc
#include <queue>
#include <list>
#include <iostream>
int main( )
{
using namespace std;
// Declares queues with list base containers
queue <int, list<int> > q1, q2, q3;
// The following line would have caused an error because vector
// does not support pop_front( ) and so cannot be adapted
// by queue as a base container
// queue <int, vector<int> > q1, q2, q3;
q1.push( 1 );
q2.push( 2 );
q3.push( 1 );
if ( q1 != q2 )
cout << "The queues q1 and q2 are not equal." << endl;
else
cout << "The queues q1 and q2 are equal." << endl;
if ( q1 != q3 )
cout << "The queues q1 and q3 are not equal." << endl;
else
cout << "The queues q1 and q3 are equal." << endl;
}
The queues q1 and q2 are not equal.
The queues q1 and q3 are equal.
operator>
Проверяет, больше ли объект queue слева от оператора, чем объект queue справа от оператора.
bool operator>(const queue <Type, Container>& left, const queue <Type, Container>& right);
Параметры
left
Объект типа queue.
right
Объект типа queue.
Возвращаемое значение
true Значение , если очередь в левой части оператора строго меньше очереди в правой части оператора; в противном случае false.
Замечания
Сравнение объектов-очередей основывается на попарном сравнении их элементов. Отношение "больше" между двумя объектам-очередями основывается на сравнении первой пары неравных элементов.
Пример
// queue_op_gt.cpp
// compile with: /EHsc
#include <queue>
#include <iostream>
int main( )
{
using namespace std;
queue <int> q1, q2, q3;
q1.push( 1 );
q1.push( 2 );
q1.push( 3 );
q2.push( 5 );
q2.push( 10 );
q3.push( 1 );
q3.push( 2 );
if ( q1 > q2 )
cout << "The queue q1 is greater than "
<< "the queue q2." << endl;
else
cout << "The queue q1 is not greater than "
<< "the queue q2." << endl;
if ( q1> q3 )
cout << "The queue q1 is greater than "
<< "the queue q3." << endl;
else
cout << "The queue q1 is not greater than "
<< "the queue q3." << endl;
}
The queue q1 is not greater than the queue q2.
The queue q1 is greater than the queue q3.
operator>=
Проверяет, больше ли объект queue слева от оператора, чем объект queue справа от оператора, или равен ему.
bool operator>=(const queue <Type, Container>& left, const queue <Type, Container>& right);
Параметры
left
Объект типа queue.
right
Объект типа queue.
Возвращаемое значение
true Значение , если очередь в левой части оператора строго меньше очереди в правой части оператора; в противном случае false.
Замечания
Сравнение объектов-очередей основывается на попарном сравнении их элементов. Две очереди равны, если они содержат одинаковое количество элементов, а их соответствующие элементы имеют одинаковые значения. В противном случае они не равны.
Пример
// queue_op_ge.cpp
// compile with: /EHsc
#include <queue>
#include <iostream>
int main( )
{
using namespace std;
queue <int> q1, q2, q3;
q1.push( 1 );
q1.push( 2 );
q2.push( 5 );
q2.push( 10 );
q3.push( 1 );
q3.push( 2 );
if ( q1 >= q2 )
cout << "The queue q1 is greater than or equal to "
<< "the queue q2." << endl;
else
cout << "The queue q1 is less than "
<< "the queue q2." << endl;
if ( q1>= q3 )
cout << "The queue q1 is greater than or equal to "
<< "the queue q3." << endl;
else
cout << "The queue q1 is less than "
<< "the queue q3." << endl;
}
The queue q1 is less than the queue q2.
The queue q1 is greater than or equal to the queue q3.