–vector , deque, list , array
–set, multiset
–map, multimap
–unordered set/ multiset
–unordered map/multimap
vector<int> vec(10,0) //创建容量为10的vector,并初始化为0 vector<int> vec = {1,4,8} vector<int> vec2(vec) //copy constructor, vec2: {1,4,8} vec.push_back(4); vec.pop_back(); //移除最后一个元素 vec.size(); //vector元素数量大小 vec.clear(); //清空 //vec.front(); //返回第一个元素 == vec[0] ------------------------------------------------------------------------ vec.erase(vec.begin()); //删除迭代器所指向的向量元素 vec.insert(vec.begin(),100); //把100插入到向量中迭代器所指的位置 ------------------------------------------------------------------------ for(vector<int>::iterator it = vec.begin(); it != vec.end(); it++) cout << *it <<endl; sort(vec.begin(),vec.end()); for(int i : vec) cout << i << endl;
deque<int> deq = {3,4,6}; deq.push_front(2); deq.push_back(9);
list<int> li = {1,2,3}; li.push_back(6); li.push_front(0);