Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Operator
Header <hash_map> menyediakan operator berikut:
operator!=
Catatan
API ini kedaluarsa. Alternatifnya adalah unordered_map.
Header ini dihapus di MSVC Build Tools 14.51
Pengujian jika objek hash_map di sisi kiri operator tidak sama dengan objek hash_map di sisi kanan.
bool operator!=(const hash_map <Key, Type, Traits, Allocator>& left, const hash_map <Key, Type, Traits, Allocator>& right);
Parameter
left
Objek jenis hash_map.
kanan
Objek jenis hash_map.
Tampilkan Nilai
true jika hash_maps tidak sama; false jika hash_maps sama.
Keterangan
Perbandingan antara objek hash_map didasarkan pada perbandingan berpasangan dari elemennya. Dua hash_maps sama jika memiliki jumlah elemen yang sama dan elemennya masing-masing memiliki nilai yang sama. Jika tidak, mereka tidak sama.
Anggota <> dan<> di Namespace stdext.
Contoh
// hash_map_op_ne.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_map <int, int> hm1, hm2, hm3;
int i;
typedef pair <int, int> Int_Pair;
for ( i = 0 ; i < 3 ; i++ )
{
hm1.insert ( Int_Pair ( i, i ) );
hm2.insert ( Int_Pair ( i, i * i ) );
hm3.insert ( Int_Pair ( i, i ) );
}
if ( hm1 != hm2 )
cout << "The hash_maps hm1 and hm2 are not equal." << endl;
else
cout << "The hash_maps hm1 and hm2 are equal." << endl;
if ( hm1 != hm3 )
cout << "The hash_maps hm1 and hm3 are not equal." << endl;
else
cout << "The hash_maps hm1 and hm3 are equal." << endl;
}
The hash_maps hm1 and hm2 are not equal.
The hash_maps hm1 and hm3 are equal.
operator==
Catatan
API ini kedaluarsa. Alternatifnya adalah kelas unordered_map.
Menguji apakah objek hash_map di sisi kiri operator sama dengan objek hash_map di sisi kanan.
bool operator==(const hash_map <Key, Type, Traits, Allocator>& left, const hash_map <Key, Type, Traits, Allocator>& right);
Parameter
left
Objek jenis hash_map.
kanan
Objek jenis hash_map.
Tampilkan Nilai
true jika hash_map di sisi kiri operator sama dengan hash_map di sisi kanan operator; jika tidak false.
Keterangan
Perbandingan antara objek hash_map didasarkan pada perbandingan berpasangan dari elemennya. Dua hash_maps sama jika memiliki jumlah elemen yang sama dan elemennya masing-masing memiliki nilai yang sama. Jika tidak, mereka tidak sama.
Contoh
// hash_map_op_eq.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_map <int, int> hm1, hm2, hm3;
int i;
typedef pair <int, int> Int_Pair;
for ( i = 0 ; i < 3 ; i++ )
{
hm1.insert ( Int_Pair ( i, i ) );
hm2.insert ( Int_Pair ( i, i * i ) );
hm3.insert ( Int_Pair ( i, i ) );
}
if ( hm1 == hm2 )
cout << "The hash_maps hm1 and hm2 are equal." << endl;
else
cout << "The hash_maps hm1 and hm2 are not equal." << endl;
if ( hm1 == hm3 )
cout << "The hash_maps hm1 and hm3 are equal." << endl;
else
cout << "The hash_maps hm1 and hm3 are not equal." << endl;
}
The hash_maps hm1 and hm2 are not equal.
The hash_maps hm1 and hm3 are equal.
operator!= (hash_multimap)
Catatan
API ini kedaluarsa. Alternatifnya adalah kelas unordered_multimap.
Pengujian jika objek hash_multimap di sisi kiri operator tidak sama dengan objek hash_multimap di sisi kanan.
bool operator!=(const hash_multimap <Key, Type, Traits, Allocator>& left, const hash_multimap <Key, Type, Traits, Allocator>& right);
Parameter
left
Objek jenis hash_multimap.
kanan
Objek jenis hash_multimap.
Tampilkan Nilai
true jika hash_multimaps tidak sama; false jika hash_multimaps sama.
Keterangan
Perbandingan antara objek hash_multimap didasarkan pada perbandingan berpasangan dari elemennya. Dua hash_multimaps sama jika memiliki jumlah elemen yang sama dan elemennya masing-masing memiliki nilai yang sama. Jika tidak, mereka tidak sama.
Contoh
// hash_multimap_op_ne.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_multimap <int, int> hm1, hm2, hm3;
int i;
typedef pair <int, int> Int_Pair;
for ( i = 0 ; i < 3 ; i++ )
{
hm1.insert ( Int_Pair ( i, i ) );
hm2.insert ( Int_Pair ( i, i * i ) );
hm3.insert ( Int_Pair ( i, i ) );
}
if ( hm1 != hm2 )
cout << "The hash_multimaps hm1 and hm2 are not equal." << endl;
else
cout << "The hash_multimaps hm1 and hm2 are equal." << endl;
if ( hm1 != hm3 )
cout << "The hash_multimaps hm1 and hm3 are not equal." << endl;
else
cout << "The hash_multimaps hm1 and hm3 are equal." << endl;
}
The hash_multimaps hm1 and hm2 are not equal.
The hash_multimaps hm1 and hm3 are equal.
operator== (hash_multimap)
Catatan
API ini kedaluarsa. Alternatifnya adalah kelas unordered_multimap.
Menguji apakah objek hash_multimap di sisi kiri operator sama dengan objek hash_multimap di sisi kanan.
bool operator==(const hash_multimap <Key, Type, Traits, Allocator>& left, const hash_multimap <Key, Type, Traits, Allocator>& right);
Parameter
left
Objek jenis hash_multimap.
kanan
Objek jenis hash_multimap.
Tampilkan Nilai
true jika hash_multimap di sisi kiri operator sama dengan hash_multimap di sisi kanan operator; jika tidak false.
Keterangan
Perbandingan antara objek hash_multimap didasarkan pada perbandingan berpasangan dari elemennya. Dua hash_multimaps sama jika memiliki jumlah elemen yang sama dan elemennya masing-masing memiliki nilai yang sama. Jika tidak, mereka tidak sama.
Contoh
// hash_multimap_op_eq.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_multimap<int, int> hm1, hm2, hm3;
int i;
typedef pair<int, int> Int_Pair;
for (i = 0; i < 3; i++)
{
hm1.insert(Int_Pair(i, i));
hm2.insert(Int_Pair(i, i*i));
hm3.insert(Int_Pair(i, i));
}
if ( hm1 == hm2 )
cout << "The hash_multimaps hm1 and hm2 are equal." << endl;
else
cout << "The hash_multimaps hm1 and hm2 are not equal." << endl;
if ( hm1 == hm3 )
cout << "The hash_multimaps hm1 and hm3 are equal." << endl;
else
cout << "The hash_multimaps hm1 and hm3 are not equal." << endl;
}
The hash_multimaps hm1 and hm2 are not equal.
The hash_multimaps hm1 and hm3 are equal.