1
我想實現內部提升多索引兩組具有相同的搜索條件,但不同的驅逐標準的關鍵。說我有兩套與相同的搜索條件的數據,但一組需要的100 MRU(最近使用)列表,而另一組需要MRU的200說的條目是這樣boost multi_index部分索引
class Student
{
int student_no;
char sex;
std::string address;
};
的搜索標準是student_no,但對於性別='m',我們需要200的MRU和性別='f',我們需要MRU爲100.現在我有一個解決方案,在這裏我引入一個新的有序索引來維持排序。
例如,IndexSpecifierList會是這樣的
typedef multi_index_container<
Student,
indexed_by<
ordered_unique< member<Student, int, &Student::student_no> >,
ordered_unique< composite_key<
member<Student, char, &Student::sex>,
member<Student, int, &Student::sex_specific_student_counter> > >
>
> student_set
現在每次,我插入一個新的,我必須承擔,使用指數2 equal_range並刪除最老的一個,如果事情是重新使用,我必須通過遞增計數器來更新它。
有沒有更好的解決這類問題的方法?
謝謝, Gokul。
我在Boost ML看到了您的消息,希望您能在這裏或那裏找到解決方案。有趣的問題+1 – AraK 2010-12-21 20:54:16