[Rcpp-commits] r489 - in pkg/src: . Rcpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jan 27 23:07:28 CET 2010
Author: romain
Date: 2010-01-27 23:07:27 +0100 (Wed, 27 Jan 2010)
New Revision: 489
Modified:
pkg/src/CharacterVector.cpp
pkg/src/Rcpp/CharacterVector.h
Log:
only keep the templated range constructor and combine it with some implicit conversion
Modified: pkg/src/CharacterVector.cpp
===================================================================
--- pkg/src/CharacterVector.cpp 2010-01-27 21:57:57 UTC (rev 488)
+++ pkg/src/CharacterVector.cpp 2010-01-27 22:07:27 UTC (rev 489)
@@ -101,22 +101,22 @@
return StringProxy(*this, offset(i,j) ) ;
}
-void CharacterVector::assign( const char** first, const char** last){
- size_t size = std::distance( first, last ) ;
- SEXP x = m_sexp ;
- bool update = false ;
- if( length() != size ){
- x = Rf_allocVector( STRSXP, size ) ;
- update = true ;
- }
- for( size_t i=0; i<size; i++, ++first){
- SET_STRING_ELT( x, i, Rf_mkChar(*first)) ;
- }
- if( update ) setSEXP( x ) ;
-}
+// void CharacterVector::assign( const char** first, const char** last){
+// size_t size = std::distance( first, last ) ;
+// SEXP x = m_sexp ;
+// bool update = false ;
+// if( length() != size ){
+// x = Rf_allocVector( STRSXP, size ) ;
+// update = true ;
+// }
+// for( size_t i=0; i<size; i++, ++first){
+// SET_STRING_ELT( x, i, Rf_mkChar(*first)) ;
+// }
+// if( update ) setSEXP( x ) ;
+// }
-CharacterVector::CharacterVector( const char** const first, const char** const last) : VectorBase(){
- assign( first, last ) ;
-}
+// CharacterVector::CharacterVector( const char** const first, const char** const last) : VectorBase(){
+// assign( first, last ) ;
+// }
} // namespace
Modified: pkg/src/Rcpp/CharacterVector.h
===================================================================
--- pkg/src/Rcpp/CharacterVector.h 2010-01-27 21:57:57 UTC (rev 488)
+++ pkg/src/Rcpp/CharacterVector.h 2010-01-27 22:07:27 UTC (rev 489)
@@ -62,8 +62,6 @@
CharacterVector( const std::string& x );
CharacterVector( const std::vector<std::string>& x );
- CharacterVector( const char** first, const char** last) ;
-
template <typename InputIterator>
CharacterVector( InputIterator first, InputIterator last): VectorBase() {
assign( first, last ) ;
@@ -84,8 +82,6 @@
StringProxy operator()( const size_t& i) throw(index_out_of_bounds) ;
StringProxy operator()( const size_t& i, const size_t& j) throw(index_out_of_bounds,not_a_matrix) ;
- void assign( const char** const first, const char** const last) ;
-
template <typename InputIterator>
void assign( InputIterator first, InputIterator last){
size_t size = std::distance( first, last ) ;
@@ -95,8 +91,10 @@
x = Rf_allocVector( STRSXP, size ) ;
update = true ;
}
+ std::string y ;
for( size_t i=0; i<size; i++, ++first){
- SET_STRING_ELT( x, i, Rf_mkChar(first->c_str())) ;
+ y = *first ;
+ SET_STRING_ELT( x, i, Rf_mkChar(y.c_str())) ;
}
if( update ) setSEXP(x) ;
}
More information about the Rcpp-commits
mailing list