| 52 | double vec_at(vec *obj, int i){ return obj->at(i) ; } |
| 53 | |
| 54 | RCPP_MODULE(stdVector){ |
| 55 | using namespace Rcpp ; |
| 56 | |
| 57 | // we expose the class std::vector<double> as "vec" on the R side |
| 58 | class_<vec>("vec") |
| 59 | |
| 60 | // exposing the default constructor |
| 61 | .constructor() |
| 62 | |
| 63 | // exposing member functions -- taken directly from std::vector<double> |
| 64 | .method( "size", &vec::size) |
| 65 | .method( "max_size", &vec::max_size) |
| 66 | .method( "capacity", &vec::capacity) |
| 67 | .method( "empty", &vec::empty) |
| 68 | .method( "reserve", &vec::reserve) |
| 69 | .method( "pop_back", &vec::pop_back ) |
| 70 | .method( "clear", &vec::clear ) |
| 71 | |
| 72 | // specifically exposing const member functions defined above |
| 73 | .method( "back", &vec_back ) |
| 74 | .method( "front", &vec_front ) |
| 75 | .method( "at", &vec_at ) |
| 76 | |
| 77 | // exposing free functions taking a std::vector<double>* |
| 78 | // as their first argument |
| 79 | .method( "assign", &vec_assign ) |
| 80 | .method( "insert", &vec_insert ) |
| 81 | .method( "as.vector",&vec_asR ) |
| 82 | .method( "push_back",&vec_push_back ) |
| 83 | .method( "resize", &vec_resize) |
| 84 | |
| 85 | // special methods for indexing |
| 86 | .method( "[[", &vec_at ) |
| 87 | .method( "[[<-", &vec_set ) |
| 88 | |
| 89 | ; |
| 90 | } |
nothing calls this directly
no outgoing calls
no test coverage detected