Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Make merge_sort_slices MergeSortSlices public #243

Merged
merged 2 commits into from
Aug 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/compute/merge_sort/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ use crate::error::Result;
/// This representation is useful when building arrays in memory as it allows to memcopy slices of arrays.
/// This is particularly useful in merge-sort because sorted arrays (passed to the merge-sort) are more likely
/// to have contiguous blocks of sorted elements (than by random).
type MergeSlice = (usize, usize, usize);
pub type MergeSlice = (usize, usize, usize);

/// Takes N arrays together through `slices` under the assumption that the slices have
/// a total coverage of the arrays.
Expand Down Expand Up @@ -234,7 +234,7 @@ fn recursive_merge_sort(slices: &[&[MergeSlice]], comparator: &Comparator) -> Ve

// An iterator adapter that merge-sorts two iterators of `MergeSlice` into a single `MergeSlice`
// such that the resulting `MergeSlice`s are ordered according to `comparator`.
struct MergeSortSlices<'a, L, R>
pub struct MergeSortSlices<'a, L, R>
where
L: Iterator<Item = &'a MergeSlice>,
R: Iterator<Item = &'a MergeSlice>,
Expand Down Expand Up @@ -426,7 +426,11 @@ where
/// Given two iterators of slices representing two sets of sorted [`Array`]s, and a `comparator` bound to those [`Array`]s,
/// returns a new iterator of slices denoting how to `take` slices from each of the arrays such that the resulting
/// array is sorted according to `comparator`
fn merge_sort_slices<'a, L: Iterator<Item = &'a MergeSlice>, R: Iterator<Item = &'a MergeSlice>>(
pub fn merge_sort_slices<
'a,
L: Iterator<Item = &'a MergeSlice>,
R: Iterator<Item = &'a MergeSlice>,
>(
lhs: L,
rhs: R,
comparator: &'a Comparator,
Expand All @@ -439,7 +443,7 @@ type Comparator<'a> = Box<dyn Fn(usize, usize, usize, usize) -> Ordering + 'a>;
type IsValid<'a> = Box<dyn Fn(usize) -> bool + 'a>;

/// returns a comparison function between any two arrays of each pair of arrays, according to `SortOptions`.
fn build_comparator<'a>(
pub fn build_comparator<'a>(
pairs: &'a [(&'a [&'a dyn Array], &SortOptions)],
) -> Result<Comparator<'a>> {
// prepare the comparison function of _values_ between all pairs of arrays
Expand Down