MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / upper_bound

Function upper_bound

Src/Base/AMReX_Algorithm.H:237–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235 */
236 template<typename ItType, typename ValType>
237 AMREX_GPU_HOST_DEVICE
238 ItType upper_bound (ItType first, ItType last, const ValType& val)
239 {
240 AMREX_IF_ON_DEVICE((
241 std::ptrdiff_t count = last-first;
242 while(count>0){
243 auto it = first;
244 const auto step = count/2;
245 it += step;
246 if (!(val < *it)){
247 first = ++it;
248 count -= step + 1;
249 }
250 else{
251 count = step;
252 }
253 }
254 return first;
255 ))
256 AMREX_IF_ON_HOST((
257 return std::upper_bound(first, last, val);
258 ))
259 }
260
261 /**
262 * \brief Return an iterator to the first element not less than a given

Callers 3

buildCopiesFunction · 0.85
packBufferFunction · 0.85
unpackBufferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected