Quickly Learn To Sort Vectors With Parallel STL Algorithm In C++ On Windows
February 22, 2021 By Yilmaz Yoru
In C++, STL Standard Template Library has many algorithms for some operations like searching, counting, and manipulation of ranges and their elements. C++17 has a new feature that you can sort vectors with Parallel STL Algorithm.
In Для просмотра ссылки Войдиили Зарегистрируйся, Vectors can be used and sorted by Parallel STL Algorithm as below.
February 22, 2021 By Yilmaz Yoru
In C++, STL Standard Template Library has many algorithms for some operations like searching, counting, and manipulation of ranges and their elements. C++17 has a new feature that you can sort vectors with Parallel STL Algorithm.
In Для просмотра ссылки Войди
C++:
#include <vcl.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<int> vec{ 36, 11, 9, 5, 15, 45, 5, 3 , 98, 23, 65};
for (auto i: vec) std::cout << i << ','; std::cout << '\n';
std::sort(std::execution::par, vec.begin(), vec.end());
for (auto i: vec) std::cout << i << ','; std::cout << '\n';
getchar(); return 0;
}