Created
January 6, 2014 00:43
-
-
Save earino/8276264 to your computer and use it in GitHub Desktop.
String Slicer in C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Rcpp.h> | |
#include <iostream> | |
using namespace Rcpp; | |
using namespace std; | |
. | |
// [[Rcpp::export]] | |
std::string string_slicer( std::string input, std::vector< int > start, std::vector< int > end) { | |
std::string working_copy = input; | |
for(std::vector<int>::size_type i = start.size() - 1; i != (std::vector<int>::size_type) -1; i--) { | |
working_copy.erase(start[i]-1, (end[i] - start[i])+1);. | |
} | |
return working_copy; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment