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>
命名空间: cliext