Skip to content

Commit 277329d

Browse files
kboyarinovIvan Kochin
andauthored
[oneTBB] Heterogeneous overloads for concurrent_hash_map (#356)
* Add description for heterogeneous overloads in chmap * Fix PR comments * More minor changes * Fix minor comments from PR * Update source/elements/oneTBB/source/containers/concurrent_hash_map_cls.rst Co-authored-by: Ivan Kochin <kochin.ivan@intel.com> * Minor fix Co-authored-by: Ivan Kochin <kochin.ivan@intel.com>
1 parent d2aac12 commit 277329d

4 files changed

Lines changed: 160 additions & 50 deletions

File tree

source/elements/oneTBB/source/containers/concurrent_hash_map_cls.rst

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,29 @@ Class Template Synopsis
112112
bool find( const_accessor& result, const key_type& key ) const;
113113
bool find( accessor& result, const key_type& key );
114114
115+
template <typename K>
116+
bool find( const_accessor& result, const K& key ) const;
117+
118+
template <typename K>
119+
bool find( accessor& result, const K& key );
120+
115121
size_type count( const key_type& key ) const;
116122
123+
template <typename K>
124+
size_type count( const K& key ) const;
125+
117126
// Modifiers
118127
bool insert( const_accessor& result, const key_type& key );
119128
bool insert( accessor& result, const key_type& key );
120129
130+
template <typename K>
131+
bool insert( const_accessor& result, const K& key );
132+
133+
template <typename K>
134+
bool insert( accessor& result, const K& key );
135+
121136
bool insert( const_accessor& result, const value_type& value );
122137
bool insert( accessor& result, const value_type& value );
123-
124138
bool insert( const_accessor& result, value_type&& value );
125139
bool insert( accessor& result, value_type&& value );
126140
@@ -143,6 +157,9 @@ Class Template Synopsis
143157
144158
bool erase( const key_type& key );
145159
160+
template <typename K>
161+
bool erase( const K& key );
162+
146163
bool erase( const_accessor& item_accessor );
147164
bool erase( accessor& item_accessor );
148165
@@ -158,13 +175,19 @@ Class Template Synopsis
158175
std::pair<iterator, iterator> equal_range( const key_type& key );
159176
std::pair<const_iterator, const_iterator> equal_range( const key_type& key ) const;
160177
178+
template <typename K>
179+
std::pair<iterator, iterator> equal_range( const K& key );
180+
181+
template <typename K>
182+
std::pair<const_iterator, const_iterator> equal_range( const K& key ) const;
183+
161184
// Parallel iteration
162185
range_type range( std::size_t grainsize = 1 );
163186
const_range_type range( std::size_t grainsize = 1 ) const;
164187
}; // class concurrent_hash_map
165188
166189
} // namespace tbb
167-
} // namespace oneapi
190+
} // namespace oneapi
168191
169192
Requirements:
170193

source/elements/oneTBB/source/containers/concurrent_hash_map_cls/iterators.rst

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. SPDX-FileCopyrightText: 2019-2020 Intel Corporation
1+
.. SPDX-FileCopyrightText: 2019-2021 Intel Corporation
22
..
33
.. SPDX-License-Identifier: CC-BY-4.0
44
@@ -48,7 +48,21 @@ equal_range
4848
4949
std::pair<const_iterator, const_iterator> equal_range( const key_type& key ) const;
5050
51-
If an element with the key that is equivalent to ``key`` exists in the container,
52-
a pair of iterators ``{f, l}``, where ``f`` is an iterator to this element,
53-
``l`` is ``std::next(f)``.
54-
Otherwise, ``{end(), end()}``.
51+
**Returns**: a range containing an element that is equivalent to ``key``.
52+
If there is no such element in the container, returns ``{end(), end()}`` .
53+
54+
--------------------------
55+
56+
.. code:: cpp
57+
58+
template <typename K>
59+
std::pair<iterator, iterator> equal_range( const K& key );
60+
61+
template <typename K>
62+
std::pair<const_iterator, const_iterator> equal_range( const K& key ) const;
63+
64+
**Returns**: a range containing an element which compares equivalent to the value ``key``.
65+
If there is no such element in the container, returns ``{end(), end()}``.
66+
67+
This overload only participates in the overload resolution if qualified-id
68+
``hash_compare_type::is_transparent`` is valid and denotes a type.

