Line data Source code
1 : // Author(s): Jan Friso Groote
2 : // Copyright: see the accompanying file COPYING or copy at
3 : // https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4 : //
5 : // Distributed under the Boost Software License, Version 1.0.
6 : // (See accompanying file LICENSE_1_0.txt or copy at
7 : // http://www.boost.org/LICENSE_1_0.txt)
8 : //
9 : //
10 : /// \file mcrl2/atermpp/standard_containers/detail/unordered_map_implementation.h
11 : /// \brief This file contains an implementation of the hash function
12 : /// to break circular header dependencies.
13 :
14 : #ifndef MCRL2_ATERMPP_STANDARD_CONTAINER_DETAIL_UNORDERED_MAP_IMPLEMENTATION_H
15 : #define MCRL2_ATERMPP_STANDARD_CONTAINER_DETAIL_UNORDERED_MAP_IMPLEMENTATION_H
16 :
17 : #include "mcrl2/atermpp/standard_containers/unordered_map.h"
18 : #include "mcrl2/atermpp/detail/thread_aterm_pool.h"
19 : #include "mcrl2/utilities/shared_mutex.h"
20 :
21 : namespace atermpp
22 : {
23 :
24 : template< class Key, class T, class Hash, class Pred, class Alloc >
25 : void unordered_map<Key,T,Hash,Pred,Alloc>::clear() noexcept
26 : {
27 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
28 : super::clear();
29 : }
30 :
31 : /// \brief Inserts an element referring to a default value in the map.
32 : template< class Key, class T, class Hash, class Pred, class Alloc >
33 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator,bool> unordered_map<Key,T,Hash,Pred,Alloc>::insert( const value_type& value )
34 : {
35 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
36 : return super::insert(value);
37 : }
38 :
39 : template< class Key, class T, class Hash, class Pred, class Alloc >
40 : template< class P >
41 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator,bool> unordered_map<Key,T,Hash,Pred,Alloc>::insert( P&& value )
42 : {
43 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
44 : return super::insert(value);
45 : }
46 :
47 : template< class Key, class T, class Hash, class Pred, class Alloc >
48 : typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator unordered_map<Key,T,Hash,Pred,Alloc>::insert( const_iterator hint, const value_type& value )
49 : {
50 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
51 : return super::insert(hint, value);
52 : }
53 :
54 : template< class Key, class T, class Hash, class Pred, class Alloc >
55 : template< class P >
56 : typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator unordered_map<Key,T,Hash,Pred,Alloc>::insert( const_iterator hint, P&& value )
57 : {
58 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
59 : return super::insert(hint, value);
60 : }
61 :
62 : template< class Key, class T, class Hash, class Pred, class Alloc >
63 : template< class InputIt >
64 : void unordered_map<Key,T,Hash,Pred,Alloc>::insert( InputIt first, InputIt last )
65 : {
66 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
67 : super::insert(first, last);
68 : }
69 :
70 : template< class Key, class T, class Hash, class Pred, class Alloc >
71 : void unordered_map<Key,T,Hash,Pred,Alloc>::insert( std::initializer_list<value_type> ilist )
72 : {
73 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
74 : super::insert(ilist);
75 : }
76 :
77 : template< class Key, class T, class Hash, class Pred, class Alloc >
78 : typename unordered_map<Key,T,Hash,Pred,Alloc>::insert_return_type unordered_map<Key,T,Hash,Pred,Alloc>::insert( node_type&& nh )
79 : {
80 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
81 : return super::insert(nh);
82 : }
83 :
84 : template< class Key, class T, class Hash, class Pred, class Alloc >
85 : typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator unordered_map<Key,T,Hash,Pred,Alloc>::insert( const_iterator hint, node_type&& nh )
86 : {
87 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
88 : return super::insert(hint, nh);
89 : }
90 :
91 : template< class Key, class T, class Hash, class Pred, class Alloc >
92 : template <class M>
93 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator, bool> unordered_map<Key,T,Hash,Pred,Alloc>::insert_or_assign( const Key& k, M&& obj )
94 : {
95 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
96 : return super::insert_or_assign(k, obj);
97 : }
98 :
99 : template< class Key, class T, class Hash, class Pred, class Alloc >
100 : template <class M>
101 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator, bool> unordered_map<Key,T,Hash,Pred,Alloc>::insert_or_assign( Key&& k, M&& obj )
102 : {
103 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
104 : return super::insert_or_assign(k, obj);
105 : }
106 :
107 : template< class Key, class T, class Hash, class Pred, class Alloc >
108 : template <class M>
109 : typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator unordered_map<Key,T,Hash,Pred,Alloc>::insert_or_assign( const_iterator hint, const Key& k, M&& obj )
110 : {
111 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
112 : return super::insert_or_assign(hint, k, obj);
113 : }
114 :
115 : template< class Key, class T, class Hash, class Pred, class Alloc >
116 : template <class M>
117 : typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator unordered_map<Key,T,Hash,Pred,Alloc>::insert_or_assign( const_iterator hint, Key&& k, M&& obj )
118 : {
119 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
120 : return super::insert_or_assign(hint, k, obj);
121 : }
122 :
123 : template< class Key, class T, class Hash, class Pred, class Alloc >
124 : template< class... Args >
125 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator,bool> unordered_map<Key,T,Hash,Pred,Alloc>::emplace( Args&&... args )
126 : {
127 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
128 : return super::emplace(args...);
129 : }
130 :
131 : template< class Key, class T, class Hash, class Pred, class Alloc >
132 : template <class... Args>
133 : typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator unordered_map<Key,T,Hash,Pred,Alloc>::emplace_hint( const_iterator hint, Args&&... args )
134 : {
135 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
136 : return super::emplace_hint(hint, args...);
137 : }
138 :
139 : template< class Key, class T, class Hash, class Pred, class Alloc >
140 : template< class... Args >
141 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator, bool> unordered_map<Key,T,Hash,Pred,Alloc>::try_emplace( const Key& k, Args&&... args )
142 : {
143 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
144 : return super::try_emplace(k, args...);
145 : }
146 :
147 : template< class Key, class T, class Hash, class Pred, class Alloc >
148 : template< class... Args >
149 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator, bool> unordered_map<Key,T,Hash,Pred,Alloc>::try_emplace( Key&& k, Args&&... args )
150 : {
151 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
152 : return super::try_emplace(k, args...);
153 : }
154 :
155 : template< class Key, class T, class Hash, class Pred, class Alloc >
156 : template< class... Args >
157 : typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator unordered_map<Key,T,Hash,Pred,Alloc>::try_emplace( const_iterator hint, const Key& k, Args&&... args )
158 : {
159 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
160 : return super::try_emplace(hint, k, args...);
161 : }
162 :
163 : template< class Key, class T, class Hash, class Pred, class Alloc >
164 : template< class... Args >
165 : typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator unordered_map<Key,T,Hash,Pred,Alloc>::try_emplace( const_iterator hint, Key&& k, Args&&... args )
166 : {
167 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
168 : return super::try_emplace(hint, k, args...);
169 : }
170 :
171 : template< class Key, class T, class Hash, class Pred, class Alloc >
172 : typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator unordered_map<Key,T,Hash,Pred,Alloc>::erase( iterator pos )
173 : {
174 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
175 : return super::erase(pos);
176 : }
177 :
178 : template< class Key, class T, class Hash, class Pred, class Alloc >
179 : typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator unordered_map<Key,T,Hash,Pred,Alloc>::erase( const_iterator pos )
180 : {
181 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
182 : return super::erase(pos);
183 : }
184 :
185 : template< class Key, class T, class Hash, class Pred, class Alloc >
186 : typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator unordered_map<Key,T,Hash,Pred,Alloc>::erase( const_iterator first, const_iterator last )
187 : {
188 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
189 : return super::erase(first, last);
190 : }
191 :
192 : template< class Key, class T, class Hash, class Pred, class Alloc >
193 : typename unordered_map<Key,T,Hash,Pred,Alloc>::size_type unordered_map<Key,T,Hash,Pred,Alloc>::erase( const Key& key )
194 : {
195 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
196 : return super::erase(key);
197 : }
198 :
199 : template< class Key, class T, class Hash, class Pred, class Alloc >
200 : void unordered_map<Key,T,Hash,Pred,Alloc>::swap( unordered_map& other )
201 : {
202 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
203 : super::swap(other);
204 : }
205 :
206 : template< class Key, class T, class Hash, class Pred, class Alloc >
207 : typename unordered_map<Key,T,Hash,Pred,Alloc>::node_type unordered_map<Key,T,Hash,Pred,Alloc>::extract( const_iterator position )
208 : {
209 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
210 : return extract(position);
211 : }
212 :
213 : template< class Key, class T, class Hash, class Pred, class Alloc >
214 : typename unordered_map<Key,T,Hash,Pred,Alloc>::node_type unordered_map<Key,T,Hash,Pred,Alloc>::extract( const Key& k )
215 : {
216 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
217 : return extract(k);
218 : }
219 :
220 : template< class Key, class T, class Hash, class Pred, class Alloc >
221 : template<class H2, class P2>
222 : void unordered_map<Key,T,Hash,Pred,Alloc>::merge( std::unordered_map<Key, T, H2, P2, allocator_type>& source )
223 : {
224 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
225 : return merge(source);
226 : }
227 :
228 : template< class Key, class T, class Hash, class Pred, class Alloc >
229 : template<class H2, class P2>
230 : void unordered_map<Key,T,Hash,Pred,Alloc>::merge( std::unordered_map<Key, T, H2, P2, allocator_type>&& source )
231 : {
232 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
233 : return merge(source);
234 : }
235 :
236 : template< class Key, class T, class Hash, class Pred, class Alloc >
237 : template<class H2, class P2>
238 : void unordered_map<Key,T,Hash,Pred,Alloc>::merge( std::unordered_multimap<Key, T, H2, P2, allocator_type>& source )
239 : {
240 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
241 : return merge(source);
242 : }
243 :
244 : template< class Key, class T, class Hash, class Pred, class Alloc >
245 : template<class H2, class P2>
246 : void unordered_map<Key,T,Hash,Pred,Alloc>::merge( std::unordered_multimap<Key, T, H2, P2, allocator_type>&& source )
247 : {
248 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
249 : return merge(source);
250 : }
251 :
252 : template< class Key, class T, class Hash, class Pred, class Alloc >
253 : typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator unordered_map<Key,T,Hash,Pred,Alloc>::begin()
254 : {
255 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
256 : return super::begin();
257 : }
258 :
259 : template< class Key, class T, class Hash, class Pred, class Alloc >
260 19721037 : typename unordered_map<Key,T,Hash,Pred,Alloc>::iterator unordered_map<Key,T,Hash,Pred,Alloc>::end()
261 : {
262 19721037 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
263 39442074 : return super::end();
264 19721037 : }
265 :
266 : template< class Key, class T, class Hash, class Pred, class Alloc >
267 : typename unordered_map<Key,T,Hash,Pred,Alloc>::const_iterator unordered_map<Key,T,Hash,Pred,Alloc>::begin() const
268 : {
269 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
270 : return super::begin();
271 : }
272 :
273 : template< class Key, class T, class Hash, class Pred, class Alloc >
274 : typename unordered_map<Key,T,Hash,Pred,Alloc>::const_iterator unordered_map<Key,T,Hash,Pred,Alloc>::end() const
275 : {
276 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
277 : return super::end();
278 : }
279 :
280 : template< class Key, class T, class Hash, class Pred, class Alloc >
281 : typename unordered_map<Key,T,Hash,Pred,Alloc>::const_iterator unordered_map<Key,T,Hash,Pred,Alloc>::cbegin() const
282 : {
283 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
284 : return super::cbegin();
285 : }
286 :
287 : template< class Key, class T, class Hash, class Pred, class Alloc >
288 : typename unordered_map<Key,T,Hash,Pred,Alloc>::const_iterator unordered_map<Key,T,Hash,Pred,Alloc>::cend() const
289 : {
290 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
291 : return super::cend();
292 : }
293 :
294 : template< class Key, class T, class Hash, class Pred, class Alloc >
295 : bool unordered_map<Key,T,Hash,Pred,Alloc>::empty() const noexcept
296 : {
297 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
298 : return super::empty();
299 : }
300 :
301 : template< class Key, class T, class Hash, class Pred, class Alloc >
302 : typename unordered_map<Key,T,Hash,Pred,Alloc>::size_type unordered_map<Key,T,Hash,Pred,Alloc>::max_size() const noexcept
303 : {
304 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
305 : return super::max_size();
306 : }
307 : } // namespace atermpp
308 :
309 : namespace atermpp::utilities {
310 :
311 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
312 547 : inline void unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::rehash(std::size_t new_size )
313 : {
314 : if constexpr (ThreadSafe)
315 : {
316 138 : mcrl2::utilities::lock_guard guard = detail::g_thread_term_pool().lock();
317 138 : super::rehash(new_size);
318 138 : }
319 : else
320 : {
321 409 : super::rehash(new_size);
322 : }
323 547 : }
324 :
325 :
326 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
327 103514 : inline void unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::rehash_if_needed()
328 : {
329 : // These functions are not thread safe.
330 103514 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
331 103514 : std::size_t count = super::bucket_count();
332 103514 : if (super::load_factor() >= super::max_load_factor())
333 : {
334 547 : guard.unlock_shared();
335 547 : rehash(count* 2);
336 : }
337 103514 : }
338 :
339 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
340 : void unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::clear() noexcept
341 : {
342 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
343 : super::clear();
344 : }
345 :
346 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
347 : template<typename ...Args>
348 723016 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::find(const Args&... args)
349 : {
350 : if constexpr (ThreadSafe)
351 : {
352 13519 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
353 13519 : return super::find(args...);
354 13519 : }
355 709497 : return super::find(args...);
356 : }
357 :
358 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
359 : template<typename ...Args>
360 25345 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::const_iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::find(const Args&... args) const
361 : {
362 : if (ThreadSafe)
363 : {
364 137 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
365 137 : return super::find(args...);
366 137 : }
367 25208 : return super::find(args...);
368 : }
369 :
370 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
371 3892 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator, bool> unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::insert(const value_type& value)
372 : {
373 3892 : rehash_if_needed();
374 3892 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
375 7784 : return super::insert(value);
376 3892 : }
377 :
378 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
379 : template< class P >
380 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator, bool> unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::insert(P&& value)
381 : {
382 : rehash_if_needed();
383 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
384 : return super::insert(value);
385 : }
386 :
387 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
388 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::insert(const_iterator hint, value_type&& value)
389 : {
390 : rehash_if_needed();
391 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
392 : return super::insert(hint, value);
393 : }
394 :
395 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
396 : template< class P >
397 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::insert(const_iterator hint, P&& value)
398 : {
399 : rehash_if_needed();
400 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
401 : return super::insert(hint, value);
402 : }
403 :
404 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
405 : template< class InputIt >
406 : void unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::insert(InputIt first, InputIt last)
407 : {
408 : rehash_if_needed();
409 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
410 : super::insert(first, last);
411 : }
412 :
413 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
414 : void unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::insert(std::initializer_list<value_type> ilist)
415 : {
416 : rehash_if_needed();
417 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
418 : super::insert(ilist);
419 : }
420 :
421 : /*
422 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
423 : insert_return_type insert(node_type&& nh)
424 : {
425 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
426 : return super::insert(nh);
427 : }
428 :
429 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
430 : iterator insert(const_iterator hint, node_type&& nh)
431 : {
432 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
433 : return super::insert(hint, nh);
434 : }
435 : */
436 :
437 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
438 : template <class M>
439 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator, bool> unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::insert_or_assign(const Key& k, M&& obj)
440 : {
441 : rehash_if_needed();
442 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
443 : return super::insert_or_assign(k, obj);
444 : }
445 :
446 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
447 : template <class M>
448 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator, bool> unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::insert_or_assign(Key&& k, M&& obj)
449 : {
450 : rehash_if_needed();
451 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
452 : return super::insert_or_assign(k, obj);
453 : }
454 :
455 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
456 : template <class M>
457 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::insert_or_assign(const_iterator hint, const Key& k, M&& obj)
458 : {
459 : rehash_if_needed();
460 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
461 : return super::insert_or_assign(hint, k, obj);
462 : }
463 :
464 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
465 : template <class M>
466 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::insert_or_assign(const_iterator hint, Key&& k, M&& obj)
467 : {
468 : rehash_if_needed();
469 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
470 : return super::insert_or_assign(hint, k, obj);
471 : }
472 :
473 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
474 : template< class... Args >
475 99622 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator, bool> unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::emplace(Args&&... args)
476 : {
477 99622 : rehash_if_needed();
478 99622 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
479 199244 : return super::emplace(args...);
480 99622 : }
481 :
482 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
483 : template <class... Args>
484 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::emplace_hint(const_iterator hint, Args&&... args)
485 : {
486 : rehash_if_needed();
487 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
488 : return super::emplace(hint, args...);
489 : }
490 :
491 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
492 : template< class... Args >
493 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator, bool> unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::try_emplace(const Key& k, Args&&... args)
494 : {
495 : rehash_if_needed();
496 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
497 : return super::try_emplace(k, args...);
498 : }
499 :
500 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
501 : template< class... Args >
502 : std::pair<typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator, bool> unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::try_emplace(Key&& k, Args&&... args)
503 : {
504 : rehash_if_needed();
505 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
506 : return super::try_emplace(k, args...);
507 : }
508 :
509 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
510 : template< class... Args >
511 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::try_emplace(const_iterator hint, const Key& k, Args&&... args)
512 : {
513 : rehash_if_needed();
514 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
515 : return super::try_emplace(hint, k, args...);
516 : }
517 :
518 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
519 : template< class... Args >
520 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::try_emplace(const_iterator hint, Key&& k, Args&&... args)
521 : {
522 : rehash_if_needed();
523 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
524 : return super::try_emplace(hint, k, args...);
525 : }
526 :
527 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
528 86323 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::erase(iterator pos)
529 : {
530 86323 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
531 172646 : return super::erase(pos);
532 86323 : }
533 :
534 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
535 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::erase(const_iterator pos)
536 : {
537 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
538 : return super::erase(pos);
539 : }
540 :
541 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
542 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::erase(const_iterator first, const_iterator last)
543 : {
544 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
545 : return super::erase(first, last);
546 : }
547 :
548 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
549 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::size_type unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::erase(const Key& key)
550 : {
551 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
552 : return super::erase(key);
553 : }
554 :
555 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
556 : void unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::swap(unordered_map& other)
557 : {
558 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
559 : super::swap(other);
560 : }
561 :
562 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
563 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::begin()
564 : {
565 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
566 : return super::begin();
567 : }
568 :
569 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
570 723016 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::end()
571 : {
572 723016 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
573 1446032 : return super::end();
574 723016 : }
575 :
576 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
577 262 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::const_iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::begin() const
578 : {
579 262 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
580 524 : return super::begin();
581 262 : }
582 :
583 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
584 25607 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::const_iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::end() const
585 : {
586 25607 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
587 51214 : return super::end();
588 25607 : }
589 :
590 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
591 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::const_iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::cbegin() const
592 : {
593 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
594 : return super::cbegin();
595 : }
596 :
597 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
598 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::const_iterator unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::cend() const
599 : {
600 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
601 : return super::cend();
602 : }
603 :
604 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
605 88648 : bool unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::empty() const noexcept
606 : {
607 88648 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
608 88648 : return super::empty();
609 88648 : }
610 :
611 : template< class Key, class T, class Hash, class Pred, class Alloc, bool ThreadSafe >
612 : typename unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::size_type unordered_map<Key,T,Hash,Pred,Alloc,ThreadSafe>::max_size() const noexcept
613 : {
614 : mcrl2::utilities::shared_guard guard = detail::g_thread_term_pool().lock_shared();
615 : return super::max_size();
616 : }
617 : } // namespace atermpp::utilities
618 :
619 : #endif // MCRL2_ATERMPP_STANDARD_CONTAINER_DETAIL_UNORDERED_MAP_IMPLEMENTATION_H
|