Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi_index] sorted iteration of values
From: Mathieu Champlon (m.champlon_at_[hidden])
Date: 2013-09-04 03:41:50


On 04/09/2013 08:15, Joaquín Mª López Muñoz wrote:
>
> Use index #0:
>
> auto range = data.get< 0 >().equal_range( someTypePtr );
>

Ah yes, indeed, thank you !

> In fact, you can get rid of index #2: when using a composite key you
> can search by providing only the first m fields of the key, so for
> all practical purposes index #2 is redundant with #0.
>

With #2 I can erase by doing :

     units_.get< 2 >().erase( &publisher );

With #0 it seems I need to do :

     auto range = units_.equal_range( &publisher );
     units_.erase( range.first, range.second );

Or is there a shorter way ?

Also if my use case rarely uses #0 but uses #1 a lot (for instance #0 is
for adding/erasing while #1 is used to perform some operations very
often), would it be more efficient to invert the indices or is it just a
matter of whichever is the more convenient to write ?

Many thanks !
MAT.


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