stl温习
map ?标准的关联式容器
? ? ? ? key是唯一的
? ? ?map 采用红黑树变体的平衡二叉树的数据结构, 因此插入和删除比vector快
? ? ?set采用红黑树
插入:
? 1:pair方式
? ? map.insert(pair<int, string>(2, ""));
? ? ? ? ? ? ? ? ? ? ? ?make_pair()
? 2:value_type
? ?map.insert(map<int,string>::value_type(1,""));
? 3:数组
? ?map[1]="tom"
? ?? 如果1不存在会先创建 然后会去修改
? ?? ?? string str = mapStud[2]; 如果2建值不存在则会返回初始化的新值
?
? ?insert方法返回值为pair<iterator, bool>?
? ?map里面是排序的,与set是一样的
?
删除?
? ? ? ?erase方法
查找
? ? ? ? ?find ?方法 ?返回迭代器
? ? ? ? ?低位匹配 高位匹配?
? ? ? ? ?lower_bound ?upper_bound ?equal_range
? ? ? ? ??
Multimap
? ?key是可以重复的多个相同key值
?
? ? ? ? ?
?
?
?
?
?
? ? ? ?
? ? ? ??
?
?
? ? ??