<queue>
, operatory
operator!=
Sprawdza, czy obiekt kolejki po lewej stronie operatora nie jest równy obiektowi kolejki po prawej stronie.
bool operator!=(const queue <Type, Container>& left, const queue <Type, Container>& right,);
Parametry
Lewy
Obiekt typu queue
.
Prawy
Obiekt typu queue
.
Wartość zwracana
true
jeśli kolejki nie są równe; false
jeśli kolejki są równe.
Uwagi
Porównanie obiektów kolejki opiera się na parowym porównywaniu ich elementów. Dwie kolejki są równe, jeśli mają taką samą liczbę elementów, a ich elementy mają te same wartości. W przeciwnym razie są one nierówne.
Przykład
// 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<
Sprawdza, czy obiekt kolejki po lewej stronie operatora jest mniejszy niż obiekt kolejki po prawej stronie.
bool operator<(const queue <Type, Container>& left, const queue <Type, Container>& right,);
Parametry
Lewy
Obiekt typu queue
.
Prawy
Obiekt typu queue
.
Wartość zwracana
true
jeśli kolejka po lewej stronie operatora jest mniejsza niż i nie równa kolejce po prawej stronie operatora; w przeciwnym razie false
.
Uwagi
Porównanie obiektów kolejki opiera się na parowym porównywaniu ich elementów. Relacja mniej niż między dwoma obiektami kolejki opiera się na porównaniu pierwszej pary nierównych elementów.
Przykład
// 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<=
Sprawdza, czy obiekt kolejki po lewej stronie operatora jest mniejszy lub równy obiektowi kolejki po prawej stronie.
bool operator<=(const queue <Type, Container>& left, const queue <Type, Container>& right,);
Parametry
Lewy
Obiekt typu queue
.
Prawy
Obiekt typu queue
.
Wartość zwracana
true
jeśli kolejka po lewej stronie operatora jest ściśle mniejsza niż kolejka po prawej stronie operatora; w przeciwnym razie false
.
Uwagi
Porównanie obiektów kolejki opiera się na parowym porównywaniu ich elementów. Relacja mniejsza lub równa relacji między dwoma obiektami kolejki jest oparta na porównaniu pierwszej pary nierównych elementów.
Przykład
// 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==
Sprawdza, czy obiekt kolejki po lewej stronie operatora jest równy obiektowi kolejki po prawej stronie.
bool operator==(const queue <Type, Container>& left, const queue <Type, Container>& right,);
Parametry
Lewy
Obiekt typu queue
.
Prawy
Obiekt typu queue
.
Wartość zwracana
true
jeśli kolejki nie są równe; false
jeśli kolejki są równe.
Uwagi
Porównanie obiektów kolejki opiera się na parowym porównywaniu ich elementów. Dwie kolejki są równe, jeśli mają taką samą liczbę elementów, a ich elementy mają te same wartości. W przeciwnym razie są one nierówne.
Przykład
// 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>
Sprawdza, czy obiekt kolejki po lewej stronie operatora jest większy niż obiekt kolejki po prawej stronie.
bool operator>(const queue <Type, Container>& left, const queue <Type, Container>& right,);
Parametry
Lewy
Obiekt typu queue
.
Prawy
Obiekt typu queue
.
Wartość zwracana
true
jeśli kolejka po lewej stronie operatora jest ściśle mniejsza niż kolejka po prawej stronie operatora; w przeciwnym razie false
.
Uwagi
Porównanie obiektów kolejki opiera się na parowym porównywaniu ich elementów. Relacja większa niż między dwoma obiektami kolejki jest oparta na porównaniu pierwszej pary nierównych elementów.
Przykład
// 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>=
Sprawdza, czy obiekt kolejki po lewej stronie operatora jest większy lub równy obiektowi kolejki po prawej stronie.
bool operator>=(const queue <Type, Container>& left, const queue <Type, Container>& right,);
Parametry
Lewy
Obiekt typu queue
.
Prawy
Obiekt typu queue
.
Wartość zwracana
true
jeśli kolejka po lewej stronie operatora jest ściśle mniejsza niż kolejka po prawej stronie operatora; w przeciwnym razie false
.
Uwagi
Porównanie obiektów kolejki opiera się na parowym porównywaniu ich elementów. Dwie kolejki są równe, jeśli mają taką samą liczbę elementów, a ich elementy mają te same wartości. W przeciwnym razie są one nierówne.
Przykład
// 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.