Hi,
I've added the following methods to SEXP_Vector (which is the template
that generates GenericVector (aka List) and ExpressionVector so that
they look more like std::vector :
push_back
push_front
insert
erase
Methods that add new things use the implicit wrap idiom : they take a
templated parameter as input, wrap it up into a SEXP using wrap. They
also take care of names using the Named class as in e.g Language.
erase has a single element form to remove a single element and a range
based form erase( iterator first, iterator last ) to remove all elements
from first to last.
All these functions actually copy the internal SEXP, as R offers no way
to do otherwise.
As usual, examples included in the unit tests. Here is one:
funx <- cfunction( signature(x = "list"),
'
List list(x) ;
list.push_back( 10 ) ;
list.push_back( Named( "foo", "bar" ) ) ;
return list ;
', Rcpp = TRUE, includes = "using namespace Rcpp;" )
d <- list( x = 1:10, y = letters[1:10] )
res <- funx( d )
checkEquals( res,
list( x = 1:10, y = letters[1:10], 10L, foo = "bar" ),
msg = "List.push_back" )
Romain