hash_multiset::size (STL/CLR)
計數項目的數目。
size_type size();
備註
成員函式會傳回受控制序列的長度。 您可以用它來判斷目前在受控制序列的項目數目。 如果您很在意是否該序列擁有非零值的大小,請參閱hash_multiset::empty (STL/CLR)()。
範例
// cliext_hash_multiset_size.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
System::Console::WriteLine("size() = {0} starting with 3", c1.size());
// clear the container and reinspect
c1.clear();
System::Console::WriteLine("size() = {0} after clearing", c1.size());
// add elements and clear again
c1.insert(L'a');
c1.insert(L'b');
System::Console::WriteLine("size() = {0} after adding 2", c1.size());
return (0);
}
需求
標頭: < cliext/hash_set >
Namespace: cliext