refactoring

This commit is contained in:
Patrick Brosi 2018-07-25 20:14:46 +02:00
parent 7f0443243c
commit 5703eb47bd
5 changed files with 58 additions and 23 deletions

View file

@ -143,16 +143,25 @@ inline size_t editDist(const std::string& s1, const std::string& s2) {
}
// _____________________________________________________________________________
template <typename T>
inline std::string implode(const std::vector<T>& vec, const char* del) {
template <class Iter>
inline std::string implode(Iter begin, const Iter& end, const char* del) {
std::stringstream ss;
for (size_t i = 0; i < vec.size(); i++) {
size_t i = 0;
while (begin != end) {
if (i != 0) ss << del;
ss << vec[i];
ss << *begin;
begin++;
i++;
}
return ss.str();
}
// _____________________________________________________________________________
template <typename T>
inline std::string implode(const std::vector<T>& vec, const char* del) {
return implode(vec.begin(), vec.end(), del);
}
}
#endif // UTIL_STRING_H_