changeset 11755:ccab9d3d1d21 release-3-0-x

Delete idx in Sparse<T> and Array<T> operator =
author David Bateman <dbateman@free.fr>
date Wed, 16 Apr 2008 23:33:36 +0200
parents a7a4090cf532
children d68fc0ca4ece
files liboctave/Array.cc liboctave/Array.h liboctave/ChangeLog liboctave/Sparse.cc liboctave/Sparse.h
diffstat 5 files changed, 57 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/Array.cc
+++ b/liboctave/Array.cc
@@ -64,6 +64,28 @@
 }
 
 template <class T>
+Array<T>&
+Array<T>::operator = (const Array<T>& a)
+{
+  if (this != &a)
+    {
+      if (--rep->count <= 0)
+	delete rep;
+
+      rep = a.rep;
+      rep->count++;
+
+      dimensions = a.dimensions;
+
+      delete [] idx;
+      idx_count = 0;
+      idx = 0;
+    }
+
+  return *this;
+}
+
+template <class T>
 Array<T>
 Array<T>::squeeze (void) const
 {
--- a/liboctave/Array.h
+++ b/liboctave/Array.h
@@ -228,24 +228,7 @@
 
   virtual ~Array (void);
 
-  Array<T>& operator = (const Array<T>& a)
-    {
-      if (this != &a)
-	{
-	  if (--rep->count <= 0)
-	    delete rep;
-
-	  rep = a.rep;
-	  rep->count++;
-
-	  dimensions = a.dimensions;
-
-	  idx_count = 0;
-	  idx = 0;
-	}
-
-      return *this;
-    }
+  Array<T>& operator = (const Array<T>& a);
 
   void fill (const T& val) { make_unique (val); }
 
--- a/liboctave/ChangeLog
+++ b/liboctave/ChangeLog
@@ -1,3 +1,14 @@
+2008-04-16  David Bateman  <dbateman@free.fr>
+
+	* Sparse.h (Sparse<T>& operator = (Sparse<T>&)): Move definition
+	of the operator for here
+	* Sparse.cc (Sparse<T>& Sparse<T>::operator = (Sparse<T>&)): To
+	here. Also delete idx.
+	* Array.h (Array<T>& operator = (Array<T>&)): Move definition
+	of the operator for here
+	* Array.cc (Array<T>& Array<T>::operator = (Array<T>&)): To
+	here. Also delete idx.
+
 2008-04-09  Michael Goffioul  <michael.goffioul@gmail.com>
 
 	* lo-mappers.cc (xround): Avoid floating-point overflow when input
--- a/liboctave/Sparse.cc
+++ b/liboctave/Sparse.cc
@@ -615,6 +615,28 @@
 }
 
 template <class T>
+Sparse<T>&
+Sparse<T>::operator = (const Sparse<T>& a)
+{
+  if (this != &a)
+    {
+      if (--rep->count <= 0)
+	delete rep;
+
+      rep = a.rep;
+      rep->count++;
+
+      dimensions = a.dimensions;
+
+      delete [] idx;
+      idx_count = 0;
+      idx = 0;
+    }
+
+  return *this;
+}
+
+template <class T>
 octave_idx_type
 Sparse<T>::compute_index (const Array<octave_idx_type>& ra_idx) const
 {
--- a/liboctave/Sparse.h
+++ b/liboctave/Sparse.h
@@ -220,24 +220,7 @@
 
   virtual ~Sparse (void);
 
-  Sparse<T>& operator = (const Sparse<T>& a)
-    {
-      if (this != &a)
-	{
-	  if (--rep->count <= 0)
-	    delete rep;
-
-	  rep = a.rep;
-	  rep->count++;
-
-	  dimensions = a.dimensions;
-	}
-
-      idx_count = 0;
-      idx = 0;
-
-      return *this;
-    }
+  Sparse<T>& operator = (const Sparse<T>& a);
 
   // Note that nzmax and capacity are the amount of storage for
   // non-zero elements, while nnz is the actual number of non-zero