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

Method get_vec

inst/include/Rcpp/vector/Subsetter.h:205–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203 }
204
205 Vector<RTYPE, StoragePolicy> get_vec() const {
206 Vector<RTYPE, StoragePolicy> output = no_init(indices_n);
207 for (R_xlen_t i=0; i < indices_n; ++i) {
208 output[i] = lhs[ indices[i] ];
209 }
210 SEXP names = Rf_getAttrib(lhs, R_NamesSymbol);
211 if (!Rf_isNull(names)) {
212 Shield<SEXP> out_names( Rf_allocVector(STRSXP, indices_n) );
213 for (R_xlen_t i=0; i < indices_n; ++i) {
214 SET_STRING_ELT(out_names, i, STRING_ELT(names, indices[i]));
215 }
216 Rf_setAttrib(output, R_NamesSymbol, out_names);
217 }
218 Rf_copyMostAttrib(lhs, output);
219 return output;
220 }
221
222 LHS_t& lhs;
223 const RHS_t& rhs;

Callers

nothing calls this directly

Calls 1

no_initFunction · 0.85

Tested by

no test coverage detected