Skip to content

Instantly share code, notes, and snippets.

@artemklevtsov
Last active February 5, 2017 05:54
Show Gist options
  • Save artemklevtsov/28d1bffbec6f4feff20edc7375c99266 to your computer and use it in GitHub Desktop.
Save artemklevtsov/28d1bffbec6f4feff20edc7375c99266 to your computer and use it in GitHub Desktop.
// [[Rcpp::plugins("cpp11")]]
#include <Rcpp.h>
#include <functional>
using namespace Rcpp;
// [[Rcpp::export]]
std::vector<size_t> hash(const std::vector<std::string>& x) {
std::vector<size_t> res(x.size());
std::transform(x.begin(), x.end(), res.begin(), std::hash<std::string>());
return res;
}
/*** R
hash(c("string", "string", "other string", "sadasd"))
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment