こんにちは、このstd::vector<std::string>
ような日付時刻が含まれています。と2011-03-23T12:23:32.123
の 2 つのベクトルを生成したいと思います。int
20110323
122332123
私はC++
Rcpp というライブラリを使用しています (これは実際には問題ではないと思いますが、わからないのでRcpp
タグを付けます)
私は仕事をするこれをしましたが、それはかなり遅いです、どうすればこれをスピードアップできますか?
Rcpp::List datetimeToInt(vector<string> datetimes){
const int N=datetimes.size();
Rcpp::IntegerVector date(N); //please consider those as std::vector<int>
Rcpp::IntegerVector time(N);
//this is what I want to speed up
for(int i=0; i<N; ++i){
datetimes[i].erase(std::remove_if(datetimes[i].begin(), datetimes[i].end(), not1(ptr_fun(::isdigit))), datetimes[i].end());
date[i] = atoi(datetimes[i].substr(0,8).c_str());
time[i] = atoi(datetimes[i].substr(8,12).c_str());
}
return Rcpp::List::create(_["date"]=date, _["time"]=time);
}