|
Ublas : |
From: Neal Becker (ndbecker2_at_[hidden])
Date: 2007-04-11 11:49:15
Gunter Winkler wrote:
> Am Montag, 9. April 2007 14:55 schrieb Neal Becker:
>
>> Sorry, I'm not sure what you mean. Do you mean that this only fixes
>> vector<unbounded_array> and not other dense vector<storage...> ?
>
> This fix applies of course for all storage types.
>
>> I know, also matrix is not addressed. My intention was to find out
>> if we have some agreement that this is the preferred approach. If
>> there is some agreement, I'll try to provide a more complete patch.
>
> We should update the container concept and the storage concept.
>
> *From storage concept*
>
> Resize 1: a.resize(n, t)
>
> The container may be reallocated if its size changes. Existing element
> values are preserved, additional elements are copies of t.
>
> Resize 2: a.resize(n)
>
> The container may be reallocated if its size changes. Element values are
> uninitialized. That is, each element value may be a previously assigned
> value or default constructed value for T.
>
> *From container concept*
>
> Resize: v.resize (n[, p]);
>
> Erases or appends elements in order to bring the vector to the
> prescribed size. Appended elements copies of value_type(). When p ==
> false then existing elements are not preserved and elements will not
> appended as normal. Instead the vector is in the same state as that
> after an equivalent sizing constructor.
>
>
> *thoughts*
>
> Before we update the code we should agree for a common concept.
>
> About storage classes - We already have additionally to resize 1 and 2:
>
> void resize_internal (const size_type size, const value_type init, const
> bool preserve);
>
> So we could modify the resize-concept to be:
>
> resize(n[, preserve = false[, init = false[, value = T()]]]);
>
> The container may be reallocated if its size changes. The values of old
> elements are preserved if <code>preserve</code> is true. New elements
> are initialized with <code>value</code> if <code>init</code> is true.
> If <code>init</code> is false then new values are default constructed
> unless <code>detail::has_trivial_constructor<T>::value</code> is
> true.
>
> <code>resize(n,t)</code> is the short form of
> <code>resize(n,true,true,t);</code>
>
>
> What do you think?
>
Actually, the proposed resize is just what I had in mind. But,
resize_internal doesn't support it. resize has 4 orthogonal args, but
resize_internal has 3 args (and they're not orthogonal. Notice the role of
preserve in resize_internal). I don't see how to map the 3rd and 4th arg
of resize into the current resize_internal.