-
-
Notifications
You must be signed in to change notification settings - Fork 219
Closed
Description
This fails because of missing std::hash<String>
.
// [[Rcpp::export]]
IntegerVector matchCpp( CharacterVector x, CharacterVector table){
// first train an unordered_map
std::unordered_map<String,int> map ;
for( int i=0; i<table.size(); i++){
String s = table[i] ;
map[s] = i +1 ;
}
// now lookup
int n = x.size() ;
IntegerVector out(n) ;
for( int i=0; i<n; i++){
String s = x[i] ;
out[i] = map[s]->second ;
}
return out ;
}