Reputation: 1680
Is there any good tree manipulation (template) libraries for C++ out there that can do basic things like binary tree.
Though it is not difficult to write a binary tree all from scratch, but I'm really surprised that it is not so easy to find one ready-for-use.
Upvotes: 1
Views: 631
Reputation: 100658
What do you need the tree for? There may already be something in the STL or Boost that satisfies your need. For example: the STL std::map<key,value>
is usually implemented as a balanced binary tree.
There is also tree.hh which implements an STL-like n-way tree.
Upvotes: 1
Reputation: 1389
ACE has an implementation of Red Black tree. It is fairly easy to use.
Upvotes: 1
Reputation: 1454
Trees are subsets of graphs. There are plenty of graph libraries out there, such as Boost Graph Library. You will have to add your vertices as you want and then use any one of the many visitors to traverse your tree.
Alternatively, you could custom make one with standard containers (think of a root node as containing 2 children that have a value and may have 2 other children).
Upvotes: 2