Mercurial > hg > octave-lyh
diff liboctave/str-vec.cc @ 12964:8ec12d686796
new string_vector::join method
* str-vec.cc, str-vec.h (string_vector::join): New method.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 15 Aug 2011 10:05:28 -0400 |
parents | 57632dea2446 |
children | 72c96de7a403 |
line wrap: on
line diff
--- a/liboctave/str-vec.cc +++ b/liboctave/str-vec.cc @@ -163,6 +163,26 @@ return *this; } +std::string +string_vector::join (const std::string& sep) const +{ + std::string retval; + + octave_idx_type len = length (); + + if (len > 0) + { + octave_idx_type i; + + for (i = 0; i < len - 1; i++) + retval += elem(i) + sep; + + retval += elem(i); + } + + return retval; +} + char ** string_vector::c_str_vec (void) const {