名前空間
変種
操作

std::unordered_set<Key,Hash,KeyEqual,Allocator>::merge

提供: cppreference.com
 
 
 
 
template<class H2, class P2>
void merge(std::unordered_set<Key, H2, P2, Allocator>& source);
(1) (C++17以上)
template<class H2, class P2>
void merge(std::unordered_set<Key, H2, P2, Allocator>&& source);
(2) (C++17以上)
template<class H2, class P2>
void merge(std::unordered_multiset<Key, H2, P2, Allocator>& source);
(3) (C++17以上)
template<class H2, class P2>
void merge(std::unordered_multiset<Key, H2, P2, Allocator>&& source);
(4) (C++17以上)

source からの要素の抽出 (スプライシング) と、 *this のハッシュ関数および同値述語を使用したその要素の *this への挿入を試みます。 source の持つ要素のキーと同等のキーを持つ要素が *this にある場合、その要素は source から抽出されません。 要素はコピーもムーブもされません。 コンテナのノードの内部ポインタが指し変えられるだけです。 転送される要素を指すすべてのポインタと参照は有効なままですが、 source ではなく *this 内を指すようになります。 転送される要素を指すイテレータおよび *this を参照するすべてのイテレータが無効化されます。 source 内に残っている要素を指すイテレータは有効なままです。

get_allocator()!= source.get_allocator() の場合、動作は未定義です。

目次

[編集]引数

source - ノード転送元の互換なコンテナ

[編集]戻り値

(なし)


[編集]計算量

平均的なケースでは O(N)、ワーストケースでは O(N*size()+N)、ただし N は source.size() です。

[編集]

[編集]関連項目

(C++17)
コンテナからノードを抽出します
(パブリックメンバ関数)[edit]
要素またはノード(C++17以上)を挿入します
(パブリックメンバ関数)[edit]
close