挿入および全検索の並列操作をサポートするセットコンテナー用のテンプレート・クラス。
template <typename Key,
typename Hasher = tbb_hash<Key>,
typename Equality = std::equal_to<Key>,
typename Allocator = tbb::tbb_allocator<Key>
class concurrent_unordered_set;
#include "tbb/concurrent_unordered_set.h"
concurrent_unordered_set は、挿入と全検索の並列操作はサポートしていますが、消去の並列操作はサポートしていません。 インターフェイスには使用可能なロックはありません。 内部的にロックを保持している可能性はありますが、ユーザー定義コードの呼び出し中にロックが保持されることはありません。 次の点を除いて、C++11 の std::unordered_set のセマンティクスと似ています。
C++11 機能を必要とするメソッド (rvalue 参照や std::initializer_list など) は省略されています。
消去メソッドには、並列化セーフでないことを示すプリフィックス unsafe_ が付いています。
バケットメソッドには、挿入操作は並列化セーフでないことを示すプリフィックス unsafe_ が付いています。
挿入メソッドは、一時的なペアを作成することがあります。これは、別のスレッドが同時に同じキーを挿入した場合は破棄されます。
std::list と同様に、新しい項目の挿入はイテレーターを無効にしません。また、すでにマップにある項目の順序を変更することもありません。 挿入操作と全検索操作は並列に処理することができます。
iterator イテレーター型および const_iterator イテレーター型は、前方イテレーターです。
挿入操作は、equal_range によって返されたイテレーターを無効または更新しません。そのため、等価でない項目は範囲の最後に挿入されます。 最初のイテレーターは、挿入操作後も等価な項目を指します。
ほかのハッシュテーブルと同様に、等価なキーのハッシュコードは同じでなければなりません。理想的なハッシュ関数は、キーをハッシュコード空間に均一に分配します。
次のコード例で、太字のメソッドは同時に呼び出すことができます。 例えば、3 つの異なるスレッドが insert、begin、および size を同時に呼び出すことができます。 それぞれの結果は非決定的です。例えば、size の結果は insert 操作の前後では異なります。
template <typename Key,
typename Hasher = tbb_hash<Key>,
typename Equal = std::equal_to<Key>,
typename Allocator = tbb::tbb_allocator<Key>
class concurrent_unordered_set {
public:
// 型
typedef Key key_type;
typedef Key value_type;
typedef Key mapped_type;
typedef Hash hasher;
typedef Equality key_equal;
typedef Alloc allocator_type;
typedef typename allocator_type::pointer pointer;
typedef typename allocator_type::const_pointer const_pointer;
typedef typename allocator_type::reference reference;
typedef typename allocator_type::const_reference const_reference;
typedef implementation-defined size_type;
typedef implementation-defined difference_type;
typedef implementation-defined iterator;
typedef implementation-defined const_iterator;
typedef implementation-defined local_iterator;
typedef implementation-defined const_local_iterator;
// construct/destroy/copy
explicit concurrent_unordered_set(size_type n = implementation-defined,
const Hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
template <typename InputIterator>
concurrent_unordered_set(
InputIterator first, InputIterator last,
size_type n = implementation-defined,
const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
concurrent_unordered_set(const concurrent_unordered_set&);
concurrent_unordered_set(const Alloc&);
concurrent_unordered_set(const concurrent_unordered_set&, const Alloc&);
~concurrent_unordered_set();
concurrent_unordered_set& operator=( const concurrent_unordered_set&);
allocator_type get_allocator() const;
// サイズとキャパシティー
bool empty() const; // リニア時間になる!
size_type size() const; // リニア時間になる!
size_type max_size() const;
// イテレーター
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
const_iterator cbegin() const;
const_iterator cend() const;
// 修飾子
std::pair<iterator, bool> insert(const value_type& x);
iterator insert(const_iterator hint, const value_type& x);
template<class InputIterator> void insert(InputIterator first,
InputIterator last);
iterator unsafe_erase(const_iterator position);
size_type unsafe_erase(const key_type& k);
iterator unsafe_erase(const_iterator first, const_iterator last);
void clear();
void swap(concurrent_unordered_set&);
// オブザーバー
hasher hash_function() const;
key_equal key_eq() const;
// 検索
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
std::pair<iterator, iterator> equal_range(const key_type& k);
std::pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
// 並列反復
typedef implementation defined range_type;
typedef implementation defined const_range_type;
range_type range();
const_range_type range() const;
// バケット・インターフェイス - デバッグ用
size_type unsafe_bucket_count() const;
size_type unsafe_max_bucket_count() const;
size_type unsafe_bucket_size(size_type n);
size_type unsafe_bucket(const key_type& k) const;
local_iterator unsafe_begin(size_type n);
const_local_iterator unsafe_begin(size_type n) const;
local_iterator unsafe_end(size_type n);
const_local_iterator unsafe_end(size_type n) const;
const_local_iterator unsafe_cbegin(size_type n) const;
const_local_iterator unsafe_cend(size_type n) const;
// ハッシュポリシー
float load_factor() const;
float max_load_factor() const;
void max_load_factor(float z);
void rehash(size_type n);
};