File indexing completed on 2024-04-06 12:15:39
0001 #ifndef HeterogeneousCore_AlpakaInterface_interface_alpakastdAlgorithm_h
0002 #define HeterogeneousCore_AlpakaInterface_interface_alpakastdAlgorithm_h
0003
0004 #include <algorithm>
0005 #include <functional>
0006 #include <utility>
0007
0008 #include <alpaka/alpaka.hpp>
0009
0010
0011
0012
0013
0014 namespace alpaka_std {
0015
0016 template <typename RandomIt, typename T, typename Compare = std::less<T>>
0017 ALPAKA_FN_HOST_ACC constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp = {}) {
0018 auto count = last - first;
0019
0020 while (count > 0) {
0021 auto it = first;
0022 auto step = count / 2;
0023 it += step;
0024 if (!comp(value, *it)) {
0025 first = ++it;
0026 count -= step + 1;
0027 } else {
0028 count = step;
0029 }
0030 }
0031 return first;
0032 }
0033
0034 }
0035
0036 #endif