]> git.proxmox.com Git - rustc.git/blob - vendor/rayon/src/collections/hash_map.rs
New upstream version 1.46.0~beta.2+dfsg1
[rustc.git] / vendor / 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.
4
5 use std::collections::HashMap;
6 use std::hash::{BuildHasher, Hash};
7
8 use crate::iter::plumbing::*;
9 use crate::iter::*;
10
11 use crate::vec;
12
13 /// Parallel iterator over a hash map
14 #[derive(Debug)] // std doesn't Clone
15 pub struct IntoIter<K: Hash + Eq + Send, V: Send> {
16 inner: vec::IntoIter<(K, V)>,
17 }
18
19 into_par_vec! {
20 HashMap<K, V, S> => IntoIter<K, V>,
21 impl<K: Hash + Eq + Send, V: Send, S: BuildHasher>
22 }
23
24 delegate_iterator! {
25 IntoIter<K, V> => (K, V),
26 impl<K: Hash + Eq + Send, V: Send>
27 }
28
29 /// Parallel iterator over an immutable reference to a hash map
30 #[derive(Debug)]
31 pub struct Iter<'a, K: Hash + Eq + Sync, V: Sync> {
32 inner: vec::IntoIter<(&'a K, &'a V)>,
33 }
34
35 impl<'a, K: Hash + Eq + Sync, V: Sync> Clone for Iter<'a, K, V> {
36 fn clone(&self) -> Self {
37 Iter {
38 inner: self.inner.clone(),
39 }
40 }
41 }
42
43 into_par_vec! {
44 &'a HashMap<K, V, S> => Iter<'a, K, V>,
45 impl<'a, K: Hash + Eq + Sync, V: Sync, S: BuildHasher>
46 }
47
48 delegate_iterator! {
49 Iter<'a, K, V> => (&'a K, &'a V),
50 impl<'a, K: Hash + Eq + Sync + 'a, V: Sync + 'a>
51 }
52
53 /// Parallel iterator over a mutable reference to a hash map
54 #[derive(Debug)]
55 pub struct IterMut<'a, K: Hash + Eq + Sync, V: Send> {
56 inner: vec::IntoIter<(&'a K, &'a mut V)>,
57 }
58
59 into_par_vec! {
60 &'a mut HashMap<K, V, S> => IterMut<'a, K, V>,
61 impl<'a, K: Hash + Eq + Sync, V: Send, S: BuildHasher>
62 }
63
64 delegate_iterator! {
65 IterMut<'a, K, V> => (&'a K, &'a mut V),
66 impl<'a, K: Hash + Eq + Sync + 'a, V: Send + 'a>
67 }