c++ map 使用

. 包含头文件:

1 #include <map>

2. 构造函数:

1   std::map<char,int> first;
2   first['a']=10;
3   first['b']=30;
4   first['c']=50;
5   first['d']=70;
6   std::map<char,int> second (first.begin(),first.end());
7   std::map<char,int> third (second);

3. 添加元素:

4. 查找元素:

5. 删除元素:

6. member functions:

    map::at
    map::begin
    map::cbegin
    map::cend
    map::clear
    map::count
    map::crbegin
    map::crend
    map::emplace
    map::emplace_hint
    map::empty
    map::end
    map::equal_range
    map::erase
    map::find
    map::get_allocator
    map::insert
    map::key_comp
    map::lower_bound
    map::max_size
    map::operator=
    map::operator[]
    map::rbegin
    map::rend
    map::size
    map::swap
    map::upper_bound
    map::value_comp

原文地址:https://www.cnblogs.com/sarah-zhang/p/6254841.html