[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost-users
Subject:    Re: [Boost-users] bimap: one to many
From:       Joaquin_M_López_Muñoz_via_Boost-users <boost-users () lists ! b
Date:       2020-03-13 17:00:45
Message-ID: 98c01f76-d4c8-fdd2-672c-3ce126f67ad9 () gmail ! com
[Download RAW message or body]

El 12/03/2020 a las 21:53, MM via Boost-users escribió:
> Hello
> I want a collection to store a relationship N to M like so:
>
> Item of type A                 Item of type B
> A1                                    B1,B2,B3
> A2                                    B4
> A3                                    B1
>
> and I would like a convenient way to get from a A instance to the list 
> of B instances, and vice versa,
> from a given B instance to the list of A instances.
>
> At runtime, the A objects are created first, then a list of B objects 
> is created.
> Later, B objects get modified asynchronously and that modification 
> need to update the relevant
> A instances
>
> what container to use?
>
> boost::bimap< unordered_set<A*> , unordered_set<B*> >

As the relationship is N:M, you'll want something like

  boost::bimap< unordered_multiset_of<A*> , unordered_multiset_of<B*> >

Joaquín M López Muñoz

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic