Intel(R) Threading Building Blocks Doxygen Documentation version 4.2.3
concurrent_unordered_set.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2005-2020 Intel Corporation
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/* Container implementations in this header are based on PPL implementations
18 provided by Microsoft. */
19
20#ifndef __TBB_concurrent_unordered_set_H
21#define __TBB_concurrent_unordered_set_H
22
23#define __TBB_concurrent_unordered_set_H_include_area
25
27
28namespace tbb
29{
30
31namespace interface5 {
32
33// Template class for hash set traits
34template<typename Key, typename Hash_compare, typename Allocator, bool Allow_multimapping>
36{
37protected:
38 typedef Key value_type;
39 typedef Key key_type;
40 typedef Hash_compare hash_compare;
42#if __TBB_UNORDERED_NODE_HANDLE_PRESENT
46#endif // __TBB_UNORDERED_NODE_HANDLE_PRESENT
47
48 enum { allow_multimapping = Allow_multimapping };
49
52
53 static const Key& get_key(const value_type& value) {
54 return value;
55 }
56
57 hash_compare my_hash_compare; // the comparator predicate for keys
58};
59
60template<typename Key, typename Hasher, typename Key_equality, typename Allocator>
62
63template <typename Key, typename Hasher = tbb::tbb_hash<Key>, typename Key_equality = std::equal_to<Key>, typename Allocator = tbb::tbb_allocator<Key> >
64class concurrent_unordered_set : public internal::concurrent_unordered_base< concurrent_unordered_set_traits<Key, internal::hash_compare<Key, Hasher, Key_equality>, Allocator, false> >
65{
66 // Base type definitions
70#if __TBB_EXTRA_DEBUG
71public:
72#endif
74public:
76
77 // Type definitions
78 typedef Key key_type;
80 typedef Key mapped_type;
81 typedef Hasher hasher;
82 typedef Key_equality key_equal;
84
86 typedef typename base_type::pointer pointer;
90
93
94 typedef typename base_type::iterator iterator;
98#if __TBB_UNORDERED_NODE_HANDLE_PRESENT
100#endif /*__TBB_UNORDERED_NODE_HANDLE_PRESENT*/
101
102 // Construction/destruction/copying
104 const key_equal& a_keyeq = key_equal(), const allocator_type& a = allocator_type())
105 : base_type(n_of_buckets, key_compare(a_hasher, a_keyeq), a)
106 {}
107
109 : base_type(n_of_buckets, key_compare(hasher(), key_equal()), a)
110 {}
111
112 concurrent_unordered_set(size_type n_of_buckets, const hasher& a_hasher, const allocator_type& a)
113 : base_type(n_of_buckets, key_compare(a_hasher, key_equal()), a)
114 {}
115
117 {}
118
119 template <typename Iterator>
121 const hasher& a_hasher = hasher(), const key_equal& a_keyeq = key_equal(), const allocator_type& a = allocator_type())
122 : base_type(n_of_buckets, key_compare(a_hasher, a_keyeq), a)
123 {
124 insert(first, last);
125 }
126
127 template <typename Iterator>
128 concurrent_unordered_set(Iterator first, Iterator last, size_type n_of_buckets, const allocator_type& a)
129 : base_type(n_of_buckets, key_compare(hasher(), key_equal()), a)
130 {
131 insert(first, last);
132 }
133
134 template <typename Iterator>
135 concurrent_unordered_set(Iterator first, Iterator last, size_type n_of_buckets, const hasher& a_hasher, const allocator_type& a)
136 : base_type(n_of_buckets, key_compare(a_hasher, key_equal()), a)
137 {
138 insert(first, last);
139 }
140
141#if __TBB_INITIALIZER_LISTS_PRESENT
143 concurrent_unordered_set(std::initializer_list<value_type> il, size_type n_of_buckets = base_type::initial_bucket_number, const hasher& a_hasher = hasher(),
144 const key_equal& a_keyeq = key_equal(), const allocator_type& a = allocator_type())
145 : base_type(n_of_buckets, key_compare(a_hasher, a_keyeq), a)
146 {
147 insert(il.begin(),il.end());
148 }
149
150 concurrent_unordered_set(std::initializer_list<value_type> il, size_type n_of_buckets, const allocator_type& a)
151 : base_type(n_of_buckets, key_compare(hasher(), key_equal()), a)
152 {
153 insert(il.begin(), il.end());
154 }
155
156 concurrent_unordered_set(std::initializer_list<value_type> il, size_type n_of_buckets, const hasher& a_hasher, const allocator_type& a)
157 : base_type(n_of_buckets, key_compare(a_hasher, key_equal()), a)
158 {
159 insert(il.begin(), il.end());
160 }
161
162#endif //# __TBB_INITIALIZER_LISTS_PRESENT
163
164#if __TBB_CPP11_RVALUE_REF_PRESENT && !__TBB_IMPLICIT_MOVE_PRESENT
166 : base_type(table)
167 {}
168
170 {
171 return static_cast<concurrent_unordered_set&>(base_type::operator=(table));
172 }
173
175 : base_type(std::move(table))
176 {}
177
179 {
180 return static_cast<concurrent_unordered_set&>(base_type::operator=(std::move(table)));
181 }
182#endif //__TBB_CPP11_RVALUE_REF_PRESENT && !__TBB_IMPLICIT_MOVE_PRESENT
183
184#if __TBB_CPP11_RVALUE_REF_PRESENT
186 : base_type(std::move(table), a)
187 {}
188#endif /*__TBB_CPP11_RVALUE_REF_PRESENT*/
189
190#if __TBB_UNORDERED_NODE_HANDLE_PRESENT
191 template<typename Hash, typename Equality>
193 { this->internal_merge(source); }
194
195 template<typename Hash, typename Equality>
197 { this->internal_merge(source); }
198
199 template<typename Hash, typename Equality>
201 { this->internal_merge(source); }
202
203 template<typename Hash, typename Equality>
205 { this->internal_merge(source); }
206
207#endif //__TBB_UNORDERED_NODE_HANDLE_PRESENT
208
209 concurrent_unordered_set(const concurrent_unordered_set& table, const Allocator& a)
210 : base_type(table, a)
211 {}
212
213};
214
215#if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT
216
217namespace internal {
218using namespace tbb::internal;
219
220template <template<typename...> typename Set, typename T, typename... Args>
221using cu_set_t = Set <
222 T,
223 std::conditional_t< (sizeof...(Args)>0) && !is_allocator_v< pack_element_t<0, Args...> >,
224 pack_element_t<0, Args...>, tbb_hash<T> >,
225 std::conditional_t< (sizeof...(Args)>1) && !is_allocator_v< pack_element_t<1, Args...> >,
226 pack_element_t<1, Args...>, std::equal_to<T> >,
227 std::conditional_t< (sizeof...(Args)>0) && is_allocator_v< pack_element_t<sizeof...(Args)-1, Args...> >,
228 pack_element_t<sizeof...(Args)-1, Args...>, tbb_allocator<T> >
229>;
230}
231
232// Deduction guide for the constructor from two iterators
233template<typename I>
234concurrent_unordered_set(I, I)
235-> internal::cu_set_t<concurrent_unordered_set, internal::iterator_value_t<I>>;
236
237// Deduction guide for the constructor from two iterators and hasher/equality/allocator
238template<typename I, typename... Args>
239concurrent_unordered_set(I, I, size_t, Args...)
240-> internal::cu_set_t<concurrent_unordered_set, internal::iterator_value_t<I>, Args...>;
241
242// Deduction guide for the constructor from an initializer_list
243template<typename T>
244concurrent_unordered_set(std::initializer_list<T>)
245-> internal::cu_set_t<concurrent_unordered_set, T>;
246
247// Deduction guide for the constructor from an initializer_list and hasher/equality/allocator
248template<typename T, typename... Args>
249concurrent_unordered_set(std::initializer_list<T>, size_t, Args...)
250-> internal::cu_set_t<concurrent_unordered_set, T, Args...>;
251
252#endif /*__TBB_CPP17_DEDUCTION_GUIDES_PRESENT */
253
254template <typename Key, typename Hasher = tbb::tbb_hash<Key>, typename Key_equality = std::equal_to<Key>,
255 typename Allocator = tbb::tbb_allocator<Key> >
257 public internal::concurrent_unordered_base< concurrent_unordered_set_traits<Key,
258 internal::hash_compare<Key, Hasher, Key_equality>, Allocator, true> >
259{
260 // Base type definitions
264#if __TBB_EXTRA_DEBUG
265public:
266#endif
268public:
269 using base_type::insert;
270
271 // Type definitions
272 typedef Key key_type;
274 typedef Key mapped_type;
275 typedef Hasher hasher;
276 typedef Key_equality key_equal;
278
280 typedef typename base_type::pointer pointer;
284
287
292#if __TBB_UNORDERED_NODE_HANDLE_PRESENT
294#endif // __TBB_UNORDERED_NODE_HANDLE_PRESENT
295
296 // Construction/destruction/copying
298 const hasher& a_hasher = hasher(), const key_equal& a_keyeq = key_equal(),
299 const allocator_type& a = allocator_type())
300 : base_type(n_of_buckets, key_compare(a_hasher, a_keyeq), a)
301 {}
302
304 : base_type(n_of_buckets, key_compare(hasher(), key_equal()), a)
305 {}
306
307 concurrent_unordered_multiset(size_type n_of_buckets, const hasher& a_hasher,
308 const allocator_type& a)
309 : base_type(n_of_buckets, key_compare(a_hasher, key_equal()), a)
310 {}
311
313 {}
314
315 template <typename Iterator>
317 const hasher& a_hasher = hasher(), const key_equal& a_keyeq = key_equal(),
318 const allocator_type& a = allocator_type())
319 : base_type(n_of_buckets, key_compare(a_hasher, a_keyeq), a)
320 {
321 insert(first, last);
322 }
323
324 template <typename Iterator>
325 concurrent_unordered_multiset(Iterator first, Iterator last, size_type n_of_buckets, const allocator_type& a)
326 : base_type(n_of_buckets, key_compare(hasher(), key_equal()), a)
327 {
328 insert(first, last);
329 }
330
331 template <typename Iterator>
332 concurrent_unordered_multiset(Iterator first, Iterator last, size_type n_of_buckets, const hasher& a_hasher,
333 const allocator_type& a)
334 : base_type(n_of_buckets, key_compare(a_hasher, key_equal()), a)
335 {
336 insert(first, last);
337 }
338
339#if __TBB_INITIALIZER_LISTS_PRESENT
341 concurrent_unordered_multiset(std::initializer_list<value_type> il, size_type n_of_buckets = base_type::initial_bucket_number,
342 const hasher& a_hasher = hasher(), const key_equal& a_keyeq = key_equal(), const allocator_type& a = allocator_type())
343 : base_type(n_of_buckets, key_compare(a_hasher, a_keyeq), a)
344 {
345 insert(il.begin(),il.end());
346 }
347
348 concurrent_unordered_multiset(std::initializer_list<value_type> il, size_type n_of_buckets, const allocator_type& a)
349 : base_type(n_of_buckets, key_compare(hasher(), key_equal()), a)
350 {
351 insert(il.begin(), il.end());
352 }
353
354 concurrent_unordered_multiset(std::initializer_list<value_type> il, size_type n_of_buckets, const hasher& a_hasher,
355 const allocator_type& a)
356 : base_type(n_of_buckets, key_compare(a_hasher, key_equal()), a)
357 {
358 insert(il.begin(), il.end());
359 }
360
361#endif //# __TBB_INITIALIZER_LISTS_PRESENT
362
363
364#if __TBB_CPP11_RVALUE_REF_PRESENT && !__TBB_IMPLICIT_MOVE_PRESENT
366 : base_type(table)
367 {}
368
370 {
371 return static_cast<concurrent_unordered_multiset&>(base_type::operator=(table));
372 }
373
375 : base_type(std::move(table))
376 {}
377
379 {
381 }
382#endif //__TBB_CPP11_RVALUE_REF_PRESENT && !__TBB_IMPLICIT_MOVE_PRESENT
383
384#if __TBB_CPP11_RVALUE_REF_PRESENT
386 : base_type(std::move(table), a)
387 {
388 }
389#endif /*__TBB_CPP11_RVALUE_REF_PRESENT*/
390
391#if __TBB_UNORDERED_NODE_HANDLE_PRESENT
392 template<typename Hash, typename Equality>
394 { this->internal_merge(source); }
395
396 template<typename Hash, typename Equality>
398 { this->internal_merge(source); }
399
400 template<typename Hash, typename Equality>
402 { this->internal_merge(source); }
403
404 template<typename Hash, typename Equality>
406 { this->internal_merge(source); }
407
408#endif //__TBB_UNORDERED_NODE_HANDLE_PRESENT
409
411 : base_type(table, a)
412 {}
413};
414
415#if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT
416
417// Deduction guide for the constructor from two iterators
418template<typename I>
420-> internal::cu_set_t<concurrent_unordered_multiset, internal::iterator_value_t<I>>;
421
422// Deduction guide for the constructor from two iterators and hasher/equality/allocator
423template<typename I, typename... Args>
424concurrent_unordered_multiset(I, I, size_t, Args...)
425-> internal::cu_set_t<concurrent_unordered_multiset, internal::iterator_value_t<I>, Args...>;
426
427// Deduction guide for the constructor from an initializer_list
428template<typename T>
429concurrent_unordered_multiset(std::initializer_list<T>)
430-> internal::cu_set_t<concurrent_unordered_multiset, T>;
431
432// Deduction guide for the constructor from an initializer_list and hasher/equality/allocator
433template<typename T, typename... Args>
434concurrent_unordered_multiset(std::initializer_list<T>, size_t, Args...)
435-> internal::cu_set_t<concurrent_unordered_multiset, T, Args...>;
436
437#endif /* __TBB_CPP17_DEDUCTION_GUIDES_PRESENT */
438} // namespace interface5
439
440using interface5::concurrent_unordered_set;
441using interface5::concurrent_unordered_multiset;
442
443} // namespace tbb
444
446#undef __TBB_concurrent_unordered_set_H_include_area
447
448#endif// __TBB_concurrent_unordered_set_H
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
STL namespace.
The graph class.
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:319
Identifiers declared inside namespace internal should never be used directly by client code.
Definition: atomic.h:65
auto last(Container &c) -> decltype(begin(c))
auto first(Container &c) -> decltype(begin(c))
tbb::internal::node_handle< key_type, key_type, typename internal::split_ordered_list< key_type, allocator_type >::node, allocator_type > node_type
static const Key & get_key(const value_type &value)
tbb::internal::allocator_rebind< Allocator, value_type >::type allocator_type
concurrent_unordered_multiset(std::initializer_list< value_type > il, size_type n_of_buckets=base_type::initial_bucket_number, const hasher &a_hasher=hasher(), const key_equal &a_keyeq=key_equal(), const allocator_type &a=allocator_type())
Constructor from initializer_list.
internal::concurrent_unordered_base< traits_type > base_type
void merge(concurrent_unordered_set< Key, Hash, Equality, Allocator > &source)
concurrent_unordered_multiset(const concurrent_unordered_multiset &table, const Allocator &a)
concurrent_unordered_multiset(size_type n_of_buckets, const allocator_type &a)
void merge(concurrent_unordered_set< Key, Hash, Equality, Allocator > &&source)
void merge(concurrent_unordered_multiset< Key, Hash, Equality, Allocator > &source)
concurrent_unordered_multiset(Iterator first, Iterator last, size_type n_of_buckets, const allocator_type &a)
concurrent_unordered_multiset(size_type n_of_buckets, const hasher &a_hasher, const allocator_type &a)
void merge(concurrent_unordered_multiset< Key, Hash, Equality, Allocator > &&source)
concurrent_unordered_multiset(size_type n_of_buckets=base_type::initial_bucket_number, const hasher &a_hasher=hasher(), const key_equal &a_keyeq=key_equal(), const allocator_type &a=allocator_type())
concurrent_unordered_multiset(std::initializer_list< value_type > il, size_type n_of_buckets, const hasher &a_hasher, const allocator_type &a)
std::pair< iterator, bool > insert(const value_type &value)
concurrent_unordered_multiset(concurrent_unordered_multiset &&table, const Allocator &a)
internal::hash_compare< Key, Hasher, Key_equality > hash_compare
concurrent_unordered_multiset(std::initializer_list< value_type > il, size_type n_of_buckets, const allocator_type &a)
concurrent_unordered_set_traits< Key, hash_compare, Allocator, true > traits_type
concurrent_unordered_multiset(Iterator first, Iterator last, size_type n_of_buckets, const hasher &a_hasher, const allocator_type &a)
concurrent_unordered_multiset(Iterator first, Iterator last, size_type n_of_buckets=base_type::initial_bucket_number, const hasher &a_hasher=hasher(), const key_equal &a_keyeq=key_equal(), const allocator_type &a=allocator_type())
void merge(concurrent_unordered_multiset< Key, Hash, Equality, Allocator > &source)
void merge(concurrent_unordered_set< Key, Hash, Equality, Allocator > &&source)
concurrent_unordered_set(size_type n_of_buckets, const hasher &a_hasher, const allocator_type &a)
concurrent_unordered_set(Iterator first, Iterator last, size_type n_of_buckets, const hasher &a_hasher, const allocator_type &a)
concurrent_unordered_set_traits< Key, hash_compare, Allocator, false > traits_type
void merge(concurrent_unordered_multiset< Key, Hash, Equality, Allocator > &&source)
concurrent_unordered_set(Iterator first, Iterator last, size_type n_of_buckets, const allocator_type &a)
concurrent_unordered_set(concurrent_unordered_set &&table, const Allocator &a)
concurrent_unordered_set(std::initializer_list< value_type > il, size_type n_of_buckets=base_type::initial_bucket_number, const hasher &a_hasher=hasher(), const key_equal &a_keyeq=key_equal(), const allocator_type &a=allocator_type())
Constructor from initializer_list.
internal::hash_compare< Key, Hasher, Key_equality > hash_compare
concurrent_unordered_set(size_type n_of_buckets, const allocator_type &a)
std::pair< iterator, bool > insert(const value_type &value)
internal::concurrent_unordered_base< traits_type > base_type
concurrent_unordered_set(size_type n_of_buckets=base_type::initial_bucket_number, const hasher &a_hasher=hasher(), const key_equal &a_keyeq=key_equal(), const allocator_type &a=allocator_type())
void merge(concurrent_unordered_set< Key, Hash, Equality, Allocator > &source)
concurrent_unordered_set(std::initializer_list< value_type > il, size_type n_of_buckets, const allocator_type &a)
concurrent_unordered_set(std::initializer_list< value_type > il, size_type n_of_buckets, const hasher &a_hasher, const allocator_type &a)
concurrent_unordered_set(const concurrent_unordered_set &table, const Allocator &a)
concurrent_unordered_set(Iterator first, Iterator last, size_type n_of_buckets=base_type::initial_bucket_number, const hasher &a_hasher=hasher(), const key_equal &a_keyeq=key_equal(), const allocator_type &a=allocator_type())
allocator_traits< Alloc >::template rebind_alloc< T >::other type
tbb::internal::allocator_traits< allocator_type >::pointer pointer
tbb::internal::allocator_traits< allocator_type >::difference_type difference_type
tbb::internal::allocator_traits< allocator_type >::const_pointer const_pointer
tbb::internal::allocator_traits< allocator_type >::size_type size_type
std::pair< iterator, bool > insert(const value_type &value)
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
Definition: tbb_allocator.h:58

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.