1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_EXPERIMENTAL_SORT_BY_TRANSFORM_HPP
12 #define BOOST_COMPUTE_EXPERIMENTAL_SORT_BY_TRANSFORM_HPP
16 #include <boost/compute/algorithm/sort_by_key.hpp>
17 #include <boost/compute/algorithm/transform.hpp>
18 #include <boost/compute/container/vector.hpp>
19 #include <boost/compute/detail/iterator_range_size.hpp>
20 #include <boost/compute/type_traits/result_of.hpp>
24 namespace experimental {
26 template<class Iterator, class Transform, class Compare>
27 inline void sort_by_transform(Iterator first,
31 command_queue &queue = system::default_queue())
33 typedef typename std::iterator_traits<Iterator>::value_type value_type;
34 typedef typename boost::compute::result_of<Transform(value_type)>::type key_type;
36 size_t n = detail::iterator_range_size(first, last);
41 const context &context = queue.get_context();
43 ::boost::compute::vector<key_type> keys(n, context);
45 ::boost::compute::transform(
53 ::boost::compute::sort_by_key(
62 } // end experimental namespace
63 } // end compute namespace
64 } // end boost namespace
66 #endif // BOOST_COMPUTE_EXPERIMENTAL_SORT_BY_TRANSFORM_HPP