Mercurial > hg > octave-nkf
diff liboctave/str-vec.cc @ 5275:23b37da9fd5b
[project @ 2005-04-08 16:07:35 by jwe]
author | jwe |
---|---|
date | Fri, 08 Apr 2005 16:07:37 +0000 |
parents | fad289f3df73 |
children | 7b6edb02f8c9 |
line wrap: on
line diff
--- a/liboctave/str-vec.cc +++ b/liboctave/str-vec.cc @@ -44,7 +44,7 @@ string_vector::string_vector (const char * const *s) : Array<std::string> () { - int n = 0; + octave_idx_type n = 0; const char * const *t = s; @@ -53,17 +53,17 @@ resize (n); - for (int i = 0; i < n; i++) + for (octave_idx_type i = 0; i < n; i++) elem (i) = s[i]; } // Create a string vector from up to N C strings. Assumes that N is // nonnegative. -string_vector::string_vector (const char * const *s, int n) +string_vector::string_vector (const char * const *s, octave_idx_type n) : Array<std::string> (n) { - for (int i = 0; i < n; i++) + for (octave_idx_type i = 0; i < n; i++) elem (i) = s[i]; } @@ -79,13 +79,13 @@ string_vector& string_vector::uniq (void) { - int len = length (); + octave_idx_type len = length (); if (len > 0) { - int k = 0; + octave_idx_type k = 0; - for (int i = 1; i < len; i++) + for (octave_idx_type i = 1; i < len; i++) if (elem(i) != elem(k)) if (++k != i) elem(k) = elem(i); @@ -100,7 +100,7 @@ string_vector& string_vector::append (const std::string& s) { - int len = length (); + octave_idx_type len = length (); resize (len + 1); @@ -112,13 +112,13 @@ string_vector& string_vector::append (const string_vector& sv) { - int len = length (); - int sv_len = sv.length (); - int new_len = len + sv_len; + octave_idx_type len = length (); + octave_idx_type sv_len = sv.length (); + octave_idx_type new_len = len + sv_len; resize (new_len); - for (int i = 0; i < sv_len; i++) + for (octave_idx_type i = 0; i < sv_len; i++) elem(len + i) = sv[i]; return *this; @@ -127,13 +127,13 @@ char ** string_vector::c_str_vec (void) const { - int len = length (); + octave_idx_type len = length (); char **retval = new char * [len + 1]; retval [len] = 0; - for (int i = 0; i < len; i++) + for (octave_idx_type i = 0; i < len; i++) retval[i] = strsave (elem(i).c_str ()); return retval; @@ -155,12 +155,12 @@ { // Compute the maximum name length. - int max_name_length = 0; - int total_names = length (); + octave_idx_type max_name_length = 0; + octave_idx_type total_names = length (); - for (int i = 0; i < total_names; i++) + for (octave_idx_type i = 0; i < total_names; i++) { - int name_length = elem (i).length (); + octave_idx_type name_length = elem (i).length (); if (name_length > max_name_length) max_name_length = name_length; } @@ -171,25 +171,25 @@ // Calculate the maximum number of columns that will fit. - int line_length = command_editor::terminal_cols (); - int nc = line_length / max_name_length; + octave_idx_type line_length = command_editor::terminal_cols (); + octave_idx_type nc = line_length / max_name_length; if (nc == 0) nc = 1; // Calculate the number of rows that will be in each column except // possibly for a short column on the right. - int nr = total_names / nc + (total_names % nc != 0); + octave_idx_type nr = total_names / nc + (total_names % nc != 0); // Recalculate columns based on rows. nc = total_names / nr + (total_names % nr != 0); - int count; - for (int row = 0; row < nr; row++) + octave_idx_type count; + for (octave_idx_type row = 0; row < nr; row++) { count = row; - int pos = 0; + octave_idx_type pos = 0; // Print the next row. @@ -198,14 +198,14 @@ std::string nm = elem (count); os << nm; - int name_length = nm.length (); + octave_idx_type name_length = nm.length (); count += nr; if (count >= total_names) break; - int spaces_to_pad = max_name_length - name_length; - for (int i = 0; i < spaces_to_pad; i++) + octave_idx_type spaces_to_pad = max_name_length - name_length; + for (octave_idx_type i = 0; i < spaces_to_pad; i++) os << " "; pos += max_name_length; }