MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / SplitOnChar

Function SplitOnChar

tensorflow/core/kernels/string_split_op.cc:63–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62template <typename Predicate>
63std::vector<StringPiece> SplitOnChar(const string& str,
64 const char delim, Predicate p) {
65 std::vector<StringPiece> result;
66 StringPiece text(str);
67 auto f = text.find(delim);
68 while (f != StringPiece::npos) {
69 StringPiece token = text.substr(0, f);
70 if (p(token)) {
71 result.emplace_back(token);
72 }
73 text.remove_prefix(f + 1);
74 f = text.find(delim);
75 }
76 if (p(text)) {
77 result.push_back(text);
78 }
79 return result;
80}
81
82// Split input string `str` based on a set of character delimiters.
83// Returns a vector of StringPieces which are valid as long as input `str`

Callers 1

SplitFunction · 0.85

Calls 3

findMethod · 0.45
emplace_backMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected