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	Tue Jun 01 12:29:01 2010 +0200
+++ b/liboctave/Array.cc	Tue Jun 01 12:34:16 2010 +0200
@@ -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	Tue Jun 01 12:29:01 2010 +0200
+++ b/liboctave/Array.h	Tue Jun 01 12:34:16 2010 +0200
@@ -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	Tue Jun 01 12:29:01 2010 +0200
+++ b/liboctave/ChangeLog	Tue Jun 01 12:34:16 2010 +0200
@@ -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