为什么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树实现
See also this question: C tree Implementation