hash_map::size

注意事項注意事項

這個 API 已經過時。這個選項是 unordered_map Class

傳回項目數 hash_map 的。

size_type size( ) const;

傳回值

hash_map 的目前長度。

備註

在 Visual C++ .NET Pocket PC, <hash_map><hash_set> 標頭檔 (Header File) 的成員不在 std 命名空間,,而是移至 stdext 命名空間。如需詳細資訊,請參閱 stdext 命名空間

範例

當編譯這個範例與 /Wp64 旗標或在一個獨立的平台時,編譯器警告 C4267 會產生。如需這項警告的詳細資訊,請參閱 編譯器警告 (層級 3) C4267

// hash_map_size.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
    using namespace std;
    using namespace stdext;
    hash_map<int, int> hm1, hm2;
    hash_map<int, int>::size_type i;
    typedef pair<int, int> Int_Pair;

    hm1.insert(Int_Pair(1, 1));
    i = hm1.size();
    cout << "The hash_map length is " << i << "." << endl;

    hm1.insert(Int_Pair(2, 4));
    i = hm1.size();
    cout << "The hash_map length is now " << i << "." << endl;
}
  
  

需求

標題: <hash_map>

命名空間: stdext

請參閱

參考

hash_map Class

標準樣板程式庫