source/elements/oneTBB/source/containers/concurrent_hash_map_cls/lookup.rst

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. SPDX-FileCopyrightText: 2019-2020 Intel Corporation
1+
.. SPDX-FileCopyrightText: 2019-2021 Intel Corporation
22
..
33
.. SPDX-License-Identifier: CC-BY-4.0
44
@@ -18,12 +18,32 @@ find
1818
1919
bool find( accessor& result, const key_type& key );
2020
21-
If the accessor ``result`` is not empty, releases the ``result``.
21+
If the ``result`` accessor is not empty, releases the ``result``.
2222

2323
If an element with the key that is equivalent to ``key`` exists, sets the ``result`` to provide access
2424
to this element.
2525

26-
**Returns**: ``true`` if an element with the key equivalent to ``key`` is found; ``false``, otherwise.
26+
**Returns**: ``true`` if an element with the key equivalent to ``key`` is found; ``false`` otherwise.
27+
28+
--------------------------
29+
30+
.. code:: cpp
31+
32+
template <typename K>
33+
bool find( const_accessor& result, const K& key ) const;
34+
35+
template <typename K>
36+
bool find( accessor& result, const K& key );
37+
38+
If the ``result`` accessor is not empty, releases the ``result``.
39+
40+
If an element with the key that compares equivalent to the value ``key`` exists, sets the ``result`` to provide access
41+
to this element.
42+
43+
**Returns**: ``true`` if an element with the key that compares equivalent to the value ``key`` is found; ``false`` otherwise.
44+
45+
This overload only participates in the overload resolution if qualified-id
46+
``hash_compare_type::is_transparent`` is valid and denotes a type.
2747

2848
count
2949
-----
@@ -32,4 +52,17 @@ count
3252
3353
size_type count( const key_type& key ) const;
3454
35-
**Returns**: ``1`` if an element with the equivalent to ``key`` exists; ``0``, otherwise.
55+
**Returns**: ``1`` if an element with the key equivalent to ``key`` exists; ``0`` otherwise.
56+
57+
--------------------------
58+
59+
.. code:: cpp
60+
61+
template <typename K>
62+
size_type count( const K& key ) const;
63+
64+
**Returns**: ``1`` if an element with the key that compares equivalent to the value ``key`` exists;
65+
``0`` otherwise.
66+
67+
This overload only participates in the overload resolution if qualified-id
68+
``hash_compare_type::is_transparent`` is valid and denotes a type.

source/elements/oneTBB/source/containers/concurrent_hash_map_cls/modifiers.rst

Lines changed: 79 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. SPDX-FileCopyrightText: 2019-2020 Intel Corporation
1+
.. SPDX-FileCopyrightText: 2019-2021 Intel Corporation
22
..
33
.. SPDX-License-Identifier: CC-BY-4.0
44
@@ -18,18 +18,44 @@ Inserting values
1818
1919
bool insert( accessor& result, const key_type& key );
2020
21-
If the accessor ``result`` is not empty, releases the ``result`` and
21+
If the ``result`` accessor is not empty, releases the ``result`` and
2222
attempts to insert the value constructed from ``key, mapped_type()`` into the container.
2323

24-
Sets the ``result`` to provide access to the inserted element or to the element with equal key
25-
that was already presented in the container.
24+
Sets the ``result`` to provide access to the inserted element or to the element with equal key,
25+
which was already presented in the container.
2626

2727
**Requirements**:
2828

29-
* the type ``value_type`` must meet the ``EmplaceConstructible`` requirements the from [container.requirements] ISO C++ Standard section.
30-
* the type ``mapped_type`` must meet the ``DefaultConstructible`` requirements from the [defaultconstructible] ISO C++ Standard section.
29+
* the ``value_type`` type must meet the ``EmplaceConstructible`` requirements described in the [container.requirements] section of the ISO C++ Standard.
30+
* the ``mapped_type`` type must meet the ``DefaultConstructible`` requirements described in the [defaultconstructible] section of the ISO C++ Standard.
3131

