[Rcpp-commits] r4333 - in pkg/Rcpp: . inst/include/Rcpp/api/meat

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 5 18:51:58 CEST 2013


Author: romain
Date: 2013-06-05 18:51:58 +0200 (Wed, 05 Jun 2013)
New Revision: 4333

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/api/meat/Vector.h
Log:
correct return value of erase

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2013-06-05 15:11:01 UTC (rev 4332)
+++ pkg/Rcpp/ChangeLog	2013-06-05 16:51:58 UTC (rev 4333)
@@ -1,6 +1,7 @@
 2013-06-05 Romain Francois <romain at r-enthusiasts.com>
 
         * include/Rcpp/api/meat/Vector.h : fixed Vector<>::erase(iterator, iterator)
+        and correct return value of erase
         * unitTests/cpp/Vector.cpp : added regression test for the above fix
         * unitTests/runit.Vector.R : added regression test for the above fix
         * include/Rcpp/module/class.h : removed useless typedef

Modified: pkg/Rcpp/inst/include/Rcpp/api/meat/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/api/meat/Vector.h	2013-06-05 15:11:01 UTC (rev 4332)
+++ pkg/Rcpp/inst/include/Rcpp/api/meat/Vector.h	2013-06-05 16:51:58 UTC (rev 4333)
@@ -247,16 +247,16 @@
         iterator this_end(end()) ;
         SEXP names = RCPP_GET_NAMES(RObject::m_sexp) ;
         if( names == R_NilValue ){
-            for( ; it < position; ++it, ++target_it){
+            int i=0; 
+            for( ; it < position; ++it, ++target_it, i++){
                 *target_it = *it;
             }
-            iterator result(target_it) ;
             ++it ;
             for( ; it < this_end ; ++it, ++target_it){
                 *target_it = *it;
             }
             set_sexp( target.asSexp() ) ;
-            return result ;
+            return begin()+i ;
         } else {
             SEXP newnames = PROTECT(::Rf_allocVector( STRSXP, n-1 ));
             int i= 0 ;
@@ -264,7 +264,7 @@
                 *target_it = *it;
                 SET_STRING_ELT( newnames, i , STRING_ELT(names,i) ) ;
             }
-            iterator result(target_it) ;
+            int result=i ;
             ++it ;
             i++ ;
             for( ; it < this_end ; ++it, ++target_it, i++){
@@ -274,7 +274,7 @@
             target.attr( "names" ) = newnames ;
             UNPROTECT(1) ; /* newnames */
             set_sexp( target.asSexp() ) ;
-            return result ;
+            return begin()+result ;
         }
     }
     
@@ -293,10 +293,11 @@
         SEXP names = RCPP_GET_NAMES(RObject::m_sexp) ;
         iterator result ;
         if( names == R_NilValue ){
-            for( ; it < first; ++it, ++target_it ){
+            int i=0; 
+            for( ; it < first; ++it, ++target_it, i++ ){
                 *target_it = *it ;
             }
-            result = target_it +1 ;
+            result = begin() + i + 1 ;
             for( it = last ; it < this_end; ++it, ++target_it ){
                 *target_it = *it ;
             }
@@ -307,7 +308,7 @@
                 *target_it = *it ;
                 SET_STRING_ELT( newnames, i, STRING_ELT(names, i ) );
             }
-            result = target_it + 1 ;
+            result = begin() + i + 1 ;
             for( it = last ; it < this_end; ++it, ++target_it, i++ ){
                 *target_it = *it ;
                 SET_STRING_ELT( newnames, i, STRING_ELT(names, i + nremoved ) );



More information about the Rcpp-commits mailing list