Untitled

mail@pastecode.io avatar
unknown
c_cpp
a year ago
568 B
1
Indexable
Never
void MsMergeParallel(int *out, int *in, 
                    long begin1, long end1, 
                    long begin2, long end2, 
                    long outBegin) {
    long m = end1 - begin1;
    long n = end2 - begin2;

    if (m < n) {
        std::swap(end1, end2);
        std::swap(begin1, begin2);
        std::swap(m, n);
    }

    if (m + n <= 304) {
        MsMergeSequential(out, in, begin1, end1, begin2, end2, outBegin);
    } else if (n == 0) {
        for (long i = begin1; i < end1; i++) {
            out[outBegin + i - begin1] = in[i];
        }