# HG changeset patch # User David Bateman # Date 1208381616 -7200 # Node ID ccab9d3d1d210cd286e0e2b08613a6bbf5b5ac1f # Parent a7a4090cf532f4a43cd1278024c7c5356386614a Delete idx in Sparse and Array operator = diff -r a7a4090cf532 -r ccab9d3d1d21 liboctave/Array.cc --- a/liboctave/Array.cc Wed Apr 16 15:15:26 2008 -0400 +++ b/liboctave/Array.cc Wed Apr 16 23:33:36 2008 +0200 @@ -64,6 +64,28 @@ } template +Array& +Array::operator = (const Array& 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 Array Array::squeeze (void) const { diff -r a7a4090cf532 -r ccab9d3d1d21 liboctave/Array.h --- a/liboctave/Array.h Wed Apr 16 15:15:26 2008 -0400 +++ b/liboctave/Array.h Wed Apr 16 23:33:36 2008 +0200 @@ -228,24 +228,7 @@ virtual ~Array (void); - Array& operator = (const Array& 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& operator = (const Array& a); void fill (const T& val) { make_unique (val); } diff -r a7a4090cf532 -r ccab9d3d1d21 liboctave/ChangeLog --- a/liboctave/ChangeLog Wed Apr 16 15:15:26 2008 -0400 +++ b/liboctave/ChangeLog Wed Apr 16 23:33:36 2008 +0200 @@ -1,3 +1,14 @@ +2008-04-16 David Bateman + + * Sparse.h (Sparse& operator = (Sparse&)): Move definition + of the operator for here + * Sparse.cc (Sparse& Sparse::operator = (Sparse&)): To + here. Also delete idx. + * Array.h (Array& operator = (Array&)): Move definition + of the operator for here + * Array.cc (Array& Array::operator = (Array&)): To + here. Also delete idx. + 2008-04-09 Michael Goffioul * lo-mappers.cc (xround): Avoid floating-point overflow when input diff -r a7a4090cf532 -r ccab9d3d1d21 liboctave/Sparse.cc --- a/liboctave/Sparse.cc Wed Apr 16 15:15:26 2008 -0400 +++ b/liboctave/Sparse.cc Wed Apr 16 23:33:36 2008 +0200 @@ -615,6 +615,28 @@ } template +Sparse& +Sparse::operator = (const Sparse& 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 octave_idx_type Sparse::compute_index (const Array& ra_idx) const { diff -r a7a4090cf532 -r ccab9d3d1d21 liboctave/Sparse.h --- a/liboctave/Sparse.h Wed Apr 16 15:15:26 2008 -0400 +++ b/liboctave/Sparse.h Wed Apr 16 23:33:36 2008 +0200 @@ -220,24 +220,7 @@ virtual ~Sparse (void); - Sparse& operator = (const Sparse& 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& operator = (const Sparse& a); // Note that nzmax and capacity are the amount of storage for // non-zero elements, while nnz is the actual number of non-zero