Namespaces
Variants

std::unordered_multiset<Key,Hash,KeyEqual,Allocator>:: unordered_multiset

From cppreference.net

(注:このHTML要素には翻訳対象のテキストコンテンツが含まれていないため、元の構造をそのまま保持しています)
(1)
unordered_multiset ( )
: unordered_multiset ( size_type ( /* 未指定 */ ) ) { }
(C++11以降)
(C++20まで)
unordered_multiset ( ) ;
(C++20以降)
explicit unordered_multiset ( size_type bucket_count,

const Hash & hash = Hash ( ) ,
const key_equal & equal = key_equal ( ) ,

const Allocator & alloc = Allocator ( ) ) ;
(2) (C++11以降)
unordered_multiset ( size_type bucket_count,

const Allocator & alloc )

: unordered_multiset ( bucket_count, Hash ( ) , key_equal ( ) , alloc ) { }
(3) (C++14以降)
unordered_multiset ( size_type bucket_count,

const Hash & hash,
const Allocator & alloc )

: unordered_multiset ( bucket_count, hash, key_equal ( ) , alloc ) { }
(4) (C++14以降)
explicit unordered_multiset ( const Allocator & alloc ) ;
(5) (C++11以降)
template < class InputIt >

unordered_multiset ( InputIt first, InputIt last,
size_type bucket_count = /* 未指定 */ ,
const Hash & hash = Hash ( ) ,
const key_equal & equal = key_equal ( ) ,

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

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

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

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

bucket_count, hash, key_equal ( ) , alloc ) { }
(8) (C++14以降)
unordered_multiset ( const unordered_multiset & other ) ;
(9) (C++11以降)
unordered_multiset ( const unordered_multiset & other, const Allocator & alloc ) ;
(10) (C++11以降)
unordered_multiset ( unordered_multiset && other ) ;
(11) (C++11以降)
unordered_multiset ( unordered_multiset && other, const Allocator & alloc ) ;
(12) (C++11以降)
unordered_multiset ( std:: initializer_list < value_type > init,

size_type bucket_count = /* 未指定 */ ,
const Hash & hash = Hash ( ) ,
const key_equal & equal = key_equal ( ) ,

const Allocator & alloc = Allocator ( ) ) ;
(13) (C++11以降)
unordered_multiset ( std:: initializer_list < value_type > init,

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

Hash ( ) , key_equal ( ) , alloc ) { }
(14) (C++14以降)
unordered_multiset ( std:: initializer_list < value_type > init,

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

hash, key_equal ( ) , alloc ) { }
(15) (C++14以降)
template < container-compatible-range < value_type > R >

unordered_multiset ( std:: from_range_t , R && rg,
size_type bucket_count = /* 詳細を参照 */ ,
const Hash & hash = Hash ( ) ,
const key_equal & equal = key_equal ( ) ,

const Allocator & alloc = Allocator ( ) ) ;
(16) (C++23以降)
template < container-compatible-range < value_type > R >

unordered_multiset ( std:: from_range_t , R && rg,
size_type bucket_count,
const Allocator & alloc )
: unordered_multiset ( std:: from_range , std:: forward < R > ( rg ) ,

bucket_count, Hash ( ) , key_equal ( ) , alloc ) { }
(17) (C++23以降)
template < container-compatible-range < value_type > R >

unordered_multiset ( std:: from_range_t , R && rg,
size_type bucket_count,
const Hash & hash,
const Alloc & alloc )
: unordered_multiset ( std:: from_range , std:: forward < R > ( rg ) ,

bucket_count, hash, key_equal ( ) , alloc ) { }
(18) (C++23以降)

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

1-5) 空のコンテナを構築します。 max_load_factor() 1.0 に設定します。デフォルトコンストラクタの場合、バケット数は未指定です。
6-8) 範囲 [ first , last ) の内容でコンテナを構築します。 max_load_factor() 1.0 に設定します。
9,10) コピーコンストラクタ。コンテナを other の内容のコピーで構築し、負荷係数、述語、およびハッシュ関数もコピーします。 alloc が提供されない場合、アロケータは std:: allocator_traits < allocator_type > :: select_on_container_copy_construction ( other. get_allocator ( ) ) を呼び出すことで取得されます。

テンプレートパラメータ Allocator は、 クラステンプレート引数推論 で使用される場合、最初の引数からのみ推論されます。

(C++23以降)
11,12) ムーブコンストラクタ . other の内容をムーブセマンティクスを使用してコンテナを構築します。 alloc が提供されない場合、アロケータは other に属するアロケータからのムーブ構築によって取得されます。

テンプレートパラメータ Allocator は、 クラステンプレート引数推論 で使用される際、最初の引数からのみ推論されます。

(C++23以降)
13-15) 初期化子リストコンストラクタ . コンテナを初期化子リスト init の内容で構築します。 unordered_multiset ( init. begin ( ) , init. end ( ) ) と同じです。
16-18) コンテナを rg の内容で構築します。

目次

パラメータ

alloc - このコンテナのすべてのメモリ割り当てに使用するアロケータ
bucket_count - 初期化時に使用する最小バケット数。指定されない場合、未規定のデフォルト値が使用される
hash - 使用するハッシュ関数
equal - このコンテナのすべてのキー比較に使用する比較関数
first, last - コピーする要素のソース範囲を定義するイテレータのペア range
rg - コンテナ互換範囲 、すなわち要素が value_type に変換可能な input_range
other - コンテナの要素を初期化するためのソースとして使用する別のコンテナ
init - コンテナの要素を初期化するための初期化子リスト
型要件
-
InputIt LegacyInputIterator の要件を満たさなければならない

計算量

1-5) 定数。
6-8) 平均ケース線形(すなわち O(N) 、ここで N std:: distance ( first, last ) )、最悪ケース二次、すなわち O(N 2 )
9,10) サイズに対して線形 other
11,12) 定数。もし alloc が与えられ、かつ alloc ! = other. get_allocator ( ) の場合、線形。
13-15) 平均ケース O(N) ( N std:: size ( init ) )、最悪ケース O(N 2 )
16-18) 平均ケース O(N) ( N ranges:: distance ( rg ) )、最悪ケース O(N 2 )

例外

Allocator::allocate への呼び出しは例外をスローする可能性があります。

注記

After container move construction (overload ( 11,12 ) ), references, pointers, and iterators (other than the end iterator) to other remain valid, but refer to elements that are now in * this . The current standard makes this guarantee via the blanket statement in [container.reqmts]/67 , and a more direct guarantee is under consideration via LWG issue 2321 .

C++23で正式に要求される前から、一部の実装では既にテンプレートパラメータ Allocator 非推定コンテキスト に置いていたものもあります。

機能テスト マクロ 標準 機能
__cpp_lib_containers_ranges 202202L (C++23) レンジ対応 構築と挿入; オーバーロード ( 16-18 )

欠陥報告

以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。

DR 適用対象 公開時の動作 正しい動作
LWG 2193 C++11 デフォルトコンストラクタ ( 1 ) がexplicitであった non-explicitに変更
LWG 2230 C++11 オーバーロード ( 13 ) のセマンティクスが規定されていなかった 規定された

関連項目

コンテナに値を代入する
(公開メンバ関数)