32-
**Returns**: ``true`` if an element was inserted; ``false``, otherwise.
32+
**Returns**: ``true`` if an element is inserted; ``false`` otherwise.
33+
34+
--------------------------
35+
36+
.. code:: cpp
37+
38+
template <typename K>
39+
bool insert( const_accessor& result, const K& key );
40+
41+
template <typename K>
42+
bool insert( accessor& result, const K& key );
43+
44+
If the ``result`` accessor is not empty, releases the ``result`` and
45+
attempts to insert the value constructed from ``key, mapped_type()`` into the container.
46+
47+
Sets the ``result`` to provide access to the inserted element or to the element with the key,
48+
that compares equivalent to the value ``key``, which was already presented in the container.
49+
50+
This overload only participates in the overload resolution if:
51+
52+
* qualified-id ``hash_compare_type::is_transparent`` is valid and denotes a type
53+
* ``std::is_constructible<key_type, const K&>::value`` is ``true``
54+
55+
**Requirements**: the ``mapped_type`` type must meet the ``DefaultConstructible`` requirements
56+
described in the [defaultconstructible] section of the ISO C++ Standard.
57+
58+
**Returns**: ``true`` if an element is inserted; ``false`` otherwise.
3359

3460
--------------------------
3561

@@ -39,16 +65,16 @@ Inserting values
3965
4066
bool insert( accessor& result, const value_type& value );
4167
42-
If the accessor ``result`` is not empty, releases the ``result`` and
68+
If the ``result`` accessor is not empty, releases the ``result`` and
4369
attempts to insert the value ``value`` into the container.
4470

45-
Sets the ``result`` to provide access to the inserted element or to the element with equal key
46-
that was already presented in the container.
71+
Sets the ``result`` to provide access to the inserted element or to the element with equal key,
72+
which was already presented in the container.
4773

48-
**Requirements**: the type ``value_type`` must meet the ``CopyInsertable`` requirements from the
49-
[container.requirements] ISO C++ Standard section.
74+
**Requirements**: the ``value_type`` type must meet the ``CopyInsertable`` requirements described in the
75+
[container.requirements] section of the ISO C++ Standard.
5076

51-
**Returns**: ``true`` if an element was inserted; ``false``, otherwise.
77+
**Returns**: ``true`` if an element is inserted; ``false`` otherwise.
5278

5379
--------------------------
5480

@@ -58,10 +84,10 @@ Inserting values
5884
5985
Attempts to insert the value ``value`` into the container.
6086

61-
**Requirements**: the type ``value_type`` must meet the ``CopyInsertable`` requirements from the
62-
[container.requirements] ISO C++ Standard section.
87+
**Requirements**: the ``value_type`` type must meet the ``CopyInsertable`` requirements described in the
88+
[container.requirements] section of the ISO C++ Standard.
6389

64-
**Returns**: ``true`` if an element was inserted; ``false``, otherwise.
90+
**Returns**: ``true`` if an element is inserted; ``false`` otherwise.
6591

6692
--------------------------
6793

@@ -71,18 +97,18 @@ Inserting values
7197
7298
bool insert( accessor& result, value_type&& value );
7399
74-
If the accessor ``result`` is not empty, releases the ``result`` and
100+
If the ``result`` accessor is not empty, releases the ``result`` and
75101
attempts to insert the value ``value`` into the container using move semantics.
76102

77-
Sets the ``result`` to provide access to the inserted element or to the element with equal key
78-
that was already presented in the container.
103+
Sets the ``result`` to provide access to the inserted element or to the element with equal key,
104+
which was already presented in the container.
79105

80106
``value`` is left in a valid, but unspecified state.
81107

82-
**Requirements**: the type ``value_type`` must meet the ``MoveInsertable`` requirements from the
83-
[container.requirements] ISO C++ Standard section.
108+
**Requirements**: the ``value_type`` type must meet the ``MoveInsertable`` requirements described in the
109+
[container.requirements] section of the ISO C++ Standard.
84110

85-
**Returns**: ``true`` if an element was inserted; ``false``, otherwise.
111+
**Returns**: ``true`` if an element is inserted; ``false`` otherwise.
86112

87113
--------------------------
88114

@@ -92,10 +118,10 @@ Inserting values
92118
93119
Attempts to insert the value ``value`` into the container using move semantics.
94120

