]>
Commit | Line | Data |
---|---|---|
94b46f34 XL |
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 iter::*; | |
8 | use iter::plumbing::*; | |
9 | ||
10 | use 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 | ||
29 | /// Parallel iterator over an immutable reference to a B-Tree map | |
30 | #[derive(Debug)] | |
31 | pub struct Iter<'a, K: Ord + Sync + 'a, V: Sync + 'a> { | |
32 | inner: vec::IntoIter<(&'a K, &'a V)>, | |
33 | } | |
34 | ||
35 | impl<'a, K: Ord + Sync, V: Sync> Clone for Iter<'a, K, V> { | |
36 | fn clone(&self) -> Self { | |
37 | Iter { inner: self.inner.clone() } | |
38 | } | |
39 | } | |
40 | ||
41 | into_par_vec!{ | |
42 | &'a BTreeMap<K, V> => Iter<'a, K, V>, | |
43 | impl<'a, K: Ord + Sync, V: Sync> | |
44 | } | |
45 | ||
46 | delegate_iterator!{ | |
47 | Iter<'a, K, V> => (&'a K, &'a V), | |
48 | impl<'a, K: Ord + Sync + 'a, V: Sync + 'a> | |
49 | } | |
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 + 'a, V: Send + 'a> { | |
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 | } |