C++ STL 速查

vector顺序容器
迭代器begin end rbegin rend cbegin cend crbegin crend
size()
empty()
operator[]
front()返回元素,不是迭代器
back()
push_back(v)无返回值
pop_back()无返回值
insert(pos,[ n,] v),(pos, first, last);返回首个插入的iter.
erase(pos),(first, last);返回删除的下一个iter.
string顺序容器
迭代器begin end rbegin rend cbegin cend crbegin crend
operator""s字面值,不转义,比如‘\0’不停止
size()
empty()
length()基本不用
operator[]
back()基本不用
front()基本不用
append([n, ]ch),(str[, idx[, n]]),(iter first, iter last),({})
push_back(ch)
pop_back
insert(idx, n, ch),(idx, *[, n]),(idx, str, str_idx[, n]),(pos[, n], ch),(pos, first, last)
erase(idx, n),(pos),(first, last)
replace(idx, n, str[, str_idx[, n]]),(first, last, str)
substr(idx, n=npos)返回子串
operator+= == != < > <= >= <=>
find(str, idx=0)从idx开始找str,返回首个idx
rfind(str, idx=npos)反向查找
find_first_of(str, idx=0[, n])从idx开始找str中任意一个字符,返回首个idx
find_first_not_of
find_last_of
find_last_not_of
(非成员函数)::
转整数stoi stol stoll stoul stoull
转浮点数stof stod stold
to_string(val)数转字符串
pairdoc
make_pair()make_pair(k1, k2);
map关联容器,哈希map
迭代器begin end rbegin rend cbegin cend crbegin crend
size()
empty()
operator[key]有就访问,没有就插入,value为相应类型的默认值
insert(pair<k, v>)返回pair<iter, bool>,iter指向pair<k, v>.
erase(iter pos),(iter first, iter last).
find(key)返回iter(没找到就是尾后迭代器)
count(key)
lower_bound(key)返回指向首个不小于 key 的元素的迭代器
upper_bound(key)返回指向首个大于 key 的元素的迭代器
equal_range(key)返回pair<lower_bound(key), upper_bound(key)>
set关联容器,集合
迭代器begin end rbegin rend cbegin cend crbegin crend
size()
empty()
insert(val)返回pair<iter, bool>,iter指向val
erase
find(key)
count(key)
lower_bound(key)
upper_bound(key)
equal_range(key)
stack容器适配器,栈
top()
empty()
size()
push(val)无返回值
pop()无返回值
queue容器适配器,队列
front()
back()
empty()
size()
push(val)无返回值
pop()无返回值
priority_queue容器适配器,最大堆
top()
empty()
size()
push(val)无返回值
pop()无返回值

在这里插入图片描述

funcdoc
【Non-modifying sequence operations】
for_eachApply function to range (function template)
findFind value in range (function template)
find_ifFind element in range (function template)
find_if_notFind element in range (negative condition) (function template)
find_endFind last subsequence in range (function template)
find_first_ofFind element from set in range (function template)
countCount appearances of value in range (function template)
count_ifReturn number of elements in range satisfying condition (function template)
equalTest whether the elements in two ranges are equal (function template)
copyCopy range of elements (function template)
copy_nCopy elements (function template)
copy_ifCopy certain elements of range (function template)
copy_backwardCopy range of elements backward (function template)
swapExchange values of two objects (function template)
swap_rangesExchange values of two ranges (function template)
replaceReplace value in range (function template)
replace_ifReplace values in range (function template)
replace_copyCopy range replacing value (function template)
replace_copy_ifCopy range replacing value (function template)
uniqueRemove consecutive duplicates in range (function template)
unique_copyCopy range removing duplicates (function template)
reverseReverse range (function template)
reverse_copyCopy range reversed (function template)
rotateRotate left the elements in range (function template)
rotate_copyCopy range rotated left (function template)
random_shuffleRandomly rearrange elements in range (function template)
shuffleRandomly rearrange elements in range using generator (function template)
Sorting::
sortSort elements in range (function template)
stable_sortSort elements preserving order of equivalents (function template)
partial_sortPartially sort elements in range (function template)
partial_sort_copyCopy and partially sort range (function template)
is_sortedCheck whether range is sorted (function template)
is_sorted_untilFind first unsorted element in range (function template)
nth_elementSort element in range (function template)
【Binary search (operating on partitioned/sorted ranges)】
lower_boundReturn iterator to lower bound (function template)
upper_boundReturn iterator to upper bound (function template)
equal_rangeGet subrange of equal elements (function template)
binary_searchTest if value exists in sorted sequence (function template)
【Min/max】
minReturn the smallest (function template)
maxReturn the largest (function template)
minmaxReturn smallest and largest elements (function template)
min_elementReturn smallest element in range (function template)
max_elementReturn largest element in range (function template)
minmax_elementReturn smallest and largest elements in range (function template)
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值