[Rcpp-devel] Simple List Operations
Greg Minshall
minshall at umich.edu
Wed Mar 6 19:07:17 CET 2013
(since i've just been here...)
.../unitTests/runit.Vector.R has these tests:
----
test.List.erase <- function(){
fun <- list_erase
d <- list( x = 1:10, y = letters[1:10] )
checkEquals(fun(d),
list( y = letters[1:10] ),
msg = "List.erase" )
}
test.List.erase.range <- function(){
fun <- list_erase_range
d <- list( x = 1:10, y = letters[1:10], z = 1:10 )
checkEquals(fun(d),
list( z = 1:10 ),
msg = "List.erase (range version)" )
}
----
the functions list_erase{,_range} are in .../unitTests/cpp/Vector.cpp:
----
// [[Rcpp::export]]
List list_erase( List list ){
list.erase( list.begin() ) ;
return list ;
}
// [[Rcpp::export]]
List list_erase_range( List list ){
list.erase( 0, 1 ) ;
return list ;
}
----
i haven't tried these.
More information about the Rcpp-devel
mailing list