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 crate::iter::plumbing::*;
8use crate::iter::*;
9
10use crate::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/// Parallel iterator over an immutable reference to a B-Tree map
29#[derive(Debug)]
30pub struct Iter<'a, K: Ord + Sync, V: Sync> {
31 inner: vec::IntoIter<(&'a K, &'a V)>,
32}
33
34impl<'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
42into_par_vec! {
43 &'a BTreeMap<K, V> => Iter<'a, K, V>,
44 impl<'a, K: Ord + Sync, V: Sync>
45}
46
47delegate_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)]
54pub struct IterMut<'a, K: Ord + Sync, V: Send> {
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}
67