0

Following up on my previous question unordered_map use in Rcpp, I wish to know if there is a way I can use multiple unique keys with multiple unique values in an unordered_map within Rcpp.

Note: the unordered_map will have two unique keys of string type and two corresponding unique values of string and double type.

Question 1: Please enlighten me if I am wrong with this multiple key-value pair concept of hash table, i.e., if it is even possible to create a hash table like that.

I am trying to do something like this: // [[Rcpp::plugins(cpp11)]]

#include <Rcpp.h>
#include <unordered_map>
#include <string>


using namespace Rcpp;

//[[Rcpp::export]]

int hash_map()

{
  std::unordered_map<std::pair<std::string,std::string>,std::pair<std::string,double>> hashtable3;

  return 0;
}

But it gives me the following errors:

See error snapshot below
Question 2: Do I need to take hint from this example: C++ unordered_map using a custom class type as the key, although being someone who is just starting out in Rcpp and C++, I am not sure if I can even implement this in Rcpp, given the fact that exposing C++ classes is something entirely new to me. (I say this as I tried to read through this document Exposing C++ functions and classes with Rcpp modules, and it was a little overwhelming.

Gompu
  • 415
  • 1
  • 6
  • 21
  • 1
    I think Boost has multi-key hashes, and the BH package should give you that but I do not have an example handy right now... – Dirk Eddelbuettel Dec 01 '17 at 20:05
  • And please never ever post screen shots or images. It really is looked down upon on the site here... – Dirk Eddelbuettel Dec 01 '17 at 20:06
  • Cool. Earlier, I tried including boost in my rcpp file, but it gave an error. Can you give me an example how to go about that. Sorry I dont have the error it gave or the command I used. Any pointers will be helpful! – Gompu Dec 01 '17 at 20:07
  • Sorry, I did not know how else to give the error list as it was too big in the console. – Gompu Dec 01 '17 at 20:08
  • There are _numerous_ posts about using BH at the Rcpp Gallery. And numerous questions here. It is worth learning how to undertake more focused searches. – Dirk Eddelbuettel Dec 01 '17 at 20:09
  • Cool, thanks! I will look into it right away. BTW, I am having a fanboy moment talking to the creator of Rcpp directly. – Gompu Dec 01 '17 at 20:11

0 Answers0