MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / insert__impl

Method insert__impl

inst/include/Rcpp/vector/Vector.h:840–879  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

838 }
839
840 iterator insert__impl( iterator position, const stored_type& object_, traits::true_type ) {
841 Shield<SEXP> object( object_ ) ;
842 R_xlen_t n = size() ;
843 Vector target( n+1 ) ;
844 iterator target_it = target.begin();
845 iterator it = begin() ;
846 iterator this_end = end() ;
847 SEXP names = RCPP_GET_NAMES(Storage::get__()) ;
848 iterator result ;
849 if( Rf_isNull(names) ){
850 for( ; it < position; ++it, ++target_it){
851 *target_it = *it ;
852 }
853 result = target_it;
854 *target_it = object ;
855 ++target_it ;
856 for( ; it < this_end; ++it, ++target_it ){
857 *target_it = *it ;
858 }
859 } else{
860 Shield<SEXP> newnames( ::Rf_allocVector( STRSXP, n + 1 ) ) ;
861 int i=0;
862 for( ; it < position; ++it, ++target_it, i++){
863 *target_it = *it ;
864 SET_STRING_ELT( newnames, i, STRING_ELT(names, i ) ) ;
865 }
866 result = target_it;
867 *target_it = object ;
868 SET_STRING_ELT( newnames, i, ::Rf_mkChar("") ) ;
869 i++ ;
870 ++target_it ;
871 for( ; it < this_end; ++it, ++target_it, i++ ){
872 *target_it = *it ;
873 SET_STRING_ELT( newnames, i, STRING_ELT(names, i - 1) ) ;
874 }
875 target.attr( "names" ) = newnames ;
876 }
877 Storage::set__( target.get__() ) ;
878 return result ;
879 }
880
881 iterator insert__impl( iterator position, const stored_type& object, traits::false_type ) {
882 R_xlen_t n = size() ;

Callers

nothing calls this directly

Calls 3

attrMethod · 0.80
beginMethod · 0.45
get__Method · 0.45

Tested by

no test coverage detected