Skip to content

Commit 7bdcfc0

Browse files
committed
fix: add forgotten set parallel unstable sorting methods
1 parent 2a2b163 commit 7bdcfc0

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/rayon/set.rs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ where
452452
});
453453
}
454454

455-
/// Sort the set’s values in place and in parallel, using the comparison function `compare`.
455+
/// Sort the set’s values in place and in parallel, using the comparison function `cmp`.
456456
pub fn par_sort_by<F>(&mut self, cmp: F)
457457
where
458458
F: Fn(&T, &T) -> Ordering + Sync,
@@ -462,7 +462,7 @@ where
462462
});
463463
}
464464

465-
/// Sort the values of the set in parallel and return a by value parallel iterator of
465+
/// Sort the values of the set in parallel and return a by-value parallel iterator of
466466
/// the values with the result.
467467
pub fn par_sorted_by<F>(self, cmp: F) -> IntoParIter<T>
468468
where
@@ -472,6 +472,37 @@ where
472472
entries.par_sort_by(move |a, b| cmp(&a.key, &b.key));
473473
IntoParIter { entries }
474474
}
475+
476+
/// Sort the set's values in parallel by their default ordering.
477+
pub fn par_sort_unstable(&mut self)
478+
where
479+
T: Ord,
480+
{
481+
self.with_entries(|entries| {
482+
entries.par_sort_unstable_by(|a, b| T::cmp(&a.key, &b.key));
483+
});
484+
}
485+
486+
/// Sort the set’s values in place and in parallel, using the comparison function `cmp`.
487+
pub fn par_sort_unstable_by<F>(&mut self, cmp: F)
488+
where
489+
F: Fn(&T, &T) -> Ordering + Sync,
490+
{
491+
self.with_entries(|entries| {
492+
entries.par_sort_unstable_by(move |a, b| cmp(&a.key, &b.key));
493+
});
494+
}
495+
496+
/// Sort the values of the set in parallel and return a by-value parallel iterator of
497+
/// the values with the result.
498+
pub fn par_sorted_unstable_by<F>(self, cmp: F) -> IntoParIter<T>
499+
where
500+
F: Fn(&T, &T) -> Ordering + Sync,
501+
{
502+
let mut entries = self.into_entries();
503+
entries.par_sort_unstable_by(move |a, b| cmp(&a.key, &b.key));
504+
IntoParIter { entries }
505+
}
475506
}
476507

477508
/// Requires crate feature `"rayon"`.

0 commit comments

Comments
 (0)