fix execution
This commit is contained in:
parent
0c31a3c24e
commit
a47714d8b6
@ -3,6 +3,7 @@
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <functional>
|
||||
#include <assert.h>
|
||||
|
||||
template<typename T>
|
||||
class QuickSorterMT {
|
||||
@ -49,8 +50,7 @@ private:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto pivot = data[std::distance(data.begin(), data.end()) / 2];
|
||||
auto pivot = *std::next(data.begin(), std::distance(data.begin(), data.end()) / 2);
|
||||
|
||||
auto m1 = std::partition(data.begin(), data.end(), [pivot, this](const auto &em) {
|
||||
return this->cmp(em, pivot);
|
||||
@ -60,8 +60,10 @@ private:
|
||||
return !(this->cmp(em, pivot));
|
||||
});
|
||||
|
||||
assert((m1 - data.begin()) <= data.size());
|
||||
assert((m2 - data.begin()) <= data.size());
|
||||
auto left = data.subspan(0, m1 - data.begin());
|
||||
auto right = data.subspan(m2 - data.begin(), data.size());
|
||||
auto right = data.subspan(m2 - data.begin());
|
||||
|
||||
if (depth < mdepth) {
|
||||
std::thread left_thread([&]() { qsort(left, depth + 1, mdepth); });
|
||||
|
Loading…
Reference in New Issue
Block a user