library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub matumoto1234/library

:warning: string/split.hpp

Depends on

Code

#pragma once

#include "./base.hpp"

#include <string>
#include <vector>

namespace matumoto {
  vector<string> split(const string &str, const string &sep, const int &max_split = INT32_MAX) {
    vector<string> res;
    string t = "";
    int cnt_split = 0;
    for (auto c: str) {
      if (sep.find(c) == string::npos or cnt_split >= max_split) {
        t += c;
        continue;
      }
      res.emplace_back(t);
      t = "";
      cnt_split++;
    }
    if (t != "")
      res.emplace_back(t);
    return res;
  }
} // namespace matumoto
#line 2 "string/split.hpp"

#line 2 "string/base.hpp"

namespace matumoto {
  using namespace std;
}
#line 4 "string/split.hpp"

#include <string>
#include <vector>

namespace matumoto {
  vector<string> split(const string &str, const string &sep, const int &max_split = INT32_MAX) {
    vector<string> res;
    string t = "";
    int cnt_split = 0;
    for (auto c: str) {
      if (sep.find(c) == string::npos or cnt_split >= max_split) {
        t += c;
        continue;
      }
      res.emplace_back(t);
      t = "";
      cnt_split++;
    }
    if (t != "")
      res.emplace_back(t);
    return res;
  }
} // namespace matumoto
Back to top page