refactoring
This commit is contained in:
parent
7f0443243c
commit
5703eb47bd
5 changed files with 58 additions and 23 deletions
|
|
@ -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_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue