[Rcpp-commits] r559 - in pkg/src/Rcpp: . internal
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Feb 2 09:43:32 CET 2010
Author: romain
Date: 2010-02-02 09:43:31 +0100 (Tue, 02 Feb 2010)
New Revision: 559
Modified:
pkg/src/Rcpp/SimpleVector.h
pkg/src/Rcpp/internal/r_vector.h
Log:
various fixes
Modified: pkg/src/Rcpp/SimpleVector.h
===================================================================
--- pkg/src/Rcpp/SimpleVector.h 2010-02-02 08:28:10 UTC (rev 558)
+++ pkg/src/Rcpp/SimpleVector.h 2010-02-02 08:43:31 UTC (rev 559)
@@ -83,15 +83,10 @@
return start[ offset(i,j) ] ;
}
- // TODO : deal with coercion by dispatching the call using
- // the iterator traits, but for this we need a smart
- // coerce template
template <typename InputIterator>
void assign( InputIterator first, InputIterator last){
- size_t size = std::distance( first, last ) ;
- SEXP x = PROTECT(Rf_allocVector( RTYPE, size )) ;
- std::copy( first, last, get_pointer<RTYPE,CTYPE>(x) ) ;
- setSEXP(x) ;
+ SEXP x = PROTECT( r_cast<RTYPE>( wrap( first, last ) ) );
+ setSEXP( x) ;
UNPROTECT(1) ;
}
@@ -101,12 +96,9 @@
virtual void update(){ start = get_pointer<RTYPE,CTYPE>(m_sexp) ; }
void init(){
- CTYPE zero = internal::get_zero<RTYPE,CTYPE>() ;
- init( zero ) ;
+ internal::r_init_vector<RTYPE>(m_sexp) ;
}
- void init( const CTYPE& value){
- std::fill( start, start+length(), value ) ;
- }
+
} ;
}// namespace Rcpp
Modified: pkg/src/Rcpp/internal/r_vector.h
===================================================================
--- pkg/src/Rcpp/internal/r_vector.h 2010-02-02 08:28:10 UTC (rev 558)
+++ pkg/src/Rcpp/internal/r_vector.h 2010-02-02 08:43:31 UTC (rev 559)
@@ -50,8 +50,8 @@
*/
template<int RTYPE> void r_init_vector(SEXP x){
typedef typename ::Rcpp::traits::storage_type<RTYPE>::type CTYPE ;
- CTYPE* start=r_vector_start<RTYPE>(x) ;
- std::fill( start, start + Rf_length(x), get_zero<RTYPE,CTYPE>(0) ) ;
+ CTYPE* start=r_vector_start<RTYPE,CTYPE>(x) ;
+ std::fill( start, start + Rf_length(x), get_zero<RTYPE,CTYPE>() ) ;
}
/**
* Initializes a generic vector (VECSXP). Does nothing since
More information about the Rcpp-commits
mailing list