在C ++中订单统计树

编程入门 行业动态 更新时间:2024-10-27 00:23:58
本文介绍了在C ++中订单统计树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要一个用于标准GCC STL地图容器的订单统计树。

I need an order statistic tree for standard GCC STL map containers.

我检查过,有一种称为PBDS的东西。基于策略的数据结构。任何人都可以告诉我如何使用STL地图容器进行订单统计树的使用。

I checked and there is something known as PBDS. Policy based data structures. That usage is also not clear to me.

即使它仅在GNU G ++上它足够?

Anyone can tell me how to use STL map containers for order statistic tree? Even if its only on GNU G++ its enough?

推荐答案

以下是以执行订单统计的GNU基于策略的STL MAP为例树(在Linux gcc 4.6.1上测试):

Here is the example of GNU Policy-Based STL MAP implemented as order statistic tree (tested on 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源。

Here is a link to the overview of GNU Policy-Based Data Structures. Here is other tree_order_statistics example. I cannot find a good reference for Policy-Based Data Structures, but you can use these links as well as PBDS sources.

更多推荐

在C ++中订单统计树

本文发布于:2023-11-30 06:32:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1649031.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:订单

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!