Why does the C++ STL not provide any quot;treequot; containers?(为什么 C++ STL 不提供任何“树?容器?)
问题描述
为什么 C++ STL 不提供任何树"容器,而最好使用什么?
我想将对象的层次结构存储为树,而不是使用树作为性能增强...
您可能想要使用树的原因有两个:
您想使用树状结构来反映问题:
为此,我们有 boost 图形库>
或者你想要一个具有树状访问特征的容器为此,我们有
std::map(和std::multimap)std::set(和std::multiset)
基本上这两个容器的特性是它们实际上必须使用树来实现(尽管这实际上不是必需的).
另见这个问题:C 树实现
Why does the C++ STL not provide any "tree" containers, and what's the best thing to use instead?
I want to store a hierarchy of objects as a tree, rather than use a tree as a performance enhancement...
There are two reasons you could want to use a tree:
You want to mirror the problem using a tree-like structure:
For this we have boost graph library
Or you want a container that has tree like access characteristics For this we have
std::map(andstd::multimap)std::set(andstd::multiset)
Basically the characteristics of these two containers is such that they practically have to be implemented using trees (though this is not actually a requirement).
See also this question: C tree Implementation
这篇关于为什么 C++ STL 不提供任何“树"?容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么 C++ STL 不提供任何“树"?容器?
基础教程推荐
- 初始化列表*参数*评估顺序 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- CString 到 char* 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
