次の方法で共有


hash_map::empty (STL/CLR)

要素が存在しないかどうかをテストします。

    bool empty();

解説

このメンバー関数は、被制御シーケンスが空の場合に true を返します。これは hash_map::size (STL/CLR)() == 0と同じです。hash_map が空であるかどうかをテストするときに使用します。

使用例

// cliext_hash_map_empty.cpp 
// compile with: /clr 
#include <cliext/hash_map> 
 
typedef cliext::hash_map<wchar_t, int> Myhash_map; 
int main() 
    { 
    Myhash_map c1; 
    c1.insert(Myhash_map::make_value(L'a', 1)); 
    c1.insert(Myhash_map::make_value(L'b', 2)); 
    c1.insert(Myhash_map::make_value(L'c', 3)); 
 
// display contents " [a 1] [b 2] [c 3]" 
    for each (Myhash_map::value_type elem in c1) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
    System::Console::WriteLine("size() = {0}", c1.size()); 
    System::Console::WriteLine("empty() = {0}", c1.empty()); 
 
// clear the container and reinspect 
    c1.clear(); 
    System::Console::WriteLine("size() = {0}", c1.size()); 
    System::Console::WriteLine("empty() = {0}", c1.empty()); 
    return (0); 
    } 
 
  

必要条件

ヘッダー: <cliext/hash_map>

名前空間: の cliext

参照

関連項目

hash_map (STL/CLR)

hash_map::size (STL/CLR)