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

Method push_back_name__impl

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

Source from the content-addressed store, hash-verified

670 }
671
672 void push_back_name__impl(const stored_type& object, const std::string& name, traits::true_type ) {
673 Shield<SEXP> object_sexp( object ) ;
674 R_xlen_t n = size() ;
675 Vector target( n + 1 ) ;
676 iterator target_it( target.begin() ) ;
677 iterator it(begin()) ;
678 iterator this_end(end());
679 SEXP names = RCPP_GET_NAMES(Storage::get__()) ;
680 Shield<SEXP> newnames( ::Rf_allocVector( STRSXP, n+1 ) ) ;
681 int i=0;
682 if( Rf_isNull(names) ){
683 for( ; it < this_end; ++it, ++target_it,i++ ){
684 *target_it = *it ; // #nocov
685 SET_STRING_ELT( newnames, i , R_BlankString ); // #nocov
686 }
687 } else {
688 for( ; it < this_end; ++it, ++target_it, i++ ){
689 *target_it = *it ;
690 SET_STRING_ELT( newnames, i, STRING_ELT(names, i ) ) ;
691 }
692 }
693 SET_STRING_ELT( newnames, i, Rf_mkChar( name.c_str() ) );
694 target.attr("names") = newnames ;
695
696 *target_it = object_sexp;
697 Storage::set__( target.get__() ) ;
698 }
699 void push_back_name__impl(const stored_type& object, const std::string& name, traits::false_type ) {
700 R_xlen_t n = size() ;
701 Vector target( n + 1 ) ;

Callers

nothing calls this directly

Calls 3

attrMethod · 0.80
beginMethod · 0.45
get__Method · 0.45

Tested by

no test coverage detected