1
1
//! Rayon extensions for `HashMap`.
2
2
3
3
use crate :: hash_map:: HashMap ;
4
- use crate :: raw:: { AllocRef , Global } ;
4
+ use crate :: raw:: { Allocator , Global } ;
5
5
use core:: fmt;
6
6
use core:: hash:: { BuildHasher , Hash } ;
7
7
use rayon:: iter:: plumbing:: UnindexedConsumer ;
@@ -16,11 +16,11 @@ use rayon::iter::{FromParallelIterator, IntoParallelIterator, ParallelExtend, Pa
16
16
/// [`par_iter`]: /hashbrown/struct.HashMap.html#method.par_iter
17
17
/// [`HashMap`]: /hashbrown/struct.HashMap.html
18
18
/// [`IntoParallelRefIterator`]: https://docs.rs/rayon/1.0/rayon/iter/trait.IntoParallelRefIterator.html
19
- pub struct ParIter < ' a , K , V , S , A : AllocRef + Clone = Global > {
19
+ pub struct ParIter < ' a , K , V , S , A : Allocator + Clone = Global > {
20
20
map : & ' a HashMap < K , V , S , A > ,
21
21
}
22
22
23
- impl < ' a , K : Sync , V : Sync , S : Sync , A : AllocRef + Clone + Sync > ParallelIterator
23
+ impl < ' a , K : Sync , V : Sync , S : Sync , A : Allocator + Clone + Sync > ParallelIterator
24
24
for ParIter < ' a , K , V , S , A >
25
25
{
26
26
type Item = ( & ' a K , & ' a V ) ;
@@ -39,14 +39,14 @@ impl<'a, K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> ParallelIterator
39
39
}
40
40
}
41
41
42
- impl < K , V , S , A : AllocRef + Clone > Clone for ParIter < ' _ , K , V , S , A > {
42
+ impl < K , V , S , A : Allocator + Clone > Clone for ParIter < ' _ , K , V , S , A > {
43
43
#[ cfg_attr( feature = "inline-more" , inline) ]
44
44
fn clone ( & self ) -> Self {
45
45
ParIter { map : self . map }
46
46
}
47
47
}
48
48
49
- impl < K : fmt:: Debug + Eq + Hash , V : fmt:: Debug , S : BuildHasher , A : AllocRef + Clone > fmt:: Debug
49
+ impl < K : fmt:: Debug + Eq + Hash , V : fmt:: Debug , S : BuildHasher , A : Allocator + Clone > fmt:: Debug
50
50
for ParIter < ' _ , K , V , S , A >
51
51
{
52
52
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -61,11 +61,11 @@ impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clo
61
61
///
62
62
/// [`par_keys`]: /hashbrown/struct.HashMap.html#method.par_keys
63
63
/// [`HashMap`]: /hashbrown/struct.HashMap.html
64
- pub struct ParKeys < ' a , K , V , S , A : AllocRef + Clone > {
64
+ pub struct ParKeys < ' a , K , V , S , A : Allocator + Clone > {
65
65
map : & ' a HashMap < K , V , S , A > ,
66
66
}
67
67
68
- impl < ' a , K : Sync , V : Sync , S : Sync , A : AllocRef + Clone + Sync > ParallelIterator
68
+ impl < ' a , K : Sync , V : Sync , S : Sync , A : Allocator + Clone + Sync > ParallelIterator
69
69
for ParKeys < ' a , K , V , S , A >
70
70
{
71
71
type Item = & ' a K ;
@@ -81,14 +81,14 @@ impl<'a, K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> ParallelIterator
81
81
}
82
82
}
83
83
84
- impl < K , V , S , A : AllocRef + Clone > Clone for ParKeys < ' _ , K , V , S , A > {
84
+ impl < K , V , S , A : Allocator + Clone > Clone for ParKeys < ' _ , K , V , S , A > {
85
85
#[ cfg_attr( feature = "inline-more" , inline) ]
86
86
fn clone ( & self ) -> Self {
87
87
ParKeys { map : self . map }
88
88
}
89
89
}
90
90
91
- impl < K : fmt:: Debug + Eq + Hash , V , S : BuildHasher , A : AllocRef + Clone > fmt:: Debug
91
+ impl < K : fmt:: Debug + Eq + Hash , V , S : BuildHasher , A : Allocator + Clone > fmt:: Debug
92
92
for ParKeys < ' _ , K , V , S , A >
93
93
{
94
94
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -103,11 +103,11 @@ impl<K: fmt::Debug + Eq + Hash, V, S: BuildHasher, A: AllocRef + Clone> fmt::Deb
103
103
///
104
104
/// [`par_values`]: /hashbrown/struct.HashMap.html#method.par_values
105
105
/// [`HashMap`]: /hashbrown/struct.HashMap.html
106
- pub struct ParValues < ' a , K , V , S , A : AllocRef + Clone = Global > {
106
+ pub struct ParValues < ' a , K , V , S , A : Allocator + Clone = Global > {
107
107
map : & ' a HashMap < K , V , S , A > ,
108
108
}
109
109
110
- impl < ' a , K : Sync , V : Sync , S : Sync , A : AllocRef + Clone + Sync > ParallelIterator
110
+ impl < ' a , K : Sync , V : Sync , S : Sync , A : Allocator + Clone + Sync > ParallelIterator
111
111
for ParValues < ' a , K , V , S , A >
112
112
{
113
113
type Item = & ' a V ;
@@ -123,14 +123,14 @@ impl<'a, K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> ParallelIterator
123
123
}
124
124
}
125
125
126
- impl < K , V , S , A : AllocRef + Clone > Clone for ParValues < ' _ , K , V , S , A > {
126
+ impl < K , V , S , A : Allocator + Clone > Clone for ParValues < ' _ , K , V , S , A > {
127
127
#[ cfg_attr( feature = "inline-more" , inline) ]
128
128
fn clone ( & self ) -> Self {
129
129
ParValues { map : self . map }
130
130
}
131
131
}
132
132
133
- impl < K : Eq + Hash , V : fmt:: Debug , S : BuildHasher , A : AllocRef + Clone > fmt:: Debug
133
+ impl < K : Eq + Hash , V : fmt:: Debug , S : BuildHasher , A : Allocator + Clone > fmt:: Debug
134
134
for ParValues < ' _ , K , V , S , A >
135
135
{
136
136
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -147,11 +147,11 @@ impl<K: Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clone> fmt::Debu
147
147
/// [`par_iter_mut`]: /hashbrown/struct.HashMap.html#method.par_iter_mut
148
148
/// [`HashMap`]: /hashbrown/struct.HashMap.html
149
149
/// [`IntoParallelRefMutIterator`]: https://docs.rs/rayon/1.0/rayon/iter/trait.IntoParallelRefMutIterator.html
150
- pub struct ParIterMut < ' a , K , V , S , A : AllocRef + Clone > {
150
+ pub struct ParIterMut < ' a , K , V , S , A : Allocator + Clone > {
151
151
map : & ' a mut HashMap < K , V , S , A > ,
152
152
}
153
153
154
- impl < ' a , K : Send + Sync , V : Send , S : Send , A : AllocRef + Clone + Sync > ParallelIterator
154
+ impl < ' a , K : Send + Sync , V : Send , S : Send , A : Allocator + Clone + Sync > ParallelIterator
155
155
for ParIterMut < ' a , K , V , S , A >
156
156
{
157
157
type Item = ( & ' a K , & ' a mut V ) ;
@@ -170,7 +170,7 @@ impl<'a, K: Send + Sync, V: Send, S: Send, A: AllocRef + Clone + Sync> ParallelI
170
170
}
171
171
}
172
172
173
- impl < K : fmt:: Debug + Eq + Hash , V : fmt:: Debug , S : BuildHasher , A : AllocRef + Clone > fmt:: Debug
173
+ impl < K : fmt:: Debug + Eq + Hash , V : fmt:: Debug , S : BuildHasher , A : Allocator + Clone > fmt:: Debug
174
174
for ParIterMut < ' _ , K , V , S , A >
175
175
{
176
176
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -185,11 +185,11 @@ impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clo
185
185
///
186
186
/// [`par_values_mut`]: /hashbrown/struct.HashMap.html#method.par_values_mut
187
187
/// [`HashMap`]: /hashbrown/struct.HashMap.html
188
- pub struct ParValuesMut < ' a , K , V , S , A : AllocRef + Clone = Global > {
188
+ pub struct ParValuesMut < ' a , K , V , S , A : Allocator + Clone = Global > {
189
189
map : & ' a mut HashMap < K , V , S , A > ,
190
190
}
191
191
192
- impl < ' a , K : Send , V : Send , S : Send , A : AllocRef + Clone + Send > ParallelIterator
192
+ impl < ' a , K : Send , V : Send , S : Send , A : Allocator + Clone + Send > ParallelIterator
193
193
for ParValuesMut < ' a , K , V , S , A >
194
194
{
195
195
type Item = & ' a mut V ;
@@ -205,7 +205,7 @@ impl<'a, K: Send, V: Send, S: Send, A: AllocRef + Clone + Send> ParallelIterator
205
205
}
206
206
}
207
207
208
- impl < K : Eq + Hash , V : fmt:: Debug , S : BuildHasher , A : AllocRef + Clone > fmt:: Debug
208
+ impl < K : Eq + Hash , V : fmt:: Debug , S : BuildHasher , A : Allocator + Clone > fmt:: Debug
209
209
for ParValuesMut < ' _ , K , V , S , A >
210
210
{
211
211
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -222,11 +222,11 @@ impl<K: Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clone> fmt::Debu
222
222
/// [`into_par_iter`]: /hashbrown/struct.HashMap.html#method.into_par_iter
223
223
/// [`HashMap`]: /hashbrown/struct.HashMap.html
224
224
/// [`IntoParallelIterator`]: https://docs.rs/rayon/1.0/rayon/iter/trait.IntoParallelIterator.html
225
- pub struct IntoParIter < K , V , S , A : AllocRef + Clone = Global > {
225
+ pub struct IntoParIter < K , V , S , A : Allocator + Clone = Global > {
226
226
map : HashMap < K , V , S , A > ,
227
227
}
228
228
229
- impl < K : Send , V : Send , S : Send , A : AllocRef + Clone + Send > ParallelIterator
229
+ impl < K : Send , V : Send , S : Send , A : Allocator + Clone + Send > ParallelIterator
230
230
for IntoParIter < K , V , S , A >
231
231
{
232
232
type Item = ( K , V ) ;
@@ -240,7 +240,7 @@ impl<K: Send, V: Send, S: Send, A: AllocRef + Clone + Send> ParallelIterator
240
240
}
241
241
}
242
242
243
- impl < K : fmt:: Debug + Eq + Hash , V : fmt:: Debug , S : BuildHasher , A : AllocRef + Clone > fmt:: Debug
243
+ impl < K : fmt:: Debug + Eq + Hash , V : fmt:: Debug , S : BuildHasher , A : Allocator + Clone > fmt:: Debug
244
244
for IntoParIter < K , V , S , A >
245
245
{
246
246
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -255,11 +255,11 @@ impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clo
255
255
///
256
256
/// [`par_drain`]: /hashbrown/struct.HashMap.html#method.par_drain
257
257
/// [`HashMap`]: /hashbrown/struct.HashMap.html
258
- pub struct ParDrain < ' a , K , V , S , A : AllocRef + Clone = Global > {
258
+ pub struct ParDrain < ' a , K , V , S , A : Allocator + Clone = Global > {
259
259
map : & ' a mut HashMap < K , V , S , A > ,
260
260
}
261
261
262
- impl < K : Send , V : Send , S : Send , A : AllocRef + Clone + Sync > ParallelIterator
262
+ impl < K : Send , V : Send , S : Send , A : Allocator + Clone + Sync > ParallelIterator
263
263
for ParDrain < ' _ , K , V , S , A >
264
264
{
265
265
type Item = ( K , V ) ;
@@ -273,15 +273,15 @@ impl<K: Send, V: Send, S: Send, A: AllocRef + Clone + Sync> ParallelIterator
273
273
}
274
274
}
275
275
276
- impl < K : fmt:: Debug + Eq + Hash , V : fmt:: Debug , S : BuildHasher , A : AllocRef + Clone > fmt:: Debug
276
+ impl < K : fmt:: Debug + Eq + Hash , V : fmt:: Debug , S : BuildHasher , A : Allocator + Clone > fmt:: Debug
277
277
for ParDrain < ' _ , K , V , S , A >
278
278
{
279
279
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
280
280
self . map . iter ( ) . fmt ( f)
281
281
}
282
282
}
283
283
284
- impl < K : Sync , V : Sync , S : Sync , A : AllocRef + Clone + Sync > HashMap < K , V , S , A > {
284
+ impl < K : Sync , V : Sync , S : Sync , A : Allocator + Clone + Sync > HashMap < K , V , S , A > {
285
285
/// Visits (potentially in parallel) immutably borrowed keys in an arbitrary order.
286
286
#[ cfg_attr( feature = "inline-more" , inline) ]
287
287
pub fn par_keys ( & self ) -> ParKeys < ' _ , K , V , S , A > {
@@ -295,7 +295,7 @@ impl<K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> HashMap<K, V, S, A>
295
295
}
296
296
}
297
297
298
- impl < K : Send , V : Send , S : Send , A : AllocRef + Clone + Sync > HashMap < K , V , S , A > {
298
+ impl < K : Send , V : Send , S : Send , A : Allocator + Clone + Sync > HashMap < K , V , S , A > {
299
299
/// Visits (potentially in parallel) mutably borrowed values in an arbitrary order.
300
300
#[ cfg_attr( feature = "inline-more" , inline) ]
301
301
pub fn par_values_mut ( & mut self ) -> ParValuesMut < ' _ , K , V , S , A > {
@@ -315,7 +315,7 @@ where
315
315
K : Eq + Hash + Sync ,
316
316
V : PartialEq + Sync ,
317
317
S : BuildHasher + Sync ,
318
- A : AllocRef + Clone + Sync ,
318
+ A : Allocator + Clone + Sync ,
319
319
{
320
320
/// Returns `true` if the map is equal to another,
321
321
/// i.e. both maps contain the same keys mapped to the same values.
@@ -329,7 +329,7 @@ where
329
329
}
330
330
}
331
331
332
- impl < K : Send , V : Send , S : Send , A : AllocRef + Clone + Send > IntoParallelIterator
332
+ impl < K : Send , V : Send , S : Send , A : Allocator + Clone + Send > IntoParallelIterator
333
333
for HashMap < K , V , S , A >
334
334
{
335
335
type Item = ( K , V ) ;
@@ -341,7 +341,7 @@ impl<K: Send, V: Send, S: Send, A: AllocRef + Clone + Send> IntoParallelIterator
341
341
}
342
342
}
343
343
344
- impl < ' a , K : Sync , V : Sync , S : Sync , A : AllocRef + Clone + Sync > IntoParallelIterator
344
+ impl < ' a , K : Sync , V : Sync , S : Sync , A : Allocator + Clone + Sync > IntoParallelIterator
345
345
for & ' a HashMap < K , V , S , A >
346
346
{
347
347
type Item = ( & ' a K , & ' a V ) ;
@@ -353,7 +353,7 @@ impl<'a, K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> IntoParallelIter
353
353
}
354
354
}
355
355
356
- impl < ' a , K : Send + Sync , V : Send , S : Send , A : AllocRef + Clone + Sync > IntoParallelIterator
356
+ impl < ' a , K : Send + Sync , V : Send , S : Send , A : Allocator + Clone + Sync > IntoParallelIterator
357
357
for & ' a mut HashMap < K , V , S , A >
358
358
{
359
359
type Item = ( & ' a K , & ' a mut V ) ;
@@ -391,7 +391,7 @@ where
391
391
K : Eq + Hash + Send ,
392
392
V : Send ,
393
393
S : BuildHasher ,
394
- A : AllocRef + Clone ,
394
+ A : Allocator + Clone ,
395
395
{
396
396
fn par_extend < I > ( & mut self , par_iter : I )
397
397
where
@@ -407,7 +407,7 @@ where
407
407
K : Copy + Eq + Hash + Sync ,
408
408
V : Copy + Sync ,
409
409
S : BuildHasher ,
410
- A : AllocRef + Clone ,
410
+ A : Allocator + Clone ,
411
411
{
412
412
fn par_extend < I > ( & mut self , par_iter : I )
413
413
where
@@ -423,7 +423,7 @@ where
423
423
K : Eq + Hash ,
424
424
S : BuildHasher ,
425
425
I : IntoParallelIterator ,
426
- A : AllocRef + Clone ,
426
+ A : Allocator + Clone ,
427
427
HashMap < K , V , S , A > : Extend < I :: Item > ,
428
428
{
429
429
let ( list, len) = super :: helpers:: collect ( par_iter) ;
0 commit comments