Udostępnij za pośrednictwem


<unordered_set>, operatory

operator!=

Sprawdza, czy obiekt unordered_set po lewej stronie operatora nie jest równy obiektowi unordered_set po prawej stronie.

bool operator!=(const unordered_set <Key, Hash, Pred, Allocator>& left, const unordered_set <Key, Hash, Pred, Allocator>& right);

Parametry

Lewej
Obiekt typu unordered_set.

Prawo
Obiekt typu unordered_set.

Wartość zwracana

true jeśli unordered_sets nie są równe; false jeśli są równe.

Uwagi

Porównanie obiektów unordered_set nie ma wpływu na dowolną kolejność przechowywania ich elementów. Dwa unordered_sets są równe, jeśli mają taką samą liczbę elementów, a elementy w jednym kontenerze są permutacją elementów w drugim kontenerze. W przeciwnym razie są one nierówne.

Przykład

// unordered_set_ne.cpp
// compile by using: cl.exe /EHsc /nologo /W4 /MTd
#include <unordered_set>
#include <iostream>
#include <ios>

int main()
{
    using namespace std;

    unordered_set<char> c1, c2, c3;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    c2.insert('c');
    c2.insert('a');
    c2.insert('d');

    c3.insert('c');
    c3.insert('a');
    c3.insert('b');

   cout << boolalpha;
   cout << "c1 != c2: " << (c1 != c2) << endl;
   cout << "c1 != c3: " << (c1 != c3) << endl;
   cout << "c2 != c3: " << (c2 != c3) << endl;

    return (0);
}

Wyjście:

c1 != c2: true

c1 != c3: false

c2 != c3: true

operator==

Sprawdza, czy obiekt unordered_set po lewej stronie operatora jest równy obiektowi unordered_set po prawej stronie.

bool operator==(const unordered_set <Key, Hash, Pred, Allocator>& left, const unordered_set <Key, Hash, Pred, Allocator>& right);

Parametry

Lewej
Obiekt typu unordered_set.

Prawo
Obiekt typu unordered_set.

Wartość zwracana

true jeśli unordered_sets są równe; false jeśli nie są równe.

Uwagi

Porównanie obiektów unordered_set nie ma wpływu na dowolną kolejność przechowywania ich elementów. Dwa unordered_sets są równe, jeśli mają taką samą liczbę elementów, a elementy w jednym kontenerze są permutacją elementów w drugim kontenerze. W przeciwnym razie są one nierówne.

Przykład

// unordered_set_eq.cpp
// compile by using: cl.exe /EHsc /nologo /W4 /MTd
#include <unordered_set>
#include <iostream>
#include <ios>

int main()
{
    using namespace std;

    unordered_set<char> c1, c2, c3;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    c2.insert('c');
    c2.insert('a');
    c2.insert('d');

    c3.insert('c');
    c3.insert('a');
    c3.insert('b');

   cout << boolalpha;
   cout << "c1 == c2: " << (c1 == c2) << endl;
   cout << "c1 == c3: " << (c1 == c3) << endl;
   cout << "c2 == c3: " << (c2 == c3) << endl;

    return (0);
}
c1 == c2: false
c1 == c3: true
c2 == c3: false

operator!= (multiset)

Sprawdza, czy obiekt unordered_multiset po lewej stronie operatora nie jest równy obiektowi unordered_multiset po prawej stronie.

bool operator!=(const unordered_multiset <Key, Hash, Pred, Allocator>& left, const unordered_multiset <Key, Hash, Pred, Allocator>& right);

Parametry

Lewej
Obiekt typu unordered_multiset.

Prawo
Obiekt typu unordered_multiset.

Wartość zwracana

true jeśli unordered_multisets nie są równe; false jeśli są równe.

Uwagi

Porównanie obiektów unordered_multiset nie ma wpływu na dowolną kolejność przechowywania ich elementów. Dwie unordered_multisets są równe, jeśli mają taką samą liczbę elementów, a elementy w jednym kontenerze są permutacją elementów w drugim kontenerze. W przeciwnym razie są one nierówne.

Przykład

// unordered_multiset_ne.cpp
// compile by using: cl.exe /EHsc /nologo /W4 /MTd
#include <unordered_set>
#include <iostream>
#include <ios>

int main()
{
    using namespace std;

    unordered_multiset<char> c1, c2, c3;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');
    c1.insert('c');

    c2.insert('c');
    c2.insert('c');
    c2.insert('a');
    c2.insert('d');

    c3.insert('c');
    c3.insert('c');
    c3.insert('a');
    c3.insert('b');

   cout << boolalpha;
   cout << "c1 != c2: " << (c1 != c2) << endl;
   cout << "c1 != c3: " << (c1 != c3) << endl;
   cout << "c2 != c3: " << (c2 != c3) << endl;

    return (0);
}
c1 != c2: true
c1 != c3: false
c2 != c3: true

operator== (multiset)

Sprawdza, czy obiekt unordered_multiset po lewej stronie operatora jest równy obiektowi unordered_multiset po prawej stronie.

bool operator==(const unordered_multiset <Key, Hash, Pred, Allocator>& left, const unordered_multiset <Key, Hash, Pred, Allocator>& right);

Parametry

Lewej
Obiekt typu unordered_multiset.

Prawo
Obiekt typu unordered_multiset.

Wartość zwracana

true jeśli unordered_multisets są równe; false jeśli nie są równe.

Uwagi

Porównanie obiektów unordered_multiset nie ma wpływu na dowolną kolejność przechowywania ich elementów. Dwie unordered_multisets są równe, jeśli mają taką samą liczbę elementów, a elementy w jednym kontenerze są permutacją elementów w drugim kontenerze. W przeciwnym razie są one nierówne.

Przykład

// unordered_multiset_eq.cpp
// compile by using: cl.exe /EHsc /nologo /W4 /MTd
#include <unordered_set>
#include <iostream>
#include <ios>

int main()
{
    using namespace std;

    unordered_multiset<char> c1, c2, c3;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');
    c1.insert('c');

    c2.insert('c');
    c2.insert('c');
    c2.insert('a');
    c2.insert('d');

    c3.insert('c');
    c3.insert('c');
    c3.insert('a');
    c3.insert('b');

   cout << boolalpha;
   cout << "c1 == c2: " << (c1 == c2) << endl;
   cout << "c1 == c3: " << (c1 == c3) << endl;
   cout << "c2 == c3: " << (c2 == c3) << endl;

    return (0);
}
c1 == c2: false
c1 == c3: true
c2 == c3: false