C++Builder Quickly Learn To Sort Vectors With Parallel STL Algorithm In C++ On Windows

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,199
Credits
4,009
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.

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;
}