unordered_multimap::unordered_multimap

更新 : 2007 年 11 月

コンテナ オブジェクトを構築します。

unordered_multimap(
    const unordered_multimap& right);
explicit unordered_multimap(
    size_type nbuckets = N0,
    const Hash& hfn = Hash(),
    const Pred& comp = Pred(),
    const Alloc& al = Alloc());
template<class InIt>
    unordered_multimap(
    InIt first, InIt last,
    size_type nbuckets = N0,
    const Hash& hfn = Hash(),
    const Pred& comp = Pred(),
    const Alloc& al = Alloc());

パラメータ

Parameter

[Description]

InIt

反復子の型。

al

格納するアロケータ オブジェクト。

comp

格納する比較関数オブジェクト。

hfn

格納するハッシュ関数オブジェクト。

nbuckets

最小バケット数。

right

コピーするコンテナ。

解説

1 つ目のコンストラクタは、right によって制御されるシーケンスのコピーを指定します。2 つ目のコンストラクタは、空の被制御シーケンスのコピーを指定します。3 つ目のコンストラクタは、要素値 [first, last) のシーケンスを挿入します。

さらに、格納された複数の値を初期化する処理が実行されます。この処理は、すべてのコンストラクタに共通です。コピー コンストラクタについては、値が right から取得されます。それ以外の場合は、次のように処理されます。

最小バケット数は、引数 nbuckets が指定されていれば、この引数から取得されます。それ以外の場合は、実装定義の値 (N0) としてここに記述した既定値が使用されます。

ハッシュ関数オブジェクトは、引数 hfn が指定されていれば、この引数から取得されます。それ以外の場合は、Hash() になります。

比較関数オブジェクトは、引数 comp が指定されていれば、この引数から取得されます。それ以外の場合は、Pred() になります。

アロケータ オブジェクトは、引数 al が指定されていれば、この引数から取得されます。それ以外の場合は、Alloc() になります。

使用例

 

// std_tr1__unordered_map__unordered_multimap_construct.cpp 
// compile with: /EHsc 
#include <unordered_map> 
#include <iostream> 
 
typedef std::tr1::unordered_multimap<char, int> Mymap; 
int main() 
    { 
    Mymap c1; 
 
    c1.insert(Mymap::value_type('a', 1)); 
    c1.insert(Mymap::value_type('b', 2)); 
    c1.insert(Mymap::value_type('c', 3)); 
 
// display contents " [c 3] [b 2] [a 1]" 
    for (Mymap::const_iterator it = c1.begin(); 
        it != c1.end(); ++it) 
        std::cout << " [" << it->first << ", " << it->second << "]"; 
    std::cout << std::endl; 
 
    Mymap c2(8, 
        std::tr1::hash<char>(), 
        std::equal_to<char>(), 
        std::allocator<std::pair<const char, int> >()); 
 
    c2.insert(Mymap::value_type('d', 4)); 
    c2.insert(Mymap::value_type('e', 5)); 
    c2.insert(Mymap::value_type('f', 6)); 
 
// display contents " [f 6] [e 5] [d 4]" 
    for (Mymap::const_iterator it = c2.begin(); 
        it != c2.end(); ++it) 
        std::cout << " [" << it->first << ", " << it->second << "]"; 
    std::cout << std::endl; 
 
    Mymap c3(c1.begin(), 
        c1.end(), 
        8, 
        std::tr1::hash<char>(), 
        std::equal_to<char>(), 
        std::allocator<std::pair<const char, int> >()); 
 
// display contents " [c 3] [b 2] [a 1]" 
    for (Mymap::const_iterator it = c3.begin(); 
        it != c3.end(); ++it) 
        std::cout << " [" << it->first << ", " << it->second << "]"; 
    std::cout << std::endl; 
 
    return (0); 
    } 
 
 [c, 3] [b, 2] [a, 1]
 [f, 6] [e, 5] [d, 4]
 [c, 3] [b, 2] [a, 1]

必要条件

ヘッダー : <unordered_map>

名前空間 : std::tr1

参照

参照

<unordered_map>

unordered_multimap クラス