C++中的顺序统计树
Order Statistic Tree in C++
我需要标准GCC STL映射容器的订单统计树。
我检查了一下,有一种叫做PBDS的东西。基于策略的数据结构。我也不清楚这种用法。
任何人都可以告诉我如何使用 STL 映射容器进行订单统计树?即使它只在 GNU G++ 上就足够了?
以下是作为顺序统计树实现的GNU基于策略的STL MAP的示例(在Linux gcc 4.6.1上测试):
#include <iostream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef
tree<
int,
int,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
map_t;
int main()
{
map_t s;
s.insert(make_pair(12, 1012));
s.insert(make_pair(505, 1505));
s.insert(make_pair(30, 1030));
cout << s.find_by_order(1)->second << 'n';
return 0;
}
这是GNU基于策略的数据结构概述的链接。这是其他tree_order_statistics示例。我找不到基于策略的数据结构的良好参考,但您可以使用这些链接以及 PBDS 源。
相关文章:
- CMake-按正确顺序将项目与C运行时对象文件链接
- 函数调用中参数的顺序重要吗
- 为什么不;名字在地图上是按顺序排列的吗
- 将Integer转换为4字节的unsined字符矢量(按大端字节顺序)
- 数到第n个楼梯的路(顺序无关紧要)
- 优先顺序:智能指针和类析构函数
- 在循环中按顺序遍历成员变量
- 独立读取-修改-写入顺序
- QML按钮点击功能执行顺序
- C++中数据类型修饰符的顺序
- 当比特(而不是字节)的顺序至关重要时的持久性
- C++从其他 constexpr 创建 lambda 不能按顺序执行 Constexpr
- 通过选项卡的文本设置QTabWidget顺序
- c++11评估顺序(未定义的行为)
- 如何在C++中递归地按相反顺序打印集合
- 给定顺序中的事件处理
- 具有包含其他对象的类的对象创建顺序
- 如何通过替换顺序代码的while循环来添加OpenMP for循环
- 使用多集__gnu_pbds的顺序统计树
- C++中的顺序统计树