1 | //! This module contains the parallel iterator types for B-Tree maps |
2 | //! (`BTreeMap<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::BTreeMap; |
6 | |
7 | use crate::iter::plumbing::*; |
8 | use crate::iter::*; |
9 | |
10 | use crate::vec; |
11 | |
12 | /// Parallel iterator over a B-Tree map |
13 | #[derive(Debug)] // std doesn't Clone |
14 | pub struct IntoIter<K: Ord + Send, V: Send> { |
15 | inner: vec::IntoIter<(K, V)>, |
16 | } |
17 | |
18 | into_par_vec! { |
19 | BTreeMap<K, V> => IntoIter<K, V>, |
20 | impl<K: Ord + Send, V: Send> |
21 | } |
22 | |
23 | delegate_iterator! { |
24 | IntoIter<K, V> => (K, V), |
25 | impl<K: Ord + Send, V: Send> |
26 | } |
27 | |
28 | /// Parallel iterator over an immutable reference to a B-Tree map |
29 | #[derive(Debug)] |
30 | pub struct Iter<'a, K: Ord + Sync, V: Sync> { |
31 | inner: vec::IntoIter<(&'a K, &'a V)>, |
32 | } |
33 | |
34 | impl<'a, K: Ord + Sync, V: Sync> Clone for Iter<'a, K, V> { |
35 | fn clone(&self) -> Self { |
36 | Iter { |
37 | inner: self.inner.clone(), |
38 | } |
39 | } |
40 | } |
41 | |
42 | into_par_vec! { |
43 | &'a BTreeMap<K, V> => Iter<'a, K, V>, |
44 | impl<'a, K: Ord + Sync, V: Sync> |
45 | } |
46 | |
47 | delegate_iterator! { |
48 | Iter<'a, K, V> => (&'a K, &'a V), |
49 | impl<'a, K: Ord + Sync + 'a, V: Sync + 'a> |
50 | } |
51 | |
52 | /// Parallel iterator over a mutable reference to a B-Tree map |
53 | #[derive(Debug)] |
54 | pub struct IterMut<'a, K: Ord + Sync, V: Send> { |
55 | inner: vec::IntoIter<(&'a K, &'a mut V)>, |
56 | } |
57 | |
58 | into_par_vec! { |
59 | &'a mut BTreeMap<K, V> => IterMut<'a, K, V>, |
60 | impl<'a, K: Ord + Sync, V: Send> |
61 | } |
62 | |
63 | delegate_iterator! { |
64 | IterMut<'a, K, V> => (&'a K, &'a mut V), |
65 | impl<'a, K: Ord + Sync + 'a, V: Send + 'a> |
66 | } |
67 | |