vsbuffalo / rivr

Other
4 stars 2 forks source link

Rcpp wrapper for STL vector #11

Open vsbuffalo opened 9 years ago

vsbuffalo commented 9 years ago

I've started working on an Rcpp version of dynamic lists (will share soon, might be separate package unless there's strong reason not to). Basically the idea (not yet working!) is to use std::vector<SEXP> — is this what you were thinking @richfitz? Then I can maintain an R6 object that has external pointers to the C++ object and wrap the C++ dynamic list class.

richfitz commented 9 years ago

I don't think that you want std::vector<SEXP> or you're going to have to have a lot of discussion with PROTECT; better to use an Rcpp type and avoid that. You'd probably be better using std::vector<Rcpp::RObject>. However, not everything inherits from RObject so that might not make much sense.

But both options would induce another copy when you push out to a list. So I think your current approach, directly copied over (i.e., storage in an Rcpp::List that is longer than necessary) might be best.

Then, if you use RcppR6 you can expose the same interface for your new package and the existing list object; that means we can swap the objects out at package load time.

richfitz commented 9 years ago

While you reimplement, can you swap size for capacity perhaps?

richfitz commented 9 years ago

Also, might be worth thinking about typed dynamic lists (using character, integer, etc rather than just list). Could be handled similarly to the vapply function by specifying the expected type.