2010-03-15 20 views
4

supposons que nous avons un data1 et data2. Comment puis-je les croiser avec std::set_intersect()?Boost.MultiIndex: Comment créer une intersection efficace?

struct pID 
{ 
    int   ID; 
    unsigned int IDf;// postition in the file 
    pID(int id,const unsigned int idf):ID(id),IDf(idf){} 
    bool operator<(const pID& p)const { return ID<p.ID;} 
}; 

struct ID{}; 
struct IDf{}; 

typedef multi_index_container< 
    pID, 
    indexed_by< 
    ordered_unique< 
    tag<IDf>, BOOST_MULTI_INDEX_MEMBER(pID,unsigned int,IDf)>, 
    ordered_non_unique< 
    tag<ID>,BOOST_MULTI_INDEX_MEMBER(pID,int,ID)> > 
    > pID_set; 

ID_set data1, data2; 
Load(data1); Load(data2); 

pID_set::index<ID>::type& L1_ID_index=L1.data.get<ID>(); 
pID_set::index<ID>::type& L2_ID_index=L2.data.get<ID>(); 
    // How do I use set_intersect? 

Répondre

5
std::set_intersection(
    L1_ID_index.begin(),L1_ID_index.end(), 
    L2_ID_index.begin(),L2_ID_index.end(), 
    output_iterator, 
    L1_ID_index.value_comp()); 
+0

Merci, Ce "L1_ID_index.value_comp()" ce que je manque. – Arman

+0

Je suppose qu'il devrait savoir depuis qu'il a écrit la bibliothèque! – shaz