如何依次到达地图的元素以使用其他地图?

时间:2019-12-30 18:21:55

标签: c++ dictionary insert

这是我的课程课程地图:

map<pair<string,int>,pair<string,Array> > matchMap;

在这张地图上,我得到的是课程名称,课程时间,天数和当天的可用时间。

这是我的Schedule类的另一幅地图:(Schedule类继承自课程和学生类):

map< string,map<string,pair<string,Array> > >  courseScList;

在此,我试图获取我在matchMap地图中输入的学生姓名,课程名称,课程日期,以及我在matchMap地图中输入的可用课程时间。

我写了这样的代码来完成这项工作:

    string c,s;
    list<string>::iterator studentLoc;
    map< string,map<string,pair<string,Array> > >::iterator last;
    map<pair<string,int>,pair<string,Array> >::iterator location;
    map< string,map<string,pair<string,Array> > >::iterator match;
    dummy1:
    cout<<"Enter the student name"<<endl;
    cin >> s;
    wrongCourse:
    cout<<"Enter the course names you want"<<endl;
    cin>>c;

    auto predicate = [&](auto& course) { return compareName(course, c); };
    studentLoc = find(getStudentList().begin(),getStudentList().end(),s);
    location = find_if(getMatchMap().begin(), getMatchMap().end(), predicate);
    if(studentLoc != getStudentList().end() || location != getMatchMap().end())
    {
        getCourseScList().insert(make_pair(s,{getMatchMap()[c],make_pair(getMatchMap().at(c))}));
    }

但是我不知道如何在此新地图中顺序到达matchMap数据。

getCourseScList().insert(make_pair(s,{getMatchMap()[c],make_pair(getMatchMap().at(c))}));

写课程名称时,如何组织代码以到达数据,matchMap地图的数据将插入CourseScList地图数据。

0 个答案:

没有答案
相关问题