Mercurial > hg > octave-nkf
diff liboctave/Array.h @ 8524:937921654627
clean up Array and DiagArray2
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 15 Jan 2009 07:22:24 +0100 |
parents | ad3afaaa19c1 |
children | b01fef323c24 |
line wrap: on
line diff
--- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -97,50 +97,16 @@ public: - // !!! WARNING !!! -- these should be protected, not public. You - // should not access these methods directly! - - void make_unique (void) - { - if (rep->count > 1) - { - --rep->count; - rep = new ArrayRep (slice_data, slice_len, true); - slice_data = rep->data; - } - else if (slice_len != rep->len) - { - // Possibly economize here. - ArrayRep *new_rep = new ArrayRep (slice_data, slice_len, true); - delete rep; - rep = new_rep; - slice_data = rep->data; - } - } - - void make_unique (const T& val) - { - if (rep->count > 1) - { - --rep->count; - rep = new ArrayRep (slice_len, val); - slice_data = rep->data; - } - else - std::fill (slice_data, slice_data + slice_len, val); - } + void make_unique (void); typedef T element_type; - // !!! WARNING !!! -- these should be protected, not public. You - // should not access these data members directly! +protected: typename Array<T>::ArrayRep *rep; dim_vector dimensions; -protected: - T* slice_data; octave_idx_type slice_len; @@ -220,7 +186,7 @@ template <class U> Array (const Array<U>& a) : rep (new typename Array<T>::ArrayRep (coerce (a.data (), a.length ()), a.length ())), - dimensions (a.dimensions) + dimensions (a.dims ()) { slice_data = rep->data; slice_len = rep->len; @@ -260,7 +226,7 @@ Array<T>& operator = (const Array<T>& a); - void fill (const T& val) { make_unique (val); } + void fill (const T& val); octave_idx_type capacity (void) const { return slice_len; } octave_idx_type length (void) const { return capacity (); }