Created
September 16, 2015 15:37
-
-
Save sifue/828075ed748cb465560c to your computer and use it in GitHub Desktop.
比較的早いC++のstringのsplit
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
| vector<string> split(const string &str, char delim){ | |
| vector<string> res; | |
| size_t current = 0, found; | |
| while((found = str.find_first_of(delim, current)) != string::npos){ | |
| res.push_back(string(str, current, found - current)); | |
| current = found + 1; | |
| } | |
| res.push_back(string(str, current, str.size() - current)); | |
| return res; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment