常用STL
标准库:
1.栈
top()//取栈顶元素 push()//压入元素 emplace()//压入元素至栈顶 s1.swap(s2)//交换两个栈 size()//栈中元素个数 empty()//判空 pop()//弹出栈顶元素 =,!=,==,>,<,>=,<=
2.队列
front()//队首元素 back()//队尾元素 empty()//判空 pop()//弹出队首元素 push()//插入元素至队尾 size()//队列中元素个数 emplace()//插入元素至队尾 q1.swap(q2)//交换两个队列 =,!=,==,>,<,>=,<=
3.优先队列
empty()//判空 size()//元素个数 top()//队首元素 push()//插入元素 emplace()//插入元素 pop()//取队首元素 q1.swap(q2)//交换两个优先队列 =,!=,==,>,<,>=,<=
4.对
p1.swap(p2)//交换两个对 first//第一个元素 second//第二个元素 ={a,b}//赋值
5.组元
t1.swap(t2)//交换两个组元 tie(a,b,c...)=t//创建左值引用tuple get<p>(t)//返回t中下标为p的元素 =,!=,==,>,<,>=,<=
6.双端队列
deque<T>q(n,val)//n个val deque<T>q(n)//初始大小为n q={a,b,c...}//初始化 q[]//指定访问位置 at()//指定访问位置 begin()//开头迭代器 end()//末尾迭代器 rbegin() rend() cegin() cend() crbegin() crend() size() max_size() resize()//修改尺寸,少的0补 empty() shrink_to_fit()//缩小以适应大小 front() back() assign(n,val)//重置为n个val assign(begin(),end())//重置 push_back() push_front() pop_back() pop_front() insert(it,val)//it之后插入val insert(it,n,val)//it之后出入n个val insert(it,begin(),end()) erase(it) erase(begin(),end()) q1.swap(q2) clear() emplace(it,val)//it之后构造并插入val emplace_front() emplace_back() =,!=,==,>,<,>=,<=
7.位集
s=x//自动将x转为二进制 bitset<size>s(a)//string a此时仅可以是01串 bitset<size>s("1001") count()//1的个数 size() test(pos)//测试是否为1 any()//存在1 none()//全为0 all()//全为1 set()//初始化为全1 set(pos)//pos赋为1 set(pos,0/1)//pos赋为0/1 reset()//清零 reset(pos)//pos清零 flip()//整体异或1 flip(pos)//pos异或1 string a=s.to_string()//将s转为字符串a unsigned int a=s.to_ulong()//将s转换为a unsigned long long a=s.to_ullong()//将s转换为a []//从右向左 &,|,^,~,<<,== ,!=
8.数组
array<T,size>a begin() end() rbegin() rend() cbegin() cend() crbegin() crend() size() max_size() empty() front() back() data()//返回第一个元素的指针 fill(x)//重置全为x a1.swap(a2) [] =,!=,==,>,<,>=,<=
9.矢量
vector<T>v(size) vector<T>v={a,b,c...} vector<T>v(n,v)//初始化n个v vector<T>v(begin(),end()) vector<T>v(v1) vector<T>v=v1 v=vector<T>()//将v清零 begin() end() rbegin() rend() cbegin() cend() crbegin() crend() size() max_size() resize()//修改大小 empty() capacity()//容量 reserve()//申请修改容量 shrink_to_fit() at() front() back() data()//返回首指针 assign(n,val)//重置为n个val assign(begin(),end()) push_back() pop_back() insert(it,val)//it之前插入val insert(it,begin(),end()) erase(it) erase(begin(),end()) v1.swap(v2) clear() emplace(it,val)//it之前构造并插入val emplace_back() filp()//此时v应为bool [] =,!=,==,>,<,>=,<=
10.权值数组
valarray<T>v valarray<T>v(size) valarray<T>v(n,val)//n个val valarray<T>v(begin(),size) valarray<T>v(v1) valarray<T>v(v1[slice(a,b,c)]) v[slice(a,b,c)]//从v[a]开始,以c为间隔,截取总长为b的切片 v=v1.apply(函数指针)//将v1进行函数运算后返回给v v=v1.cshift(cnt)//将v1向左循环移动cnt次返回给v max() min() v=T//将v初始化全为T resize(n)//清零并修改大小为n v=v1.shift(cnt)//将v1向左移动cnt次后返回给v,非循环移动 size() sum() v1.swap(v2) it=begin(v) it=end(v) 运算符=(const valarray& rhs) 运算符=(const T& val) valarray<bool>cmp=(v逻辑运算符v1) valarray<bool>cmp=(v逻辑运算符T) valarray<bool>cmp=(T逻辑运算符v) valarray<T>ans=(v运算符v1) valarray<T>ans=(v运算符T) valarray<T>ans=(T运算符v) +,-,*,/,%,~,!,&&,||,<<,>>,+=,-=,*=,/=,%=,^=,&=,|=,<<=,>>=,=,!=,==,>,<,>=,<=
11.单向链表
forward_list<T>f forward_list<T>f(n,val)//n个val forward_list<T>f(begin(),end()) forward_list<T>f(f1) forward_list<T>f(move(f1)) forward_list<T>f={a,b,c...} before_begin() begin() end() cbefore_begin() cbegin() cend() empty() max_size() front() assign(n,val)//初始化为n个val assign(begin(),end()) assign({a,b,c...}) emplace_front() push_front() pop_front() emplace_after(it,T) insert_after(it,val)//it之后插入val insert_after(it,n,val)//it之后插入n个val insert_after(it,begin(),end()) insert_after(it,{a,b,c...}) erase_after(it) erase_after(begin(),end()) f1.swap(f2) resize(n)//修改大小为n,多则舍,少补0 resize(n,val)//修改大小为n,多则舍,少补val clear() splice_after(it,f1)//it之后插入f1 splice_after(it,f1,it1)//it之后插入f1中it1之后的一个元素 splice_after(it,f1,begin(),end()) remove(x)//删除所有x remove_if(函数指针)//删除所有满足函数的值 unique(函数指针)//删除满足函数的值 unique()//去重 merge(f1)//合并排好序f与f1,合并后依然有序 merge(f1,cmp)//按cmp合并f与f1 sort() sort(cmp) reverse()//翻转 =,!=,==,>,<,>=,<=
12.双向链表
list<T>l list<T>l(n,val)//初始化n个val list<T>l(begin(),end()) list<T>l(l1) l=l1 l=list<T>() begin() end() rbegin() rend() cbegin() cend() crbegin() crend() empty() size() max_size() front() back() assign(n,val)//初始化为n个val assign(begin(),end()) emplace_front() push_front() pop_front() emplace_back() push_back() pop_back() emplcae(it,T)//在it之前插入T insert(it,T)//在it之前插入T insert(it,n,T)//在it之前插入n个T insert(it,begin(),end()) erase(it) erase(begin(),end()) l1.swap(l2) resize(n)//修改大小为n,多则舍,少则补0 resize(n,val)//修改大小为n,多则舍,少则补val clear() splice(it,l1)//it之前插入l1 splice(it,l1,it1)//it之前插入l1的it1 splice(it,l1,begin(),end()) remove(x)//删除所有x remove_if(函数指针)//删除满足函数的值 unique()//去重 unique(函数指针)//去掉满足函数的值 merge(l1)//合并排好序的l与l1 merge(l1,cmp)//按cmp合并l与l1 sort() sort(cmp) reverse() =,!=,==,>,<,>=,<=
13.集合
set<T>s set<T>s(begin(),end()) set<T>s(s1) set<T,classcmp>s bool(*p)(T,T)=函数指针 set<T,bool(*)(T,T)>s(函数指针) s=set<T>() s={a,b,c...} begin() end() rbegin() rend() cbegin() cend() crbegin() crend() empty() size() max_size() insert(x)//插入x insert(it,x)//若知道x的位置则插入效率更高 insert({a,b,c...}) insert(begin(),end()) erase(it) erase(val) erase(begin(),end()) s1.swap(s2) clear() emplace(x)//插入x emplace_hint(it,x)//在it插入x key_comp()//返回自身比较函数 value_comp()//返回自身比较函数 find(x)//返回x的it count(x)//返回x的个数 lower_bound() upper_bound() equal_range(x)//返回pair(lower_bound(x),upper_boundd(x)) =,!=,==,>,<,>=,<=
14.多重集合
multiset<T>s multiset<T>s(begin(),end()) multiset<T>s(s1) multiset<T,classcmp>s bool(p)(T,T)=函数指针 set<T,bool()(T,T)>s(函数指针) s=multiset<T>() s={a,b,c...}; begin() end() rbegin() rend() cbegin() cend() crbegin() crend() empty() size() max_size() insert(x)//插入x insert(it,x)//若知道x的位置则插入效率更高 insert({a,b,c...}) insert(begin(),end()) erase(it) erase(val)//删除所有val erase(begin(),end()) s1.swap(s2) clear() emplace(x)//插入x emplace_hint(it,x)//在it插入x key_comp()//返回自身比较函数 value_comp()//返回自身比较函数 find(x)//返回x的it count(x)//返回x的个数 lower_bound() upper_bound() equal_range(x)//返回pair(lower_bound(x),upper_boundd(x)) =,!=,==,>,<,>=,<=
15.无序集合
unordered_set<T>s unordered_set<T>s(begin(),end()) unordered_set<T>s(s1) unordered_set<T>s({a,b,c...}) s=unordered_set<T>() s={a,b,c...} s=s1 begin() end() cbegin() cend() empty() size() max_size() insert(x)//插入x insert(it,x)//若知道x的位置则插入效率更高 insert({a,b,c...}) insert(begin(),end()) erase(it) erase(val) erase(begin(),end()) s1.swap(s2) clear() emplace(x)//插入x emplace_hint(it,x)//在it插入x key_comp()//返回自身比较函数 value_comp()//返回自身比较函数 bucket_count()//按键值分配的桶数 //s.begin(i),s.end(i)为该桶内的值(i=0->bucket_conut-1) max_bucket_count() bucket_size(x)//桶x含有的数量 bucket(x)//x所在的bucket find(x)//返回x的it count(x)//返回x的个数 equal_range(x)//返回pair(lower_bound(x),upper_boundd(x)) load_factor()//返回size/bucket_count max_load_factor()//返回最大load_factor max_load_factor(x)//将最大load_factor设置为x rehash(n)//修改hash表最小存储桶数为n reserve(n)//存储桶数修改为最适合至少包含n个元素的桶数 hash_function()(x)//返回x的hash值 key_eq()(x,y)//返回x与y是否被认为是相同的 =,!=,==
16.无序多重集合
unordered_multiset<T>s unordered_multiset<T>s(begin(),end()) unordered_multiset<T>s(s1) unordered_multiset<T>s({a,b,c...}) s=unordered_multiset<T>() s={a,b,c...} s=s1 begin() end() cbegin() cend() empty() size() max_size() insert(x)//插入x insert(it,x)//若知道x的位置则插入效率更高 insert({a,b,c...}) insert(begin(),end()) erase(it) erase(val)//删除所有val erase(begin(),end()) s1.swap(s2) clear() emplace(x)//插入x emplace_hint(it,x)//在it插入x key_comp()//返回自身比较函数 value_comp()//返回自身比较函数 bucket_count()//按键值分配的桶数 //s.begin(i),s.end(i)为该桶内的值(i=0->bucket_conut-1) max_bucket_count() bucket_size(x)//桶x含有的数量 bucket(x)//x所在的bucket find(x)//返回x的it count(x)//返回x的个数 equal_range(x)//返回pair(lower_bound(x),upper_boundd(x)) load_factor()//返回size/bucket_count max_load_factor()//返回最大load_factor max_load_factor(x)//将最大load_factor设置为x rehash(n)//修改hash表最小存储桶数为n reserve(n)//存储桶数修改为最适合至少包含n个元素的桶数 hash_function()(x)//返回x的hash值 key_eq()(x,y)//返回x与y是否被认为是相同的 =,!=,==
17.映射
map<T,t>m map<T,t>m(begin(),end()) map<T,t>m(m1) bool(P)(T,T)=cmp map<T,t,bool()(T,T)>m(p) begin() end() rbegin() rend() cbegin() cend() crbegin() crend() empty() size() max_size() at() insert(pair<T,t>) insert(it,pair<T,t>) insert(begin(),end()) erase(it) erase(T) erase(begin(),end()) m1.swap(m2) emplace(T,t) emplace_hint(it,T,t) clear() key_comp() value_comp() find(x)//返回x的it count(x)//返回x的个数 lower_bound() upper_bound() equal_range() m=m1 m=map<T,t>() it->first it->second (*it).first (*it).second [] =,!=,==,>,<,>=,<=
18.多重映射
multimap<T,t>m multimap<T,t>m(begin(),end()) multimap<T,t>m(m1) multimap<T,t,classcmp>m bool(P)(T,T)=cmp multimap<T,t,bool()(T,T)>m(p) begin() end() rbegin() rend() cbegin() cend() crbegin() crend() empty() size() max_size() insert(pair<T,t>) insert(it,pair<T,t>) insert(begin(),end()) erase(it) erase(T)//删除所有T erase(begin(),end()) m1.swap(m2) emplace(T,t) emplace_hint(it,T,t) clear() key_comp() value_comp() find(x)//返回x的it count(x)//返回x的个数 lower_bound() upper_bound() equal_range() m=m1 m=multimap<T,t>() it->first it->second (*it).first (*it).second =,!=,==,>,<,>=,<=
19.无序映射
unordered_map<T,t>m unordered_map<T,t>m({{T1,t1},{T2,t2}...}) unordered_map<T,t>m(m1) unordered_map<T,t>m(begin(),end()) m={{T1,t1},{T2,t2}...} begin() end() cbegin() cend() empty() size() max_size() insert(pair<T,t>) insert(it,pair<T,t>) insert(begin(),end()) erase(it) erase(T)//删除所有T erase(begin(),end()) m1.swap(m2) emplace(T,t) emplace_hint(it,T,t) clear() find(x)//返回x的it count(x)//返回x的个数 equal_range() bucket_count()//桶的个数 max_bucket_count() bucket_size(x)//桶x含有的数量 bucket(x)//x所在的桶 load_factor()//返回size/bucket_count max_load_factor()//返回最大load_factor max_load_factor(x)//最大load_factor设置为x rehash(n)//修改hash表最小存储桶数为n reserve(n)//存储桶数修改为最适合至少包含n个元素的桶数 hash_function()(x)//返回x的hash值 key_eq()(x,y)//返回x与y是否被认为是相同的 m=m1 m=unordered_map<T,t>() it->first it->second (*it).first (*it).second at() [] =,!=,==
20.无序多重映射
unordered_multimap<T,t>m unordered_multimap<T,t>m({{T1,t1},{T2,t2}...}) unordered_multimap<T,t>m(m1) unordered_multimap<T,t>m(begin(),end()) m={{T1,t1},{T2,t2}...} begin() end() cbegin() cend() empty() size() max_size() insert(pair<T,t>) insert(it,pair<T,t>) insert(begin(),end()) erase(it) erase(T)//删除所有T erase(begin(),end()) m1.swap(m2) emplace(T,t) emplace_hint(it,T,t) clear() find(x)//返回x的it count(x)//返回x的个数 equal_range() bucket_count()//桶的个数 max_bucket_count() bucket_size(x)//桶x含有的数量 bucket(x)//x所在的桶 load_factor()//返回size/bucket_count max_load_factor()//返回最大load_factor max_load_factor(x)//最大load_factor设置为x rehash(n)//修改hash表最小存储桶数为n reserve(n)//存储桶数修改为最适合至少包含n个元素的桶数 hash_function()(x)//返回x的hash值 key_eq()(x,y)//返回x与y是否被认为是相同的 m=m1 m=unordered_multimap<T,t>() it->first it->second (*it).first (*it).second =,!=,==
21.字符串
string s("abc...") string s(s1) string s(s1,pos,len) string s(s1,pos) string s("abc...",len) string s(n,ch)//初始化n个字符ch string s(begin(),end()) s="abc..." s=ch s=s1+s2 begin() end() rbegin() rend() cbegin() cend() crbegin() crend() size() length() max_size() resize(n)//调整大小为n,多则舍,少则补空字符 resize(n,ch)//调整大小为n,多则舍,少则补ch capacity()//容量 reserve(n)//请求更改容量为n clear() empty() shrink_to_fit() at() [] back() front() append(s1)//追加s1 append(s1,pos) append(s1,pos,len)//追加s1从pos开始,长len的子串 append("abc...",len)//追加"abc..."长为len的子串 append("abc...") append(n,ch)//追加n个ch append(begin(),end()) push_back() assign(s1)//重置为s1 assign(s1,pos) assign(s1,pos,len) assign("abc...",len) assign("abc...") assign(n,ch) assign(begin(),end()) insert(pos,s1)//pos之后插入s1 insert(pos,s1,st,len)//pos之后插入s1从st开始的长len的子串 insert(pos,"abc...",len) insert(pos,"abc...") insert(pos,n,ch) insert(it,ch)//it之前插入ch insert(it,n,ch) insert(it,begin(),end()) erase(pos,len) erase(it) erase(begin(),end()) erase(x)//保留<=x的部分,x<=n replace(pos,len,s1)//将从pos开始长len的部分替换为s1 replace(pos,len,s1,pos1,len1) replace(pos,len,"abc...") replace(pos,len,"abc...",len1) replace(pos,len,n,ch) replace(begin(),end(),s1) replace(begin(),end(),"abc...") replace(begin(),end(),"abc...",len) replace(begin(),end(),n,ch) replace(begin(),end(),s1.begin(),s2.end()) s1.swap(s2) pop_back() c_str()//返回指向正规c字符串的只读指针,const char*p=s.c_str()或strcpy(p,s.c_str()) data()//返回指向一个与s内容相同的数组的指针 copy(p,len) copy(p,len,pos)//string 从pos开始len个字符赋值给p,不追加'\0' find(s1,pos=0)//从pos开始查找s1在s中的位置,没有为npos或-1 find(p,pos=0) find(p,pos,len)//从pos考试查找p的前len个字符,没有为npos或-1 find(ch,pos=0) rfind(s1,pos=npos)//从pos开始反向查找s1在s中出现的最后一次的位置,没有为npos或-1 rfind(p,pos=npos) rfind(p,pos,len)//从pos开始反向查找p前len个字符在s中最后一次出现的位置,没有为npos或-1 rfind(ch,pos=npos) find_first_of(s1,pos=0)//从pos开始查找s1中任何一个字符首次在s中出现的位置,没有为npos或-1 find_first_of(p,pos=0) find_first_of(p,pos,len)//从pos开始查找p的前len个字符任何一个首次在s中出现的位置,没有为npos或-1 find_first_of(ch,pos=0) find_last_of(s1,pos=npos)//从pos开始反向查找s1中任何一个字符最后一次在s中出现的位置,没有为npos或-1 find_last_of(p,pos=npos) find_last_of(p,pos,len)//从pos开始反向查找p的前len个字符任何一个最后一次在s中出现的位置,没有为npos或-1 find_last_of(ch,pos=npos) find_first_not_of(s1,pos=0)//从pos开始查找s中第一个不存在于s1中的字符,没有则返回npos或-1 find_first_not_of(p,pos=0) find_first_not_of(p,pos,len)//从pos开始查找s中第一个不存在于p的前len个字符的字符,没有则返回npos或-1 find_first_not_of(ch,pos=0) find_last_not_of(s1,pos=npos)//从pos开始反向查找s中最后一个不存在于s1中的字符,没有则返回npos或-1 find_last_not_of(p,pos=npos) find_last_not_of(p,pos,len)//从pos开始反向查找s中第一个不存在于p的前len个字符的字符,没有则返回npos或-1 find_last_not_of(ch,pos=npos) substr(pos=0,len=npos) compare(s1) compare(pos,len,s1)//比较s从pos开始len个字符与s1,相同为0 compare(pos,len,s1,subpos,sublen)//比较s从pos开始len个字符与s1从subpos开始sublen个字符,相同为0 compare(p) compare(pos,len,p) compare(pos,len,p,n)//比较s从pos开始前len个字符与p前n个字符,相同为0 npos//size_t的最大值 getline(cin,s) =,!=,==,<,>,<=,>=,+,+=
22.字符串流
s<<x<<y...//x,y...流入s s>>a>>b...//依次将x,y...流出至a,b... str()//复制s内容 str(s1)//重置s为s1 str("abc...") s1.swap(s2) >> << 类型转换 template<class T,class t> T convert(const t&v){ stringstream s; s<<v; T re; s>>re; return re; }
扩展库:
万能头文件
#include<bits/extc++.h> using namespace __gnu_pbds
关联容器头文件
#include<ext/pb_ds/assoc_container.hpp> //hash,trie,tree都包含在这里面
迭代器
::point_iterator it
1.哈希表
#include<ext/pb_ds/hash_policy.hpp> cc_hash_table<T,t>mp1;//拉链法 gp_hash_table<T,t>mp2;//查探法 //一般认为查探法的效率会更高一些。 cc_hash_table<T,t>m cc_hash_table<T,t>m(begin(),end()) cc_hash_table<T,t>m(m1) gp_hash_table<T.t>m gp_hash_table<T,t>m(begin(),end()) gp_hash_table<T,t>m(m1) begin() end() empty() size() max_size() insert(pair<T,t>) erase(T) m1.swap(m2) clear() find(T) m=m1 m=cc_hash_table<int,int>() it->first it->second (*it).first (*it).second []
2.可并堆
#include<ext/pb_ds/priority_queue.hpp> priority_queue<T>q//默认为配对堆 priority_queue<T,cmp>q priority_queue<int,cmp,pairing_heap_tag>q//配对堆 priority_queue<int,cmp,binary_heap_tag>q//二叉堆 priority_queue<int,cmp,binomial_heap_tag>q//二项堆 priority_queue<int,cmp,rc_binomial_heap_tag>q//冗余计数二项堆 priority_queue<int,cmp,thin_heap_tag>q//经改良的斐波那契堆 struct cmp{bool operator()(const int&x,const int&y){return x<y;}}; /* 一般认为配对堆最快 二项堆次之 冗余计数二项堆再次 经改良的斐波那契堆更次 二叉堆最次 cmp函数可以自己写 也可以是less<T>或greater<T> */ q.join(q1)//将q1加入q并清空q1 bool pred(int x){return 1;} q.split(pred,q1)//按照pred(谓词)判断真假,真的分裂到q1,假的留在q push(T) modify(it,T)//修改it的位置,只要迭代器未被删除则保持有效 erase(it) top() empty() pop() size() q.swap(q1) q=q1 clear() begin() end()
3.字典树
#include<ext/pb_ds/trie_policy.hpp> trie<string,null_type>t trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>t /* 第一个参数必须是字符串类型 第二个参数通常为空 弄成map不方便 一般认为pat最快 不支持重复元素 */ begin() end() rbegin() rend() empty() size() insert(s) find(s) erase(s) erase(it) t.join(t1)//将t1并入t并清空t1,要求两方元素的字典序不能相交 t.split(s,t1)//小于等于s的属于t,其余的属于t1 t.lower_bound(s) t.upper_bound(s) //对于trie_prefix_search_node_update pair<::point_iterator,::point_iterator>range=t.prefix_range(s);//返回t中以s为前缀的字符串的迭代器范围,左闭右开 //对于trie_prefix_search_node_update order_of_key(s)//返回s的排名,从0开始 find_by_order(x)//返回排名为x的元素的迭代器
4.平衡树
#include<ext/pb_ds/tree_policy.hpp> tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>t tree<int,null_type,less<int>,splay_tree_tag,tree_order_statistics_node_update>t tree<int,null_type,less<int>,ov_tree_tag,tree_order_statistics_node_update>t /* 一般认为红黑树最快 伸展树次之 空间向量树最次 */ begin() end() rbegin() rend() size() empty() clear() insert(x) erase(x) erase(it) find(x) join(t1)//将t1并如t并删除t1 split(x,t1)//小于等于x的留在t,其余分裂到t1 lower_bound(x) upper_bound(x) order_of_key(x)//求x的排名 find_by_order(x)//根据排名找数
5.可持久化平衡树
#include<ext/rope> using namespace __gnu_cxx rope<char>rp rope<int>rp /* char和int在一些函数上会有所区别 crope相当于rope<char> */ begin() end() rbegin() rend() find() insert(pos,s,n) /* 下标pos插入s中的前n个字符 对于rope<char> 没有n则默认为全部字符 对于rope<int> 没有n则默认为0 */ substr(pos,n)//提取下标pos开始的n个字符 at(x)//下标为x的字符 clear() replace(pos,len,s,n)//下标pos开始的len位替换位s的前n位 push_back(x)//末尾添加 append(n,x//末尾添加n个x append(s,n)//末未添加s的前n位 erase(pos,n)//删除下标pos开始的n个字符 copy(pos,n,s)//下标pos开始n位替换到s中 rope<int>*rp[N] rp[0]=new rope<int>() rp[y=new rope<int>(*rp[x])//可持久化
函数
用于合并两个有序容器
merge(a.begin(),a.end(),b.begin(),b.end(),dest.begin()) dest.begin()为目标容器开始迭代器
函数
用于求容器中的第小数
nth_element(begin(),begin()+nth,end()) 最后也可以再传一个cmp比较函数 调用完后begin()+nth-1的指向的数即为区间[begin(),end())的第nth小数
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)