]>
git.proxmox.com Git - rustc.git/blob - vendor/rustc-rayon/src/collections/hash_map.rs
1 //! This module contains the parallel iterator types for hash maps
2 //! (`HashMap<K, V>`). You will rarely need to interact with it directly
3 //! unless you have need to name one of the iterator types.
5 use std
::collections
::HashMap
;
6 use std
::hash
::{BuildHasher, Hash}
;
7 use std
::marker
::PhantomData
;
9 use crate::iter
::plumbing
::*;
14 /// Parallel iterator over a hash map
15 #[derive(Debug)] // std doesn't Clone
16 pub struct IntoIter
<K
: Hash
+ Eq
+ Send
, V
: Send
> {
17 inner
: vec
::IntoIter
<(K
, V
)>,
21 HashMap
<K
, V
, S
> => IntoIter
<K
, V
>,
22 impl<K
: Hash
+ Eq
+ Send
, V
: Send
, S
: BuildHasher
>
26 IntoIter
<K
, V
> => (K
, V
),
27 impl<K
: Hash
+ Eq
+ Send
, V
: Send
>
30 /// Parallel iterator over an immutable reference to a hash map
32 pub struct Iter
<'a
, K
: Hash
+ Eq
+ Sync
, V
: Sync
> {
33 inner
: vec
::IntoIter
<(&'a K
, &'a V
)>,
36 impl<'a
, K
: Hash
+ Eq
+ Sync
, V
: Sync
> Clone
for Iter
<'a
, K
, V
> {
37 fn clone(&self) -> Self {
39 inner
: self.inner
.clone(),
45 &'a HashMap
<K
, V
, S
> => Iter
<'a
, K
, V
>,
46 impl<'a
, K
: Hash
+ Eq
+ Sync
, V
: Sync
, S
: BuildHasher
>
50 Iter
<'a
, K
, V
> => (&'a K
, &'a V
),
51 impl<'a
, K
: Hash
+ Eq
+ Sync
+ 'a
, V
: Sync
+ 'a
>
54 /// Parallel iterator over a mutable reference to a hash map
56 pub struct IterMut
<'a
, K
: Hash
+ Eq
+ Sync
, V
: Send
> {
57 inner
: vec
::IntoIter
<(&'a K
, &'a
mut V
)>,
61 &'a
mut HashMap
<K
, V
, S
> => IterMut
<'a
, K
, V
>,
62 impl<'a
, K
: Hash
+ Eq
+ Sync
, V
: Send
, S
: BuildHasher
>
66 IterMut
<'a
, K
, V
> => (&'a K
, &'a
mut V
),
67 impl<'a
, K
: Hash
+ Eq
+ Sync
+ 'a
, V
: Send
+ 'a
>
70 /// Draining parallel iterator that moves out of a hash map,
71 /// but keeps the total capacity.
73 pub struct Drain
<'a
, K
: Hash
+ Eq
+ Send
, V
: Send
> {
74 inner
: vec
::IntoIter
<(K
, V
)>,
75 marker
: PhantomData
<&'a
mut HashMap
<K
, V
>>,
78 impl<'a
, K
: Hash
+ Eq
+ Send
, V
: Send
, S
: BuildHasher
> ParallelDrainFull
79 for &'a
mut HashMap
<K
, V
, S
>
81 type Iter
= Drain
<'a
, K
, V
>;
84 fn par_drain(self) -> Self::Iter
{
85 let vec
: Vec
<_
> = self.drain().collect();
87 inner
: vec
.into_par_iter(),
94 Drain
<'_
, K
, V
> => (K
, V
),
95 impl<K
: Hash
+ Eq
+ Send
, V
: Send
>