]> git.proxmox.com Git - rustc.git/blob - vendor/rustc-rayon/src/collections/binary_heap.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / vendor / rustc-rayon / src / collections / binary_heap.rs
1 //! This module contains the parallel iterator types for heaps
2 //! (`BinaryHeap<T>`). 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::BinaryHeap;
6
7 use crate::iter::plumbing::*;
8 use crate::iter::*;
9
10 use crate::vec;
11
12 /// Parallel iterator over a binary heap
13 #[derive(Debug, Clone)]
14 pub struct IntoIter<T: Ord + Send> {
15 inner: vec::IntoIter<T>,
16 }
17
18 impl<T: Ord + Send> IntoParallelIterator for BinaryHeap<T> {
19 type Item = T;
20 type Iter = IntoIter<T>;
21
22 fn into_par_iter(self) -> Self::Iter {
23 IntoIter {
24 inner: Vec::from(self).into_par_iter(),
25 }
26 }
27 }
28
29 delegate_indexed_iterator! {
30 IntoIter<T> => T,
31 impl<T: Ord + Send>
32 }
33
34 /// Parallel iterator over an immutable reference to a binary heap
35 #[derive(Debug)]
36 pub struct Iter<'a, T: Ord + Sync> {
37 inner: vec::IntoIter<&'a T>,
38 }
39
40 impl<'a, T: Ord + Sync> Clone for Iter<'a, T> {
41 fn clone(&self) -> Self {
42 Iter {
43 inner: self.inner.clone(),
44 }
45 }
46 }
47
48 into_par_vec! {
49 &'a BinaryHeap<T> => Iter<'a, T>,
50 impl<'a, T: Ord + Sync>
51 }
52
53 delegate_indexed_iterator! {
54 Iter<'a, T> => &'a T,
55 impl<'a, T: Ord + Sync + 'a>
56 }
57
58 // `BinaryHeap` doesn't have a mutable `Iterator`