95-
**Requirements**: the type ``value_type`` must meet the ``MoveInsertable`` requirements from the
96-
[container.requirements] ISO C++ Standard section.
121+
**Requirements**: the ``value_type`` type must meet the ``MoveInsertable`` requirements described in the
122+
[container.requirements] section of the ISO C++ Standard.
97123

98-
**Returns**: ``true`` if an element was inserted; ``false``, otherwise.
124+
**Returns**: ``true`` if an element is inserted; ``false`` otherwise.
99125

100126
Inserting sequences of elements
101127
-------------------------------
@@ -111,8 +137,8 @@ Inserting sequences of elements
111137
If the interval ``[first, last)`` contains multiple elements with equal keys,
112138
it is unspecified which element should be inserted.
113139

114-
**Requirements**: the type ``InputIterator`` must meet the requirements of `InputIterator`
115-
from the ``[input.iterators]`` ISO C++ Standard section.
140+
**Requirements**: the ``InputIterator`` type must meet the requirements of `InputIterator`
141+
described in the ``[input.iterators]`` section of the ISO C++ Standard.
116142

117143
--------------------------
118144

@@ -133,16 +159,16 @@ Emplacing elements
133159
template <typename... Args>
134160
bool emplace( accessor& result, Args&&... args );
135161
136-
If the accessor ``result`` is not empty, releases the ``result`` and
162+
If the ``result`` accessor is not empty, releases the ``result`` and
137163
attempts to insert an element constructed in-place from ``args`` into the container.
138164

139-
Sets the ``result`` to provide access to the inserted element or to the element with equal key
140-
that was already presented in the container.
165+
Sets the ``result`` to provide access to the inserted element or to the element with equal key,
166+
which was already presented in the container.
141167

142-
**Requirements**: the type ``value_type`` must meet the ``EmplaceConstructible`` requirements from the
143-
[container.requirements] ISO C++ Standard section.
168+
**Requirements**: the type ``value_type`` must meet the ``EmplaceConstructible`` requirements described in the
169+
[container.requirements] section of the ISO C++ Standard.
144170

145-
**Returns**: ``true`` if an element was inserted; ``false``, otherwise
171+
**Returns**: ``true`` if an element is inserted; ``false`` otherwise
146172

147173
--------------------------
148174

@@ -153,10 +179,10 @@ Emplacing elements
153179
154180
Attempts to insert an element constructed in-place from ``args`` into the container.
155181

156-
**Requirements**: the type ``value_type`` must meet the ``EmplaceConstructible`` requirements from the
157-
[container.requirements] ISO C++ Standard section.
182+
**Requirements**: the type ``value_type`` must meet the ``EmplaceConstructible`` requirements described in the
183+
[container.requirements] section of the ISO C++ Standard.
158184

159-
**Returns**: ``true`` if an element was inserted; ``false``, otherwise
185+
**Returns**: ``true`` if an element is inserted; ``false`` otherwise
160186

161187
Erasing elements
162188
----------------
@@ -167,7 +193,21 @@ Erasing elements
167193
168194
If an element with the key equivalent to ``key`` exists, removes it from the container.
169195

170-
**Returns**: ``true`` if an element was removed; ``false``, otherwise.
196+
**Returns**: ``true`` if an element is removed; ``false`` otherwise.
197+
198+
--------------------------
199+
200+
.. code:: cpp
201+
202+
template <typename K>
203+
bool erase( const K& key );
204+
205+
If an element with the key that compares equivalent to the value ``key`` exists, removes it from the container.
206+
207+
This overload only participates in the overload resolution if qualified-id
208+
``hash_compare_type::is_transparent`` is valid and denotes a type.
209+
210+
**Returns**: ``true`` if an element is removed; ``false`` otherwise.
171211

172212
--------------------------
173213

@@ -180,5 +220,5 @@ Erasing elements
180220

181221
**Requirements**: ``item_accessor`` should not be empty.
182222

183-
**Returns**: ``true`` if an element was removed by the current thread; ``false``
184-
if it was removed by another thread.
223+
**Returns**: ``true`` if an element is removed by the current thread; ``false``
224+
if it is removed by another thread.

0 commit comments

Comments
 (0)