Skip to content

Missing std::hash<String> #84

@romainfrancois

Description

@romainfrancois

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 ;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions