Mercurial > hg > octave-lojdl
changeset 9624:3fc7272937ce
implement Array<T>::clear overloads
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sun, 06 Sep 2009 10:54:36 +0200 |
parents | bc0739d02724 |
children | cbabf50315ca |
files | liboctave/Array.cc liboctave/Array.h liboctave/ChangeLog |
diffstat | 3 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -88,6 +88,20 @@ } template <class T> +void +Array<T>::clear (const dim_vector& dv) +{ + if (--rep->count <= 0) + delete rep; + + rep = new ArrayRep (dv.numel ()); + slice_data = rep->data; + slice_len = rep->len; + + dimensions = dv; +} + +template <class T> Array<T> Array<T>::squeeze (void) const {
--- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -266,7 +266,14 @@ } void fill (const T& val); + void clear (void); + void clear (const dim_vector& dv); + void clear (octave_idx_type n) + { clear (dim_vector (n)); } + + void clear (octave_idx_type r, octave_idx_type c) + { clear (dim_vector (r, c)); } octave_idx_type capacity (void) const { return slice_len; } octave_idx_type length (void) const { return capacity (); }
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,10 @@ +2009-09-04 Jaroslav Hajek <highegg@gmail.com> + + * Array.cc (Array<T>::clear (const dim_vector&)): new method. + * Array.h: Declare it. + (Array<T>::clear (octave_idx_type)): New method. + (Array<T>::clear (octave_idx_type, octave_idx_type)): New method. + 2009-09-04 Jaroslav Hajek <highegg@gmail.com> * mx-inlines.cc (DEFMXBOOLOPEQ): New macro.