|
Boost : |
Subject: Re: [boost] Associative container using a vector
From: Stefan Strasser (strasser_at_[hidden])
Date: 2013-03-31 13:48:38
>> struct A{
>> vector<Value> values;
>> vector<std::size_t> freelist;
>> map<Value,std::size_t> index;
>>
>> void erase(...){ push index of unused value to freelist; }
>> void push_back(Value){ reuse a freelist entry or
values.push_back; }
>> };
>> struct B{
>> vector<optional<Data> > data;
>> };
Am 31.03.2013 19:22, schrieb Michael Marcin:
>> template<class Value>
>> class index;
>>
>> template<class Mapped,class OptionalTraits=boost_optional_traits>
>> class vector_map;
>>
>> Is there anything like that?
>>
>
> Is this multi-index?
>
I don't think so. At least I can't find it.
You could implement my "struct A" above using Boost.MultiIndex as it
uses a vector and a map, but I can't find a map implementation that uses
a vector with empty values for almost-contiguous keys.
keep in mind the one-to-many relationship between A and B. I'd like to
be able to do ONE map lookup to receive a key with which you can access
many associated data values in B objects.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk