unordered_multiset::unordered_multiset
更新 : 2007 年 11 月
コンテナ オブジェクトを構築します。
unordered_multiset(
const unordered_multiset& right);
explicit unordered_multiset(
size_type nbuckets = N0,
const Hash& hfn = Hash(),
const Pred& comp = Pred(),
const Alloc& al = Alloc());
template<class InIt>
unordered_multiset(
InIt first, InIt last,
size_type nbuckets = N0,
const Hash& hfn = Hash(),
const Pred& comp = Pred(),
const Alloc& al = Alloc());
パラメータ
パラメータ |
説明 |
---|---|
InIt |
反復子の型。 |
al |
格納するアロケータ オブジェクト。 |
comp |
格納する比較関数オブジェクト。 |
hfn |
格納するハッシュ関数オブジェクト。 |
nbuckets |
最小バケット数。 |
right |
コピーするコンテナ。 |
解説
1 つ目のコンストラクタは、right によって制御されるシーケンスのコピーを指定します。2 つ目のコンストラクタは、空の被制御シーケンスのコピーを指定します。3 つ目のコンストラクタは、要素値 [first, last) のシーケンスを挿入します。
これらのコンストラクタは、すべて、格納された複数の値を初期化する処理も実行します。コピー コンストラクタの場合、値は right から取得されます。それ以外の場合は、次のように処理されます。
最小バケット数は、引数 nbuckets が指定されていれば、この引数から取得されます。それ以外の場合は、実装定義の値 N0 としてここに記述した既定値が使用されます。
ハッシュ関数オブジェクトは、引数 hfn が指定されていれば、この引数から取得されます。それ以外の場合は、Hash() が使用されます。
比較関数オブジェクトは、引数 comp が指定されていれば、この引数から取得されます。それ以外の場合は、Pred() が使用されます。
アロケータ オブジェクトは、引数 al が指定されていれば、この引数から取得されます。それ以外の場合は、Alloc() が使用されます。
使用例
// std_tr1__unordered_set__unordered_multiset_construct.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>
typedef std::tr1::unordered_multiset<char> Myset;
int main()
{
Myset c1;
c1.insert('a');
c1.insert('b');
c1.insert('c');
// display contents " [c] [b] [a]"
for (Myset::const_iterator it = c1.begin();
it != c1.end(); ++it)
std::cout << " [" << *it << "]";
std::cout << std::endl;
Myset c2(8,
std::tr1::hash<char>(),
std::equal_to<char>(),
std::allocator<std::pair<const char, int> >());
c2.insert('d');
c2.insert('e');
c2.insert('f');
// display contents " [f] [e] [d]"
for (Myset::const_iterator it = c2.begin();
it != c2.end(); ++it)
std::cout << " [" << *it << "]";
std::cout << std::endl;
Myset c3(c1.begin(),
c1.end(),
8,
std::tr1::hash<char>(),
std::equal_to<char>(),
std::allocator<std::pair<const char, int> >());
// display contents " [c] [b] [a]"
for (Myset::const_iterator it = c3.begin();
it != c3.end(); ++it)
std::cout << " [" << *it << "]";
std::cout << std::endl;
return (0);
}
[c] [b] [a]
[f] [e] [d]
[c] [b] [a]
必要条件
ヘッダー : <unordered_set>
名前空間 : std::tr1