Boost logo

Boost Users :

Subject: [Boost-users] [multi_index] modify~~
From: isjk (isjk_at_[hidden])
Date: 2010-08-02 03:44:42


hi,

now, I have two structures like this,

struct peer
{
     int guid_;
};
struct channel
{
    int md5_;
    peer* pr_;
    int prop_;
};
------------------------------------------
peer and channel is many to many.

using example6::key_from_key class;
------------------------------------------
typedef multi_index_container<
   peer,
   index_by<
      ordered_unique<
         BOOST_MULTI_INDEX_MEMBER(peer, int, guid_)
>
>
>peer_table;

typedef multi_index_container<
   channel,
   index_by<
      ordered_non_unique<
          BOOST_MULTI_INDEX_MEMBER(channel, int, md5_)
>
>
>channel_table;

typedef multi_index_container<
    const channel*,
    ordered_non_unique<
       key_from_key<
          BOOST_MULTI_INDEX_MEMBER(peer, const int, guid_),
          BOOST_MULTI_INDEX_MEMBER(channel, const peer*, pr_)
>
>
>channel_table_pr_view;

peer_table pt;
channel_table ct;

/// insert very much data....

nth_index<channel_table, 0>::type ic0,ic1;
boost::tie(ic0, ic1) = get<0>(ct).equal_range(md5_);
channel_table_pr_view ctpv;
while (ic0 != ic1)
{
    ctpv.insert(&*ic0);
    ++ic0;
}
channel_table_pr_view::iterator ictpv = ctpv.find(guid_);
if (ictpv != ctpv.end())
{
    ctpv.modify(ictpv, _Modify_prop()); // right or not?
}

struct _Modify_prop{
    void operator()(channel& cl_)
    {
         cl_.prop = rand();
    }
};

I want to modify channel' s prop.

thanks.

-- 
View this message in context: http://old.nabble.com/-multi_index--modify%7E%7E-tp29322711p29322711.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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