multimap::empty (STL/CLR)
測試是否沒有項目呈現。
bool empty();
備註
成員函式會傳回空白的受控制序列的則為 true。它相當於multimap::size (STL/CLR)() == 0。您可以用它來測試是否是空的 multimap。
範例
// cliext_multimap_empty.cpp
// compile with: /clr
#include <cliext/map>
typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
{
Mymultimap c1;
c1.insert(Mymultimap::make_value(L'a', 1));
c1.insert(Mymultimap::make_value(L'b', 2));
c1.insert(Mymultimap::make_value(L'c', 3));
// display contents " [a 1] [b 2] [c 3]"
for each (Mymultimap::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/地圖 >
Namespace: cliext