Adding a new component to a DatetimeVector in Rcpp

梦想的初衷 提交于 2019-12-20 07:30:09

问题


I would appreciate if someone could help me in push_back a new component into DatetimeVector. A DatetimeVector only has begin, end, getDatetimes and size methods.


回答1:


I'd say don't. For multiple reasons:

  1. All Rcpp types uses an underlying SEXP which requires contiguous memory. So adding a single element always requires copying all--expensive.
  2. The DatetimeVector class is pretty bad. I wrote it many years ago to pass data to QuantLib.
  3. These days we can do better via simple NumericVector classes to POSIXct -- see eg here in Rblpapi


来源:https://stackoverflow.com/questions/33794296/adding-a-new-component-to-a-datetimevector-in-rcpp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!