Re: [glas] return type of operator(size_type) for sparse vectors?
From: Russell Smiley (smiley_at_[hidden])
Date: 2006-04-26 15:11:21
I think I prefer option 3 (proxy that modifies a structural zero if
necessary). Presumably there is some penalty for this more sophisticated
If "proxy_type operator" is not provided how would structural zeroes
normally be modified?
> -----Original Message-----
> Subject: [glas] return type of operator(size_type) for
> sparse vectors?
> Given a sparse vector v of size 10, what would v return? Should it
> return a reference to the element at position 0 in the sparse vector.
> What if that element is a structural-zero? It clearly is not as
> straightforward as with dense vectors.
> The options AFAICT are:
> 1) provide no 'operator(size_type)' to avoid confusion
> 2) return the value at the corresponding position or if the position
> corresponds to a structural-zero return zero. Thus in that case
> operator will not affect/change the structure and
> operator will not
> allow to change the value at the corresponding position.
> 3) return a proxy. If the proxy is being assigned to, the
> structure will
> be changed in case the position corresponded with a structural-zero.