C++ boost多索引部分索引

C++ boost多索引部分索引,c++,boost,multi-index,C++,Boost,Multi Index,我想在boost内部实现两组具有相同搜索条件但不同逐出条件的多索引键。假设我有两组具有相同搜索条件的数据,但其中一组需要100个MRU(最近使用的)列表,另一组需要200个MRU。假设条目是这样的 class Student { int student_no; char sex; std::string address; }; typedef multi_index_container< Student, indexed_by< ord

我想在boost内部实现两组具有相同搜索条件但不同逐出条件的多索引键。假设我有两组具有相同搜索条件的数据,但其中一组需要100个MRU(最近使用的)列表,另一组需要200个MRU。假设条目是这样的

class Student
{
     int student_no;
     char sex;
     std::string address;
};
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 
搜索条件是student_no,但对于sex='m',我们需要200的MRU,对于sex='f',我们需要100的MRU。现在我有了一个解决方案,在这里我引入了一个新的有序索引来维护有序性

例如,IndexSpecifierList将是这样的

class Student
{
     int student_no;
     char sex;
     std::string address;
};
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 
typedef多索引容器<
大学生
索引<
有序的\u唯一,
有序\u唯一<复合\u键<
成员
成员>>
> 
>学生组
现在,每次我插入一个新的,我必须使用索引2为它取一个相等的_范围,并删除最旧的一个,如果有东西被重复使用,我必须通过增加计数器来更新它

这类问题有更好的解决办法吗

谢谢,
Gokul.

也可以使用sequenced代替第二个索引,并保持迭代器,该迭代器将阳性和阴性作为缓存的迭代器进行拆分。这对相同的行为也有帮助。

我在Boost ML中看到了您的消息,希望您能在这里或那里找到解决方案。有趣的问题+1