Mercurial > hg > octave-terminal
changeset 10674:e3064439d6b4
new Array method for internal use
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 01 Jun 2010 12:34:16 +0200 |
parents | b17a966099ed |
children | e5b1353695ef |
files | liboctave/Array.cc liboctave/Array.h liboctave/ChangeLog |
diffstat | 3 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -2571,6 +2571,16 @@ } template <class T> +bool Array<T>::optimize_dimensions (const dim_vector& dv) +{ + bool retval = dimensions == dv; + if (retval) + dimensions = dv; + + return retval; +} + +template <class T> void Array<T>::instantiation_guard () { // This guards against accidental implicit instantiations.
--- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -622,6 +622,11 @@ template <class U> friend class Array; + // Returns true if this->dims () == dv, and if so, replaces this->dimensions + // by a shallow copy of dv. This is useful for maintaining several arrays with + // supposedly equal dimensions (e.g. structs in the interpreter). + bool optimize_dimensions (const dim_vector& dv); + private: static void instantiation_guard (); };
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2010-06-01 Jaroslav Hajek <highegg@gmail.com> + + * Array.cc (Array<T>::optimize_dimensions): New method. + * Array.h: Declare it. + 2010-06-01 Jaroslav Hajek <highegg@gmail.com> * Array.cc (Array<T>::maybe_delete_dims): Remove method (makes no