stl: rope(块状链表)

今天比赛中看到的一个挺简单的东西,除了常数大,别的都挺好的

#include <ext/rope>  // 头文件
using namespace __gnu_cxx;  // 注意名称空间

rope<int> rp;

int main() {
    rp.push_back(x); // 在末尾插入 x
    rp.insert(pos, x); // 在 pos 处插入 x
    rp.erase(pos, x); // 在 pos 处删除 x 个元素
    rp.length(); // 返回 rp 的大小
    rp.size(); // 同上
    rp.replace(pos, x); // 将 pos 处的元素替换成 x
    rp.substr(pos, x); // 从 pos 处开始提取 x 个元素
    rp.copy(pos, x, s); // 从 pos 处开始复制 x 个元素到 s 中
    rp[x]; // 访问第 x 个元素
    rp.at(x); // 同上
    return 0;
}
posted @   zhaozixu2006  阅读(26)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下
点击右上角即可分享
微信分享提示