]> git.proxmox.com Git - rustc.git/blame - vendor/rustc-rayon/src/collections/binary_heap.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / vendor / rustc-rayon / src / collections / binary_heap.rs
CommitLineData
2c00a5a8
XL
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
5use std::collections::BinaryHeap;
6
6a06907d
XL
7use crate::iter::plumbing::*;
8use crate::iter::*;
2c00a5a8 9
6a06907d 10use crate::vec;
2c00a5a8
XL
11
12/// Parallel iterator over a binary heap
13#[derive(Debug, Clone)]
14pub struct IntoIter<T: Ord + Send> {
15 inner: vec::IntoIter<T>,
16}
17
18impl<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 {
532ac7d7
XL
23 IntoIter {
24 inner: Vec::from(self).into_par_iter(),
25 }
2c00a5a8
XL
26 }
27}
28
532ac7d7 29delegate_indexed_iterator! {
2c00a5a8
XL
30 IntoIter<T> => T,
31 impl<T: Ord + Send>
32}
33
2c00a5a8
XL
34/// Parallel iterator over an immutable reference to a binary heap
35#[derive(Debug)]
6a06907d 36pub struct Iter<'a, T: Ord + Sync> {
2c00a5a8
XL
37 inner: vec::IntoIter<&'a T>,
38}
39
40impl<'a, T: Ord + Sync> Clone for Iter<'a, T> {
41 fn clone(&self) -> Self {
532ac7d7
XL
42 Iter {
43 inner: self.inner.clone(),
44 }
2c00a5a8
XL
45 }
46}
47
532ac7d7 48into_par_vec! {
2c00a5a8
XL
49 &'a BinaryHeap<T> => Iter<'a, T>,
50 impl<'a, T: Ord + Sync>
51}
52
532ac7d7 53delegate_indexed_iterator! {
2c00a5a8
XL
54 Iter<'a, T> => &'a T,
55 impl<'a, T: Ord + Sync + 'a>
56}
57
2c00a5a8 58// `BinaryHeap` doesn't have a mutable `Iterator`