gotchacppCritical
Why does the C++ STL not provide any "tree" containers?
Viewed 0 times
treeanywhycontainersthedoesnotprovidestl
Problem
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...
I want to store a hierarchy of objects as a tree, rather than use a tree as a performance enhancement...
Solution
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
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
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
Context
Stack Overflow Q#205945, score: 204
Revisions (0)
No revisions yet.