.. SPDX-FileCopyrightText: 2019-2021 Intel Corporation .. .. SPDX-License-Identifier: CC-BY-4.0 =================== concurrent_hash_map =================== **[containers.concurrent_hash_map]** ``concurrent_hash_map`` is a class template for an unordered associative container that holds key-value pairs with unique keys and supports concurrent insertion, lookup, and erasure. Class Template Synopsis ----------------------- .. code:: cpp // Defined in header namespace oneapi { namespace tbb { template , typename Allocator = tbb_allocator>> class concurrent_hash_map { public: using key_type = Key; using mapped_type = T; using value_type = std::pair; using reference = value_type&; using const_reference = const value_type&; using pointer = typename std::allocator_traits::pointer; using const_pointer = typename std::allocator_traits::const_pointer; using hash_compare_type = HashCompare; using allocator_type = Allocator; using size_type = ; using difference_type = ; using iterator = ; using const_iterator = ; using range_type = ; using const_range_type = ; class accessor; class const_accessor; // Construction, destruction, copying concurrent_hash_map(); explicit concurrent_hash_map( const hash_compare_type& compare, const allocator_type& alloc = allocator_type() ); explicit concurrent_hash_map( const allocator_type& alloc ); concurrent_hash_map( size_type n, const hash_compare_type& compare, const allocator_type& alloc = allocator_type() ); concurrent_hash_map( size_type n, const allocator_type& alloc = allocator_type() ); template concurrent_hash_map( InputIterator first, InputIterator last, const hash_compare_type& compare, const allocator_type& alloc = allocator_type() ); template concurrent_hash_map( InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type() ); concurrent_hash_map( std::initializer_list init, const hash_compare_type& compare = hash_compare_type(), const allocator_type& alloc = allocator_type() ); concurrent_hash_map( std::initializer_list init, const allocator_type& alloc ); concurrent_hash_map( const concurrent_hash_map& other ); concurrent_hash_map( const concurrent_hash_map& other, const allocator_type& alloc ); concurrent_hash_map( concurrent_hash_map&& other ); concurrent_hash_map( concurrent_hash_map&& other, const allocator_type& alloc ); ~concurrent_hash_map(); concurrent_hash_map& operator=( const concurrent_hash_map& other ); concurrent_hash_map& operator=( concurrent_hash_map&& other ); concurrent_hash_map& operator=( std::initializer_list init ); allocator_type get_allocator() const; // Concurrently unsafe modifiers void clear(); void swap( concurrent_hash_map& other ); // Hash policy void rehash( size_type sz = 0 ); size_type bucket_count() const; // Size and capacity size_type size() const; bool empty() const; size_type max_size() const; // Lookup bool find( const_accessor& result, const key_type& key ) const; bool find( accessor& result, const key_type& key ); template bool find( const_accessor& result, const K& key ) const; template bool find( accessor& result, const K& key ); size_type count( const key_type& key ) const; template size_type count( const K& key ) const; // Modifiers bool insert( const_accessor& result, const key_type& key ); bool insert( accessor& result, const key_type& key ); template bool insert( const_accessor& result, const K& key ); template bool insert( accessor& result, const K& key ); bool insert( const_accessor& result, const value_type& value ); bool insert( accessor& result, const value_type& value ); bool insert( const_accessor& result, value_type&& value ); bool insert( accessor& result, value_type&& value ); bool insert( const value_type& value ); bool insert( value_type&& value ); template void insert( InputIterator first, InputIterator last ); void insert( std::initializer_list init ); template bool emplace( const_accessor& result, Args&&... args ); template bool emplace( accessor& result, Args&&... args ); template bool emplace( Args&&... args ); bool erase( const key_type& key ); template bool erase( const K& key ); bool erase( const_accessor& item_accessor ); bool erase( accessor& item_accessor ); // Iterators iterator begin(); const_iterator begin() const; const_iterator cbegin() const; iterator end(); const_iterator end() const; const_iterator cend() const; std::pair equal_range( const key_type& key ); std::pair equal_range( const key_type& key ) const; template std::pair equal_range( const K& key ); template std::pair equal_range( const K& key ) const; // Parallel iteration range_type range( std::size_t grainsize = 1 ); const_range_type range( std::size_t grainsize = 1 ) const; }; // class concurrent_hash_map } // namespace tbb } // namespace oneapi Requirements: * The expression ``std::allocator_type::destroy(m, val)``, where ``m`` is an object of the type ``Allocator`` and ``val`` is an object of type ``value_type``, must be well-formed. Member functions can impose stricter requirements depending on the type of the operation. * The type ``HashCompare`` must meet the :doc:`HashCompare requirements <../named_requirements/containers/hash_compare>`. * The type ``Allocator`` must meet the ``Allocator`` requirements from the [allocator.requirements] ISO C++ Standard section. Member classes -------------- .. toctree:: :maxdepth: 1 concurrent_hash_map_cls/accessors.rst Member functions ---------------- .. toctree:: :maxdepth: 1 concurrent_hash_map_cls/construct_destroy_copy.rst concurrent_hash_map_cls/unsafe_modifiers.rst concurrent_hash_map_cls/hash_policy.rst concurrent_hash_map_cls/size_and_capacity.rst concurrent_hash_map_cls/lookup.rst concurrent_hash_map_cls/modifiers.rst concurrent_hash_map_cls/iterators.rst concurrent_hash_map_cls/parallel_iteration.rst Non-member functions -------------------- These functions provide binary comparison and swap operations on ``oneapi::tbb::concurrent_hash_map`` objects. The exact namespace where these functions are defined is unspecified, as long as they may be used in respective comparison operations. For example, an implementation may define the classes and functions in the same internal namespace and define ``oneapi::tbb::concurrent_hash_map`` as a type alias for which the non-member functions are reachable only via argument-dependent lookup. .. code:: cpp template bool operator==( const concurrent_hash_map& lhs, const concurrent_hash_map& rhs ); template bool operator!=( const concurrent_hash_map& lhs, const concurrent_hash_map& rhs ); template void swap( concurrent_hash_map& lhs, concurrent_hash_map& rhs ); .. toctree:: :maxdepth: 1 concurrent_hash_map_cls/non_member_swap.rst concurrent_hash_map_cls/non_member_binary_comparisons.rst Other ----- .. toctree:: :maxdepth: 1 concurrent_hash_map_cls/deduction_guides.rst