hash_multiset::count
[!メモ]
この API は、互換性のために残されています。代わりに unordered_multiset クラスです。
キーがパラメーター指定したキーに一致するhash_multisetの要素数を返します。
size_type count(
const Key& _Key
) const;
パラメーター
- _Key
hash_multisetに一致する要素のキー。
戻り値
パラメーター指定したキーを持つhash_multisetの要素数。
解説
このメンバー関数は、次の範囲内の要素数を返します:
[lower_bound (_Key ), upper_bound (_Key ) ).
Visual C++ .NET 2003では、<hash_map> と <hash_set> ヘッダー ファイルのメンバーはstdの名前空間に存在しなくなりましたが、ではなくstdextの名前空間に型。詳細については、「The stdext Namespace」を参照してください。
使用例
/Wp64 フラグを持つまたは64ビット プラットフォームでこの例をコンパイルすると、コンパイラの警告C4267エラーが生成されます。この警告の詳細については、コンパイラの警告 (レベル 3) C4267を参照してください。
// hash_multiset_count.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_multiset<int> hms1;
hash_multiset<int>::size_type i;
hms1.insert(1);
hms1.insert(1);
// Keys do not need to be unique in hash_multiset,
// so duplicates may exist.
i = hms1.count(1);
cout << "The number of elements in hms1 with a sort key of 1 is: "
<< i << "." << endl;
i = hms1.count(2);
cout << "The number of elements in hms1 with a sort key of 2 is: "
<< i << "." << endl;
}
必要条件
ヘッダー: <hash_set>
名前空間: のstdext