Compare commits
2 Commits
0c31a3c24e
...
2665332f70
Author | SHA1 | Date | |
---|---|---|---|
2665332f70 | |||
a47714d8b6 |
@ -3,6 +3,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class QuickSorterMT {
|
class QuickSorterMT {
|
||||||
@ -49,8 +50,7 @@ private:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
auto pivot = *std::next(data.begin(), std::distance(data.begin(), data.end()) / 2);
|
||||||
auto pivot = data[std::distance(data.begin(), data.end()) / 2];
|
|
||||||
|
|
||||||
auto m1 = std::partition(data.begin(), data.end(), [pivot, this](const auto &em) {
|
auto m1 = std::partition(data.begin(), data.end(), [pivot, this](const auto &em) {
|
||||||
return this->cmp(em, pivot);
|
return this->cmp(em, pivot);
|
||||||
@ -61,7 +61,7 @@ private:
|
|||||||
});
|
});
|
||||||
|
|
||||||
auto left = data.subspan(0, m1 - data.begin());
|
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) {
|
if (depth < mdepth) {
|
||||||
std::thread left_thread([&]() { qsort(left, depth + 1, mdepth); });
|
std::thread left_thread([&]() { qsort(left, depth + 1, mdepth); });
|
||||||
|
Loading…
Reference in New Issue
Block a user