Compare commits
No commits in common. "2665332f7043400528e1af5aca10dcc318d6c582" and "0c31a3c24e9f048b2cf3f8bc0836ddcc08319a03" have entirely different histories.
2665332f70
...
0c31a3c24e
@ -3,7 +3,6 @@
|
|||||||
#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 {
|
||||||
@ -50,7 +49,8 @@ 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());
|
auto right = data.subspan(m2 - data.begin(), data.size());
|
||||||
|
|
||||||
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…
x
Reference in New Issue
Block a user