Mercurial > hg > octave-terminal
changeset 9379:d77fa87c47d8
oct-map.cc: preserve key order
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 23 Jun 2009 09:55:53 -0400 |
parents | bb0697c70c16 |
children | 182b7088af1c |
files | src/ChangeLog src/oct-map.cc |
diffstat | 2 files changed, 28 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2009-06-23 John W. Eaton <jwe@octave.org> + + * oct-map.cc (Octave_map::squeeze, Octave_map::permute, + Octave_map::transpose, Octave_map::reshape, Octave_map::resize, + Octave_map::concat): Preserve key order. + 2009-06-23 Jaroslav Hajek <highegg@gmail.com> * pt-eval.cc (tree_evaluator::visit_try_catch_command): Simplify.
--- a/src/oct-map.cc +++ b/src/oct-map.cc @@ -64,6 +64,9 @@ retval.assign (key (pa), tmp); } + // Preserve order of keys. + retval.key_list = key_list; + return retval; } @@ -82,6 +85,9 @@ retval.assign (key (pa), tmp); } + // Preserve order of keys. + retval.key_list = key_list; + return retval; } @@ -153,6 +159,9 @@ for (const_iterator p = begin (); p != end (); p++) retval.assign (key(p), Cell (contents(p).transpose ())); + // Preserve order of keys. + retval.key_list = key_list; + return retval; } @@ -167,6 +176,9 @@ retval.assign (key(p), contents(p).reshape (new_dims)); retval.dimensions = new_dims; + + // Preserve order of keys. + retval.key_list = key_list; } else retval = *this; @@ -196,6 +208,9 @@ assign (key(p), tmp); } + + // Preserve order of keys. + retval.key_list = key_list; } } } @@ -220,6 +235,9 @@ retval.assign (key(pa), contents(pa).insert (rb.contents(pb), ra_idx)); } + + // Preserve order of keys. + retval.key_list = key_list; } else { @@ -436,10 +454,13 @@ Octave_map::index (const octave_value_list& idx, bool resize_ok) const { Octave_map retval; + octave_idx_type n_idx = idx.length (); + if (n_idx > 0) { Array<idx_vector> ra_idx (n_idx); + for (octave_idx_type i = 0; i < n_idx; i++) { ra_idx(i) = idx(i).index_vector (); @@ -451,8 +472,8 @@ { for (const_iterator p = begin (); p != end (); p++) { + Cell tmp = contents (p); - Cell tmp = contents (p); tmp = tmp.ArrayN<octave_value>::index (ra_idx, resize_ok); if (error_state)