Advertisement
Bernard0x01

Untitled

May 13th, 2019
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. __device__ int lowerBound(Particle* particles, int size, int index) {
  2.     int lo = 0, hi = size - 1;
  3.     while (lo < hi) {
  4.         int mid = (lo + hi) / 2;
  5.         if (particles[mid].cell >= index) {
  6.             hi = mid;
  7.         } else {
  8.             lo = mid + 1;
  9.         }
  10.     }
  11.     if (particles[lo].cell == index) {
  12.         return lo;
  13.     }
  14.     return -1;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement