Rcpp check if list has an element -


my program deals clustering. apart dataset user has specify details concerning clusters. there 2 ways approach that: specify number of clusters or prepare list of clusters' descriptions.

args <- list(dataset=points, k=5) args <- list(dataset=points, clusters=list(                              list(type="spherical",radius=4),                              list(type="covariance",covmat=matrix)                                           ) 

next call proper function (my program) in r args argument.

classification <- cec(args) 

i prepare cec below

sexp cec(sexp args) {   rcpp::list list(args);   arma::mat dataset = rcpp::as<arma::mat>(list["dataset"]);   if(list.contains("k")) {     //something   } else if(list.contains("clusters")) {     //something   } } 

i cannot find api list or example how that. moreover, study headers of rcpp definition of list typedef vector<vecsxp> list ; hardly helpful.

is there can use instead of list.contains() ?

you looking containselementnamed method:

rcpp::list list(args); if( list.containselementnamed("k") ){     // } else {     // else } 

https://github.com/rcppcore/rcpp/blob/master/inst/include/rcpp/vector/vector.h#l503


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -