为什么C ++ STL不提供任何“树”容器? [英] Why does the C++ STL not provide any "tree" containers?

查看:1748
本文介绍了为什么C ++ STL不提供任何“树”容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么C ++ STL不提供任何树容器,什么是最好的用法代替?

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...

推荐答案

有两个原因, :

您希望使用树状结构来镜像问题:

为此,我们有 boost图库

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
  • std::set

基本上这两个容器的特性是这样的,他们实际上必须使用树实现(虽然这不是一个要求)。

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).

另请参见此问题:
C树实现< a>

See also this question: C tree Implementation

这篇关于为什么C ++ STL不提供任何“树”容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