Boost logo

Glas :

Re: [glas] dense and sparse vectors

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2005-08-14 15:38:51

Theodore Papadopoulo wrote:

> Here is a very crude implementation of what I was thinking (just for nz
> iterators and only for structured_vector).

I just had a look at your patch and here's my feedback on it:

> - Expandable iterators (create your iterator, your tag and this is it...
> at least if the container class provides enought information for you
> to implement your iterator).

Indeed it is ... but note more exandable as having a 'template <class T>
begin()' member-function. Actually finally the nz_iterator is calling
this member-function. So IIUC the added-value of your approach is the
automatic conversion from the return-value of the 'begin()' member to
the desired iterator-type. This is indeed nice but also has the drawback
of increasing the call-overhead.

> Can be used with the std stuff (sorting elements, finding elements,
> for_each,....). Well, if the iterators obey the std rules (which is
> not yet the case with this sample code).

But one can't call std::sort(v.begin(),v.end())' for instance because
the sort function is passed two struct's in that case ?

> Let me know what you think of this idea... if it seems OK, then I'll try
> to adapt more containers/iterators and eventually reorganise some of the
> code).

You inspired the idea of having 'begin(nz)' and 'begin(all)'. Again IIUC
 your solution is build on top of this. However I'm not convinced yet
that the difference in notation (due to the implicit conversion) is
worth the additional overhead.