list支持在在容器中任意位置进行快速插入和删除。对于list来说,erase和push_back操作并不会使指向其他元素的迭代器失效,这一点与vector不同。
list不支持随机访问,因此无法使用标准库的sort函数来对存储在list上的元素排序,但可以用它的成员函数.sort来对它排序。
list<Student_info> students;
students.sort(compare);
在vector中使用通用的sort函数:
vector<Student_info> students;
sort(students.begin(),students.(end),compare);