1.顺序容器-deque
2.顺序容器-forward_list
3.顺序容器-list
4.迭代器
5.关联容器 map
6.联容器 set
#include <iostream>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <set>
using namespace std;
int main() {
deque<int> de;
de.push_back(10);
de.push_back(20);
de.push_back(30);
de.push_front(40);
auto postion = de.begin() + 2;
de.insert(postion,41);
cout << de[0] << endl;
cout << de[1] << endl;
cout << "second="<< *de.begin()+1 << endl;
cout << "first value="<< de.front() << endl;
cout << "end value="<< de.back() << endl;
cout << de.at(1) << endl;
cout << "de长度"<< de.size() << endl;
de[0] = 400;
cout << de[0] << endl;
for (int i = 0; i < de.size(); ++i) {
cout << de[i] << endl;
}
de.pop_back();
cout << de.size() << endl;
forward_list<int> fl;
fl.push_front(11);
fl.push_front(21);
fl.insert_after(fl.begin(),31);
for (auto f = fl.begin();f != fl.end();f++) {
cout << *f <<endl;
}
fl.remove(11);
list<int> li;
li.push_front(12);
li.push_back(22);
li.insert(li.end(),32);
cout << li.front()<< endl;
cout << li.back()<< endl;
cout << "size="<< li.size() <<endl;
*li.begin() = 322;
for (auto l = li.begin();l !=li.end();l++) {
cout << *l<< endl;
}
li.remove(322);
vector<int> vi{13,23,33,43,53};
cout << *vi.begin() << endl;
cout << *(vi.begin() + 1)<< endl;
for(auto v = vi.begin();v != vi.end();v++){
cout << *v << endl;
}
map<string,int> mp;
mp.insert({"egg",10});
mp.insert(make_pair("banana",20));
mp.insert(pair<string,int>("orange",12));
mp.insert({"egg",15});
cout << mp["banana"] << endl;
cout <<mp.at("egg") << endl;
mp["orange"] = 122;
cout << mp["orange"] << endl;
mp.clear();
cout << mp.size() << endl;
set<int> st{1,2,3,4,5};
st.insert(6);
st.insert({7,8});
st.empty();
st.size();
int cout1 = st.count(8);
for(auto ss = st.begin();ss !=st.end();ss++ ){
cout << *ss << endl;
}
st.erase(8);
st.clear();
return 0;
}