Boost logo

Boost :

Subject: Re: [boost] [cpo-proposal] presentation of the idea
From: Larry Evans (cppljevans_at_[hidden])
Date: 2013-08-19 10:30:57


On 08/19/13 09:06, Thorsten Ottosen wrote:
> On 19-08-2013 15:57, Larry Evans wrote:
>> On 08/19/13 08:44, Thorsten Ottosen wrote:
>
>>> Maybe we can avoid storing the linked list al together. Forward
>>> iteration would find the next element by asking the current element by
>>> its size and by computing i_aligned (somehow). Maybe that's the way
>>> to go.
>>>
>> OR, by having the container also contain a
>> std::vector<std::size_t> offsets;//offsets of values stored.
>> as well as:
>> std::vector<char> storage;//for storing values at offsets.
>>
>> This would trade space for time, but it would also allow random access.
>
> Yeah, random access indexing, probably not full random access iterators.
>
> Since the size of vector<T*> is no bigger than vector<size_t>, it's
> probably better just to allow forward iteration and then let the user
> create a vector<T*> as they want (for full random access manipulation).
>
> -Thorsten
>
However I assume you meant vector<T*> to contain pointers to elements
in the vector<char> storage of the container. But what happens if
storage needs to be resized? OTOH, using vector<std::size_t> to
store the offsets would not be invalidated by resizing storage.

-Larry


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk