Function max_element
boost::compute::max_element
Synopsis
template<typename InputIterator, typename Compare>
InputIterator
max_element(InputIterator first, InputIterator last, Compare compare,
command_queue & queue = system::default_queue());
template<typename InputIterator>
InputIterator
max_element(InputIterator first, InputIterator last,
command_queue & queue = system::default_queue());Description
Возвращает итератор, указывающий на элемент в диапазоне [<first>,<last>]] с максимальным значением.
Например, чтобы найти значение<int2>с максимальным первым компонентом в данном векторе:
BOOST_COMPUTE_FUNCTION(bool, compare_first, (const int2_ &a, const int2_ &b),
{
return a.x < b.x;
});
boost::compute::vector<uint2_> data = ...
boost::compute::vector<uint2_>::iterator max =
boost::compute::max_element(data.begin(), data.end(), compare_first, queue);
См. также:
min_element()
Параметры: | |
compare
| объект функции сравнения, который возвращается истинным, если первый аргумент меньше (т.е. упорядочен до) второго. |
<first> | Первый элемент входного диапазона |
<last> | последний элемент во входном диапазоне |
<queue> | командная очередь для выполнения операции |