MCPcopy Create free account
hub / github.com/Singular/Singular / split

Method split

ppcc/adlib/str.cc:12–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10}
11
12StrArr *Str::split(const char *s, Int n) {
13 if (n == 1)
14 return split(s[0]);
15 Arr<Int> *parts = new Arr<Int>();
16 parts->add(-n);
17 for (Int i = 0; i < _len - n; i++) {
18 if (_data[i] == s[0] && memcmp(_data + i, s, n)) {
19 parts->add(i);
20 i += n;
21 }
22 }
23 parts->add(_len);
24 StrArr *result = new StrArr(parts->len() - 1);
25 for (Int i = 1; i < parts->len(); i++) {
26 Int begin = parts->at(i - 1) + n;
27 Int end = parts->at(i);
28 result->add(new Str(_data + begin, end - begin));
29 }
30 return result;
31}
32
33StrArr *Str::split(Str *sep) {
34 return split(sep->_data, sep->_len);

Callers 5

process_inputFunction · 0.80
CheckFunction · 0.80
MainFunction · 0.80
NormalizePathFunction · 0.80
ProgramPathFunction · 0.80

Calls 4

splitFunction · 0.85
addMethod · 0.45
lenMethod · 0.45
atMethod · 0.45

Tested by 1

MainFunction · 0.64