I want use "model, name" to query "price", and I maybe to modify "price".
------------------ 原始邮件 ------------------
发送时间: 2010年7月22日(星期四) 凌晨2:08
收件人: "boost-users"<boost-users@lists.boost.org>;
主题: Re: [Boost-users] Multi_indexcomposite_key~~
isjk <isjk <at> foxmail.com> writes:
>
> hi all,
>
> now,I have a composite_key like this,
> struct leader_key
> boost::multi_index::composite_key<
> channel_info,
> BOOST_MULTI_INDEX_MEMBER(channel_info, boost::uint64_t, st_md5_),
> BOOST_MULTI_INDEX_MEMBER(channel_info, boost::uint32_t, st_rank_),
> BOOST_MULTI_INDEX_MEMBER(channel_info, boost::uint8_t, st_degrees_),
> BOOST_MULTI_INDEX_MEMBER(
> channel_info, boost::uint8_t, st_lan_type_)
> >{};
>
> I used "md5, rank, degrees, lan_type" to query.
> I want to the result like this,
> equal to md5,
> less than rank
> degrees from small to large
> equal to lan_type
You can't do this by issuing a single lookup operation.
A composite key on keys k1,...,kn allows you to do lookup
operations of the form
k1==a1, ... , kj==aj, kj+1==aj+1
k1==a1, ... , kj==aj, kj+1< aj+1
k1==a1, ... , kj==aj, kj+1<=aj+1
k1==a1, ... , kj==aj, kj+1> aj+1
k1==a1, ... , kj==aj, kj+1>=aj+1
For any j in the range [1,n], that is, you can query for the
exact value of the first j keys and add any type of inequality
for the last key being queried.
In your particular case you can rearrange the key extractors
of your composite key in the following order
md5,lan_type,rank,degress
then use lower_bound with elements
equal to md5
equal to lan_type
less than rank
(note you've had to rearrange the extractors in leader_key to
be able to do this) which gives you some result "it", and
finally manually traverse the range [begin,it) to obtain
those elements with degrees from small to large.
Hope this helps,
Joaquín M López Muoz
Telefónica, Investigación y Desarrollo
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users