parallel_disk_usage/data_tree/
sort.rs1use super::DataTree;
2use crate::size;
3use rayon::prelude::*;
4use std::cmp::Ordering;
5
6impl<Name, Size> DataTree<Name, Size>
7where
8 Self: Send,
9 Size: size::Size,
10{
11 pub fn par_sort_by(&mut self, compare: impl Fn(&Self, &Self) -> Ordering + Copy + Sync) {
13 self.children
14 .par_iter_mut()
15 .for_each(|child| child.par_sort_by(compare));
16 self.children.sort_by(compare);
17 }
18
19 #[inline]
21 pub fn into_par_sorted(
22 mut self,
23 compare: impl Fn(&Self, &Self) -> Ordering + Copy + Sync,
24 ) -> Self {
25 self.par_sort_by(compare);
26 self
27 }
28}