名前空間
変種
操作

std::unordered_multimap<Key,T,Hash,KeyEqual,Allocator>::unordered_multimap

提供: cppreference.com
 
 
 
 
unordered_multimap() : unordered_multimap( size_type(/*implementation-defined*/) ) {}

explicit unordered_multimap( size_type bucket_count,
                             const Hash& hash = Hash(),
                             const key_equal& equal = key_equal(),

                             const Allocator& alloc = Allocator() );
(1)(C++11以上)
unordered_multimap( size_type bucket_count,

                    const Allocator& alloc )
                   : unordered_multimap(bucket_count, Hash(), key_equal(), alloc) {}
unordered_multimap( size_type bucket_count,
                    const Hash& hash,
                    const Allocator& alloc )

                   : unordered_multimap(bucket_count, hash, key_equal(), alloc) {}
(1)(C++14以上)
explicit unordered_multimap( const Allocator& alloc );
(1)(C++11以上)
template< class InputIt >

unordered_multimap( InputIt first, InputIt last,
                    size_type bucket_count = /*implementation-defined*/,
                    const Hash& hash = Hash(),
                    const key_equal& equal = key_equal(),

                    const Allocator& alloc = Allocator() );
(2)(C++11以上)
template< class InputIt >

unordered_multimap( InputIt first, InputIt last,
                    size_type bucket_count,
                    const Allocator& alloc )
                   : unordered_multimap(first, last,

                       bucket_count, Hash(), key_equal(), alloc) {}
(2)(C++14以上)
template< class InputIt >

unordered_multimap( InputIt first, InputIt last,
                    size_type bucket_count,
                    const Hash& hash,
                    const Allocator& alloc )
                   : unordered_multimap(first, last,

                       bucket_count, hash, key_equal(), alloc) {}
(2)(C++14以上)
unordered_multimap( const unordered_multimap& other );
(3)(C++11以上)
unordered_multimap( const unordered_multimap& other, const Allocator& alloc );
(3)(C++11以上)
unordered_multimap( unordered_multimap&& other );
(4)(C++11以上)
unordered_multimap( unordered_multimap&& other, const Allocator& alloc );
(4)(C++11以上)
unordered_multimap( std::initializer_list<value_type> init,

                    size_type bucket_count = /*implementation-defined*/,
                    const Hash& hash = Hash(),
                    const key_equal& equal = key_equal(),

                    const Allocator& alloc = Allocator() );
(5)(C++11以上)
unordered_multimap( std::initializer_list<value_type> init,

                    size_type bucket_count,
                    const Allocator& alloc )
                   : unordered_multimap(init, bucket_count,

                       Hash(), key_equal(), alloc) {}
(5)(C++14以上)
unordered_multimap( std::initializer_list<value_type> init,

                    size_type bucket_count,
                    const Hash& hash,
                    const Allocator& alloc )
                   : unordered_multimap(init, bucket_count,

                       hash, key_equal(), alloc) {}
(5)(C++14以上)

様々なデータソースから新しいコンテナを構築します。 オプションで作成する最小バケット数 bucket_count、ハッシュ関数 hash、キーを比較するための関数 equal、アロケータ alloc を指定できます。

1) 空のコンテナを構築します。 max_load_factor() は 1.0 に設定されます。 デフォルトコンストラクタの場合、バケット数は処理系定義です。
2) 範囲 [first, last) の内容を持つコンテナを構築します。 max_load_factor() は 1.0 に設定されます。
3) コピーコンストラクタ。 other の内容のコピーを持つコンテナを構築します。 負荷係数、述語、ハッシュ関数も同様にコピーされます。 alloc が指定されない場合、アロケータは std::allocator_traits<allocator_type>::select_on_container_copy_construction(other.get_allocator()) を呼ぶことによって取得されます。
4) ムーブコンストラクタ。 ムーブセマンティクスを用いて other の内容を持つコンテナを構築します。 alloc が指定されない場合、アロケータは other の持つアロケータからムーブ構築によって取得されます。
5) 初期化子リスト init の内容を持つコンテナを構築します。 unordered_multimap(init.begin(), init.end()) と同様です。

目次

[編集] 引数

alloc-このコンテナのすべてのメモリ確保に使用するアロケータ
bucket_count-初期化時に使用する最小バケット数。 指定されない場合は処理系定義のデフォルト値が使われます
hash-使用するハッシュ関数
equal-このコンテナのすべてのキー比較のために使用する比較関数
first, last-要素をコピーする範囲
other-コンテナの要素を初期化するためのソースとして使用される別のコンテナ
init-コンテナの要素を初期化するための初期化子リスト
型の要件
-
InputItLegacyInputIterator の要件を満たさなければなりません。

[編集] 計算量

1) 一定。
2) 平均的なケースでは firstlast の距離に比例。 ワーストケースではその二乗。
3) other のサイズに比例。
4) 一定。 alloc が指定されていて alloc != other.get_allocator() の場合は比例。
5) 平均的なケースでは init のサイズに比例。 ワーストケースではその二乗。

[編集] 例外

Allocator::allocate の呼び出しは例外を投げるかもしれません。

[編集] ノート

コンテナのムーブ構築 (オーバーロード (4)) の後、 other を指す参照、ポインタ、イテレータ (終端イテレータは除く) は有効なまま残りますが、以後 *this 内の要素を指すようになります。 現行の標準ではこの保証は [container.requirements.general]/12 の包括的な文言によってなされていますが、より直接的な保証が LWG 2321 で検討されています。

[編集]

[編集] 欠陥報告

以下の動作変更欠陥報告は以前に発行された C++ 標準に遡って適用されました。

DR適用先発行時の動作正しい動作
LWG 2193C++11the default constructor is explicitmade non-explicit


[編集] 関連項目

コンテナに値を代入します
(パブリックメンバ関数) [edit]