]> git.proxmox.com Git - rustc.git/blame - src/vendor/rustc-rayon/src/collections/btree_map.rs
New upstream version 1.31.0+dfsg1
[rustc.git] / src / vendor / rustc-rayon / src / collections / btree_map.rs
CommitLineData
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
5use std::collections::BTreeMap;
6
7use iter::*;
8use iter::plumbing::*;
9
10use vec;
11
12/// Parallel iterator over a B-Tree map
13#[derive(Debug)] // std doesn't Clone
14pub struct IntoIter<K: Ord + Send, V: Send> {
15 inner: vec::IntoIter<(K, V)>,
16}
17
18into_par_vec!{
19 BTreeMap<K, V> => IntoIter<K, V>,
20 impl<K: Ord + Send, V: Send>
21}
22
23delegate_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)]
31pub struct Iter<'a, K: Ord + Sync + 'a, V: Sync + 'a> {
32 inner: vec::IntoIter<(&'a K, &'a V)>,
33}
34
35impl<'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
41into_par_vec!{
42 &'a BTreeMap<K, V> => Iter<'a, K, V>,
43 impl<'a, K: Ord + Sync, V: Sync>
44}
45
46delegate_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)]
54pub struct IterMut<'a, K: Ord + Sync + 'a, V: Send + 'a> {
55 inner: vec::IntoIter<(&'a K, &'a mut V)>,
56}
57
58into_par_vec!{
59 &'a mut BTreeMap<K, V> => IterMut<'a, K, V>,
60 impl<'a, K: Ord + Sync, V: Send>
61}
62
63delegate_iterator!{
64 IterMut<'a, K, V> => (&'a K, &'a mut V),
65 impl<'a, K: Ord + Sync + 'a, V: Send + 'a>
66}