[MultiIndex] Hinted insertion for multiple indices?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[MultiIndex] Hinted insertion for multiple indices?

Boost - Dev mailing list
Is there a way to provide insertion hints for multiple indices in a multi_index_container?

In a particular example, I have a container with several ordered_non_unique indices, and for the majority of insertions, the value will end up at the end of these indices.
I'm looking for a way to provide the index.end() hint for all of these indices? (Or maybe alternatively, to relax the stability/insertion-order guarantee?)

Thanks,
Gareth





_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [MultiIndex] Hinted insertion for multiple indices?

Boost - Dev mailing list
El 29/06/2018 a las 9:12, Gareth Sylvester-Bradley via Boost escribió:
> Is there a way to provide insertion hints for multiple indices in
> a multi_index_container?
>
> In a particular example, I have a container with several ordered_non_unique
> indices, and for the majority of insertions, the value will end up at the
> end of these indices.
>
> I'm looking for a way to provide the index.end() hint for all of these indices?
> (Or maybe alternatively, to relax the stability/insertion-order guarantee?)

Hi Gareth,

Just use hinted insertion like:

   m.insert(m.end(),x);

As it happens, the hint in hinted insertion is used for *all* indices,
so providing m.end()
does indeed indicate that insertion should happen as close as possible
to the end of
*each* index.

Is this what you're after? Best regards,

Joaquín M López Muñoz

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [MultiIndex] Hinted insertion for multiple indices?

Boost - Dev mailing list
At 02 July 2018 16:51, Joaquin M López Muñoz wrote:

> El 29/06/2018 a las 9:12, Gareth Sylvester-Bradley via Boost escribió:
> > Is there a way to provide insertion hints for multiple indices in
> > a multi_index_container?
> >
> > In a particular example, I have a container with several ordered_non_unique
> > indices, and for the majority of insertions, the value will end up at the
> > end of these indices.
> >
> > I'm looking for a way to provide the index.end() hint for all of these indices?
> > (Or maybe alternatively, to relax the stability/insertion-order guarantee?)
>
> Hi Gareth,
>
> Just use hinted insertion like:
>
>    m.insert(m.end(),x);
>
> As it happens, the hint in hinted insertion is used for *all* indices, so providing m.end()
> does indeed indicate that insertion should happen as close as possible to the end of
> *each* index.
>
> Is this what you're after? Best regards,
>
> Joaquín M López Muñoz

Thanks, Joaquín, that makes sense.

I suppose it means that it's not currently possible to optimise an insertion that you know would put the item at the end of one index and the beginning of another, or more generally to pass e.g. a tuple of index positions (unless they correspond to an existing item), but I don't need that right now, it's just the feature I  thought I was looking for!

Can I still get the bool flag that indicates whether insertion took place? I guess I can use pre/post size() otherwise...

Thanks,
Gareth



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [MultiIndex] Hinted insertion for multiple indices?

Boost - Dev mailing list
El 03/07/2018 a las 15:12, Gareth Sylvester-Bradley via Boost escribió:

> At 02 July 2018 16:51, Joaquin M López Muñoz wrote:
>> El 29/06/2018 a las 9:12, Gareth Sylvester-Bradley via Boost escribió:
>>> Is there a way to provide insertion hints for multiple indices in
>>> a multi_index_container?
>>>
>>> In a particular example, I have a container with several ordered_non_unique
>>> indices, and for the majority of insertions, the value will end up at the
>>> end of these indices.
>>>
>>> I'm looking for a way to provide the index.end() hint for all of these indices?
>>> (Or maybe alternatively, to relax the stability/insertion-order guarantee?)
>> Hi Gareth,
>>
>> Just use hinted insertion like:
>>
>>     m.insert(m.end(),x);
>>
>> [...]
> Thanks, Joaquín, that makes sense.
>
> I suppose it means that it's not currently possible to optimise an insertion
> that you know would put the item at the end of one index and the beginning
> of another, or more generally to pass e.g. a tuple of index positions (unless
> they correspond to an existing item), but I don't need that right now, it's
> just the feature I  thought I was looking for!

This feature is not available. I remember having thought about it back
when I initially wrote the
library, but dismissed it as potentially cumbersome interfacewise and
likely not too demanded.

> Can I still get the bool flag that indicates whether insertion took place?
> I guess I can use pre/post size() otherwise...

You've got to use pre/post size(). I'm just mimicking std::set's
interface here.

Joaquín M López Muñoz

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost