Mercurial > hg > octave-avbm
changeset 7717:ff918ee1a983
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 | 9c15f385811c |
children | 62279ce5654c |
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 @@ -63,6 +63,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 @@ -230,24 +230,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 @@ -222,24 +222,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