comparison src/core/strings.cc @ 226:f784b5b1914c

settings: add library page
author Paper <mrpapersonic@gmail.com>
date Mon, 08 Jan 2024 21:23:00 -0500
parents 53211cb1e7f5
children 69f4768a820c
comparison
equal deleted inserted replaced
225:56ea2bdc6724 226:f784b5b1914c
27 std::string out; 27 std::string out;
28 28
29 for (unsigned long long i = 0; i < vector.size(); i++) { 29 for (unsigned long long i = 0; i < vector.size(); i++) {
30 out.append(vector.at(i)); 30 out.append(vector.at(i));
31 if (i < vector.size() - 1) 31 if (i < vector.size() - 1)
32 out.append(delimiter);
33 }
34
35 return out;
36 }
37
38 std::string Implode(const std::set<std::string>& set, const std::string& delimiter) {
39 if (set.size() < 1)
40 return "-";
41
42 std::string out;
43
44 for (auto it = set.cbegin(); it != set.cend(); it++) {
45 out.append(*it);
46 if (it != std::prev(set.cend(), 1))
32 out.append(delimiter); 47 out.append(delimiter);
33 } 48 }
34 49
35 return out; 50 return out;
36 } 51 }