Rope大法好!
不会写Splay,就算会也懒得写,
一些基本操作:
#include<iostream>
#include<ext/rope>
using namespace std;
using __gnu_cxx::crope;
/*
crope test;
test.push_back(x);//在末尾添加x
test.insert(pos,x);//在pos插入x
test.erase(pos,x);//从pos开始删除x个
test.copy(pos,len,x);//从pos开始到pos+len为止用x代替
test.replace(pos,x);//从pos开始换成x
test.substr(pos,x);//提取pos开始x个
test.at(x)/[x];//访问第x个元素
*/
crope test;
int main()
{
string s = "abcdef";
for(int i = 0; i < s.size(); i++) test += s[i];
//可以开始操作啦
return 0;
}
它到底是一个分块链表还是二叉搜索树啊。。。复杂度是logn还是n^1.5啊。。
有空我一定还是学一学Splay
continuing.....