This commit is contained in:
Robin Dietzel 2023-11-03 11:41:58 +01:00
parent c8a3a6d4e3
commit 23a02e9dd1
3 changed files with 11 additions and 4 deletions

View File

@ -5,6 +5,7 @@
#include <chrono>
#include <mergesort.h>
#include <mergesort_mt.h>
/*
Create a simple sorting application that uses the mergesort algorithm to sort a
@ -98,7 +99,7 @@ auto main(int argc, char *argv[]) -> int {
return 0;
} catch (std::exception e) {
} catch (std::exception &e) {
fmt::print("Error occured: {}", e.what());
return -1;
}

View File

@ -305,7 +305,7 @@ namespace algo {
while (l < left.end() && r < right.end()) {
if (cmp(*l, *r)) {
outpbufut.insert(o, *l);
output.insert(o, *l);
l++;
} else {
output.insert(o, *r);

View File

@ -11,13 +11,13 @@ class MergeSorterMT {
auto merge(std::span<T> &output, std::span<T> left, std::span<T> right) -> void {
std::vector<T> buf;
buf.reserver(left.size() + right.size());
buf.reserve(left.size() + right.size());
auto l = left.begin();
auto r = right.begin();
auto o = buf.begin();
hile (l < left.end() && r < right.end()) {
while (l < left.end() && r < right.end()) {
if (cmp(*l, *r)) {
buf.insert(o, *l);
l++;
@ -44,5 +44,11 @@ class MergeSorterMT {
}
}
auto split(std::vector<T> &data, C cmp, int depth, int &max_depth, std::mutex &mut) -> void {
}
};