[Rcpp-devel] What is the most efficient method to check if a Rcpp vector contains an element?

Asis Hallab asis.hallab at gmail.com
Sun Dec 29 12:50:17 CET 2013


Dear Rcpp experst,

I hope everyone has had a pleasant Xmas.

I am just wondering what would be the recommended and most efficient way to
check, if a Rcpp Vector contains a given element?

If I am not mistaken the C++ standard approach for very large std::vectors
would be to first sort them and then perform a binary search:

http://stackoverflow.com/questions/571394/how-to-find-an-item-in-a-stdvector

What would be the Rcpp solution for the same task on a Rcpp vector?
Should I convert my Rcpp Vector to a std::vector and do the above, as
explained on the stackoverflow blog?

Cheers and a happy new year!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20131229/9bdeede0/attachment.html>


More information about the Rcpp-devel mailing list