Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
rcpp中无序映射的使用_R_Rcpp - Fatal编程技术网

rcpp中无序映射的使用

rcpp中无序映射的使用,r,rcpp,R,Rcpp,我是一个新手,试图学习Rcpp中使用标准模板库(STL)的数据结构和算法实现 我试图在Rcpp中使用无序的_映射实现一个非常基本的哈希表,从Hadley的 这是我想在RCPP(取自)中实现的C++代码 #包括 #包括 #包括 使用名称空间std; int main() { 无序映射哈希表; hashtable.emplace(“www.element14.com”,“184.51.49.225”); cout这实际上只是缺少()旁边的散列测试 以下工作: // [[Rcpp::plugins(c

我是一个新手,试图学习Rcpp中使用标准模板库(STL)的数据结构和算法实现

我试图在Rcpp中使用无序的_映射实现一个非常基本的哈希表,从Hadley的

这是我想在RCPP(取自)

中实现的C++代码
#包括
#包括
#包括
使用名称空间std;
int main()
{
无序映射哈希表;
hashtable.emplace(“www.element14.com”,“184.51.49.225”);

cout这实际上只是缺少
()
旁边的
散列测试

以下工作:

// [[Rcpp::plugins(cpp11)]]
#include <Rcpp.h>
#include <unordered_map>
#include <string>


// [[Rcpp::export]]
int hash_test() { // missed the ()

  std::unordered_map<std::string, std::string> hashtable;

  hashtable.emplace("www.element14.com",
                    "184.51.49.225");

  Rcpp::Rcout << "IP Address: " << hashtable["www.element14.com"] << std::endl;
  return 0;
}
/[[Rcpp::plugins(cpp11)]]
#包括
#包括
#包括
//[[Rcpp::导出]]
int hash_test(){//缺少()
std::无序的_映射哈希表;
hashtable.emplace(“www.element14.com”,
"184.51.49.225");

Rcpp::Rcout这实际上只是缺少
()
旁边的
散列测试

以下工作:

// [[Rcpp::plugins(cpp11)]]
#include <Rcpp.h>
#include <unordered_map>
#include <string>


// [[Rcpp::export]]
int hash_test() { // missed the ()

  std::unordered_map<std::string, std::string> hashtable;

  hashtable.emplace("www.element14.com",
                    "184.51.49.225");

  Rcpp::Rcout << "IP Address: " << hashtable["www.element14.com"] << std::endl;
  return 0;
}
/[[Rcpp::plugins(cpp11)]]
#包括
#包括
#包括
//[[Rcpp::导出]]
int hash_test(){//缺少()
std::无序的_映射哈希表;
hashtable.emplace(“www.element14.com”,
"184.51.49.225");

Rcpp::Rcout哦,哇,我真是太蠢了。谢谢你指出@coatlessOh哇,我真是太蠢了。谢谢你指出@coatless
hash_test.cpp:11:46: error: expected primary-expression before ‘hashtable’
 std::unordered_map<std::string, std::string> hashtable;
                                              ^
hash_test.cpp:11:46: error: expected ‘}’ before ‘hashtable’
hash_test.cpp:11:46: error: expected ‘,’ or ‘;’ before ‘hashtable’
hash_test.cpp:12:1: error: ‘hashtable’ does not name a type
 hashtable.emplace("www.element14.com", "184.51.49.225");
 ^
hash_test.cpp:14:1: error: ‘Rcout’ does not name a type
 Rcout << "IP Address: " << hashtable["www.element14.com"] << endl;
 ^
hash_test.cpp:15:1: error: expected unqualified-id before ‘return’
 return 0;
 ^
hash_test.cpp:16:1: error: expected declaration before ‘}’ token
 }
 ^
make: *** [hash_test.o] Error 1
Error in sourceCpp("./CDM_Open_Source_ME/kohls_model/hash_test.cpp") : 
  Error 1 occurred building shared library.
In addition: Warning message:
No function found for Rcpp::export attribute at hash_test.cpp:9 
// [[Rcpp::plugins(cpp11)]]
#include <Rcpp.h>
#include <unordered_map>
#include <string>


// [[Rcpp::export]]
int hash_test() { // missed the ()

  std::unordered_map<std::string, std::string> hashtable;

  hashtable.emplace("www.element14.com",
                    "184.51.49.225");

  Rcpp::Rcout << "IP Address: " << hashtable["www.element14.com"] << std::endl;
  return 0;
}