Rcpp replaces binsearch