第三周

容器

字符串 std::string

string s = “abc”

  • substr

  • erase

  • find

  • vector
    vector vec(10,5)
    // int present the type of the element in vector

  • 2 d vector
    vector <vector> vec = {
    {…},
    {…},
    {…}
    }
    vector[]
    vector.at
    front
    back
    pop_back();
    push_back(int num);
    vec.erase(int index, int length);
    vec.insert()

  • map 有序map函数
    map<string,int> m{
    {“CPU”,10},{“GPU”,15},{“RAM”,20},
    }
    m[“CPU”] = 25; //赋值语句
    size
    earse
    empty

  • set 无序可重复
    count 出现多少次
    find 获取某个元素出现的位置(返回一个迭代器)

  • auto 类型简化书写(可以用来接迭代器

  • queue 队列 先进先出

  • stack 栈 先进后出

  • list 列表
    push_back()
    push_front()
    for(int n : l ){
    cout << n;
    }