Boost logo

Boost Users :

From: Robert Kubrick (robertkubrick_at_[hidden])
Date: 2008-08-17 12:01:27


On Aug 17, 2008, at 5:15 AM, Ion Gaztañaga wrote:

> Robert Kubrick wrote:
>> A couple of beginner questions on basic_managed_heap_memory:
>> 1) I want to access elements in the contiguous memory segment by
>> using an int key, rather than a char string. Can I declare
>> something like this:
>> typedef basic_managed_heap_memory < int, /* my key is an
>> integer */ rbtree_best_fit<null_mutex_family>,
>> flat_map_index
>> > managed_heap_memory;
>> I need to lookup objects using an external integer ID but the ID
>> can have any value (ie, does not match the 0-N array element order
>> of my memory segment).
>
> No sorry, named allocation is only availables for chars. One
> workaround thing you can do is to allocate anonymous objects in the
> managed segment and create another map-like structure pointing to
> those anonymous objects. More inefficient, I know, but I can't
> think another way. Anyway, I think you've shown me a good use case
> to study the possibility of using non-char indexes (something I
> suspect will require a lot of work, because all the code supposes
> string keys).
>
>> 2) If I want to insert multiple objects with the same char* name
>> (ala multimap) can I create a flat_multimap_index?
>
> You can't. Names must be unique because it should identify a unique
> named object. Otherwise, we wouldn't be capable to find an object
> correctly.

A subset of objects could have the same name, but each object would
be assigned to a unique slot in the segment. A multimap search on the
non-unique name would return an equal_range object.

>
> Regards,
>
> Ion
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net