[Rcpp-commits] r588 - in pkg: inst src/Rcpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Feb 6 09:47:32 CET 2010


Author: romain
Date: 2010-02-06 09:47:29 +0100 (Sat, 06 Feb 2010)
New Revision: 588

Modified:
   pkg/inst/ChangeLog
   pkg/src/Rcpp/ComplexVector.h
   pkg/src/Rcpp/IntegerVector.h
   pkg/src/Rcpp/LogicalVector.h
   pkg/src/Rcpp/NumericVector.h
   pkg/src/Rcpp/RawVector.h
   pkg/src/Rcpp/SimpleVector.h
Log:
simplevector now only templated by the sexp type (the c storage type is retrieved by traits)

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2010-02-05 18:15:07 UTC (rev 587)
+++ pkg/inst/ChangeLog	2010-02-06 08:47:29 UTC (rev 588)
@@ -1,3 +1,9 @@
+2010-02-06  Romain Francois <francoisromain at free.fr>
+
+	* src/Rcpp/SimpleVector.h: SimpleVector is now only parameterized
+	by the SEXP type. The c type is automatically retrieved using 
+	the storage_type trait class.
+
 2010-02-05  Dirk Eddelbuettel  <edd at debian.org>
 
 	* inst/THANKS: Added in order to show our appreciation

Modified: pkg/src/Rcpp/ComplexVector.h
===================================================================
--- pkg/src/Rcpp/ComplexVector.h	2010-02-05 18:15:07 UTC (rev 587)
+++ pkg/src/Rcpp/ComplexVector.h	2010-02-06 08:47:29 UTC (rev 588)
@@ -27,7 +27,7 @@
 
 namespace Rcpp{ 
 
-typedef SimpleVector<CPLXSXP,Rcomplex> ComplexVector ;	
+typedef SimpleVector<CPLXSXP> ComplexVector ;	
 
 } // namespace
 

Modified: pkg/src/Rcpp/IntegerVector.h
===================================================================
--- pkg/src/Rcpp/IntegerVector.h	2010-02-05 18:15:07 UTC (rev 587)
+++ pkg/src/Rcpp/IntegerVector.h	2010-02-06 08:47:29 UTC (rev 588)
@@ -27,7 +27,7 @@
 
 namespace Rcpp{ 
 
-typedef SimpleVector<INTSXP,int> IntegerVector ;
+typedef SimpleVector<INTSXP> IntegerVector ;
 
 } // namespace
 

Modified: pkg/src/Rcpp/LogicalVector.h
===================================================================
--- pkg/src/Rcpp/LogicalVector.h	2010-02-05 18:15:07 UTC (rev 587)
+++ pkg/src/Rcpp/LogicalVector.h	2010-02-06 08:47:29 UTC (rev 588)
@@ -27,7 +27,7 @@
 
 namespace Rcpp{
 
-typedef SimpleVector<LGLSXP,int> LogicalVector ;
+typedef SimpleVector<LGLSXP> LogicalVector ;
 
 } // namespace
 

Modified: pkg/src/Rcpp/NumericVector.h
===================================================================
--- pkg/src/Rcpp/NumericVector.h	2010-02-05 18:15:07 UTC (rev 587)
+++ pkg/src/Rcpp/NumericVector.h	2010-02-06 08:47:29 UTC (rev 588)
@@ -27,7 +27,7 @@
 
 namespace Rcpp{ 
 
-typedef SimpleVector<REALSXP,double> NumericVector ;
+typedef SimpleVector<REALSXP> NumericVector ;
 
 } // namespace
 

Modified: pkg/src/Rcpp/RawVector.h
===================================================================
--- pkg/src/Rcpp/RawVector.h	2010-02-05 18:15:07 UTC (rev 587)
+++ pkg/src/Rcpp/RawVector.h	2010-02-06 08:47:29 UTC (rev 588)
@@ -27,7 +27,7 @@
 
 namespace Rcpp{ 
 
-typedef SimpleVector<RAWSXP,Rbyte> RawVector ;
+typedef SimpleVector<RAWSXP> RawVector ;
 
 } // namespace
 

Modified: pkg/src/Rcpp/SimpleVector.h
===================================================================
--- pkg/src/Rcpp/SimpleVector.h	2010-02-05 18:15:07 UTC (rev 587)
+++ pkg/src/Rcpp/SimpleVector.h	2010-02-06 08:47:29 UTC (rev 588)
@@ -30,9 +30,14 @@
 
 namespace Rcpp{
 
-template <int RTYPE, typename CTYPE>
+template <int RTYPE>
 class SimpleVector : public VectorBase {
 public:
+	
+	typedef typename traits::storage_type<RTYPE>::type value_type ;
+	typedef value_type* iterator ;
+	typedef value_type& reference ;
+	
 	SimpleVector() : VectorBase(), start(0){}
 	
 	SimpleVector(SEXP x) throw(RObject::not_compatible) : VectorBase(), start(0){
@@ -59,20 +64,20 @@
 	}
 	
 #ifdef HAS_INIT_LISTS
-	SimpleVector( std::initializer_list<CTYPE> list ) : VectorBase(), start(0){
+	SimpleVector( std::initializer_list<value_type> list ) : VectorBase(), start(0){
 		assign( list.begin() , list.end() ) ;
 	}
 #endif
 
-	inline CTYPE& operator[]( const int& i ){ return start[i] ; }
-	inline CTYPE* begin() const{ return start ; }
-	inline CTYPE* end() const{ return start+Rf_length(m_sexp); }
+	inline reference operator[]( const int& i ){ return start[i] ; }
+	inline iterator begin() const{ return start ; }
+	inline iterator end() const{ return start+Rf_length(m_sexp); }
 	
-	inline CTYPE& operator()( const size_t& i) throw(RObject::index_out_of_bounds){
+	inline reference operator()( const size_t& i) throw(RObject::index_out_of_bounds){
 		return start[ offset(i) ] ;
 	}
 	
-	inline CTYPE& operator()( const size_t& i, const size_t& j) throw(VectorBase::not_a_matrix,RObject::index_out_of_bounds){
+	inline reference operator()( const size_t& i, const size_t& j) throw(VectorBase::not_a_matrix,RObject::index_out_of_bounds){
 		return start[ offset(i,j) ] ;
 	}
 	
@@ -87,10 +92,10 @@
 	}
 
 private:
-	CTYPE* start ;
+	value_type* start ;
 	
 	virtual void update(){ 
-		start = internal::r_vector_start<RTYPE,CTYPE>(m_sexp) ;
+		start = internal::r_vector_start<RTYPE,value_type>(m_sexp) ;
 	}
 	
 	void init(){



More information about the Rcpp-commits mailing list