Mercurial > hg > octave-max
changeset 6639:ed74670db09b
[project @ 2007-05-21 19:47:22 by jwe]
author | jwe |
---|---|
date | Mon, 21 May 2007 19:47:22 +0000 |
parents | 15837c5982cb |
children | 379244420c72 |
files | src/ChangeLog src/load-save.cc src/ls-mat5.cc src/oct-map.cc src/oct-map.h src/octave.cc src/ov-struct.cc src/ov-struct.h src/ov.cc |
diffstat | 9 files changed, 24 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2007-05-21 John W. Eaton <jwe@octave.org> + + * oct-map.h (Octave_map::numel): Return number of array elements, + not number of map elements. + (Octave_map::nfields): Rename from length. + (Octave_map::empty): Delete. + Change all uses of empty to check nfields () == 0 instead. + 2007-05-21 Søren Hauberg <soren@hauberg.org> * help.cc (Fautoload): Doc fix.
--- a/src/load-save.cc +++ b/src/load-save.cc @@ -583,7 +583,7 @@ else octave_stdout << msg; } - else if (! retstruct.empty ()) + else if (retstruct.nfields () != 0) retval = retstruct; return retval;
--- a/src/ls-mat5.cc +++ b/src/ls-mat5.cc @@ -868,11 +868,11 @@ tc2 = m2.contents("MCOS")(0).cell_value()(1 + off).cell_value()(1); m2 = tc2.map_value(); symbol_table *local_sym_tab = 0; - if (m2.length() > 0) + if (m2.nfields() > 0) { octave_value tmp; - local_sym_tab = new symbol_table (((m2.length() + 1) & ~1), + local_sym_tab = new symbol_table (((m2.nfields() + 1) & ~1), "LOCAL"); for (Octave_map::iterator p0 = m2.begin() ;
--- a/src/oct-map.cc +++ b/src/oct-map.cc @@ -91,7 +91,7 @@ string_vector Octave_map::keys (void) const { - assert (length () == key_list.size ()); + assert (nfields () == key_list.size ()); return string_vector (key_list); } @@ -134,28 +134,12 @@ return retval; } -octave_idx_type -Octave_map::numel (void) const -{ - octave_idx_type retval; - - if (empty ()) - retval = 0; - else - { - Cell tmp = contents (begin ()); - retval = tmp.numel (); - } - - return retval; -} - void Octave_map::resize (const dim_vector& dv, bool fill) { if (dv != dims ()) { - if (empty ()) + if (nfields () == 0) dimensions = dv; else { @@ -181,7 +165,7 @@ { Octave_map retval; - if (length() == rb.length()) + if (nfields () == rb.nfields ()) { for (const_iterator pa = begin (); pa != end (); pa++) { @@ -210,7 +194,7 @@ keys = string_vector (); - if (a.empty ()) + if (a.nfields () == 0) { keys = b.keys (); retval = true; @@ -382,7 +366,7 @@ Octave_map& Octave_map::assign (const std::string& k, const octave_value& rhs) { - if (empty ()) + if (nfields () == 0) { maybe_add_to_key_list (k); @@ -410,7 +394,7 @@ Octave_map& Octave_map::assign (const std::string& k, const Cell& rhs) { - if (empty ()) + if (nfields () == 0) { maybe_add_to_key_list (k);
--- a/src/oct-map.h +++ b/src/oct-map.h @@ -88,9 +88,7 @@ ~Octave_map (void) { } // This is the number of keys. - octave_idx_type length (void) const { return map.size (); } - - int empty (void) const { return map.empty (); } + octave_idx_type nfields (void) const { return map.size (); } void del (const std::string& k) { @@ -159,7 +157,7 @@ void resize (const dim_vector& dv, bool fill = false); - octave_idx_type numel (void) const; + octave_idx_type numel (void) const { return dimensions.numel (); } Octave_map concat (const Octave_map& rb, const Array<octave_idx_type>& ra_idx);
--- a/src/octave.cc +++ b/src/octave.cc @@ -235,7 +235,7 @@ if (nargin == 4) { - if (vinfo.empty ()) + if (vinfo.nfields () == 0) { vinfo.assign ("Name", args (0)); vinfo.assign ("Version", args (1));
--- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -1020,7 +1020,7 @@ octave_struct::save_ascii (std::ostream& os, bool& infnan_warned) { Octave_map m = map_value (); - os << "# length: " << m.length () << "\n"; + os << "# length: " << m.nfields () << "\n"; Octave_map::iterator i = m.begin (); while (i != m.end ()) @@ -1099,7 +1099,7 @@ { Octave_map m = map_value (); - int32_t len = m.length(); + int32_t len = m.nfields (); os.write (reinterpret_cast<char *> (&len), 4); Octave_map::iterator i = m.begin ();
--- a/src/ov-struct.h +++ b/src/ov-struct.h @@ -95,7 +95,7 @@ return dv.numel (); } - octave_idx_type nfields (void) const { return map.length (); } + octave_idx_type nfields (void) const { return map.nfields (); } octave_value reshape (const dim_vector& new_dims) const { return map.reshape (new_dims); }
--- a/src/ov.cc +++ b/src/ov.cc @@ -1877,7 +1877,7 @@ Octave_map m = arg.map_value (); if (! error_state - && m.length () == 2 && m.contains ("type") && m.contains ("subs")) + && m.nfields () == 2 && m.contains ("type") && m.contains ("subs")) { Cell& type = m.contents ("type"); Cell& subs = m.contents ("subs");