Boost logo

Boost Users :

Subject: Re: [Boost-users] accessing a pair<> element of multi_index container, uniquely ordered
From: Igor R (boost.lists_at_[hidden])
Date: 2010-02-25 07:11:27


> I have the following problem using a multi index container which is uniquely
> ordered  on a pair <int,int>.
> Each time i want to find every pair i that contains a specific integer. The
> other value of the pair is irrelevant.
>
> An example:
> <0,1>
> <0,2>
> <0,3>
> <1,2>
> <1,3>
> <2,3>
>
> and I want to find all the pairs with the value 0 as the first integer.

Make an additional index for the pair::first, then use equal_range()
for this index. Or change your existing index to be a composite index
with 2 fields (pair::first, pair::second), then you'll be able to use
equal_range() specifying the value of pair::first only.
http://www.boost.org/doc/libs/1_42_0/libs/multi_index/doc/tutorial/key_extraction.html#composite_keys


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