Tree in C/C++
Tree structure is frequently useful in case your software need to manage data in structured mode. The tree concept is simple but can have many different implementations. However, rather than reinvent the wheel, many developers proposed their solutions for manage tree. Here a short linst of some of them available in open source format. Feel free to add new if you know.
tree.hh: an STL-like C++ tree class
The tree.hh library for C++ provides an STL-like container class for n-ary trees, templated over the data stored at the nodes. Various types of iterators are provided (post-order, pre-order, and others). Where possible the access methods are compatible with the STL or alternative algorithms are available. The library is available under the terms of the GNU General Public License version 2 or 3.
Tree Container Library
The Tree Container Library (TCL) is a class template
library that you can use to store data elements in a tree-like
structure. The TCL consists of four templatized container classes,
similar to those found in the STL. These classes allow storage of basic
data types or user-defined types to be stored as nodes within a tree
structure. Each node of the tree is considered a tree itself, having all
the properties of a tree container. So, any operations that can be
performed on the tree container likewise can be performed on any node
within the tree. Iterators are provided to allow the transversal of the
tree nodes. Insert and find operations, as well as various other
operations, are also provided.
Rooted Ordered Tree Container
This component is an STL-like template class which implements a tree data structure. I called it an ntree (short for n-ary tree) years ago due to a misunderstanding - this is in fact a rooted ordered tree. However, the name has stuck because I don't want to break existing code that uses it.
Tree data class for C++
Not so long ago in one of my recent projects I needed a tree class for representing data structures.
I looked all over the web and didn't find any acceptable solution. A
tree is a structure which is not as simple as an array or list, so
unfortunately STL comes without it and I had to write one myself. I divided the implementation on two main parts: Data and Node.
Data object is responsible for holding the data, and the Node (Tree) for
the tree structure.
Treetree
Treetree is a header-only C++ library that implements a generic
tree-structured container class according to STL conventions, as well as
properly overloaded operator>> for input and operator<< for output.The
underlying data structure generalizes a doubly linked list - in
addition to previous and next pointers, tree nodes contain a third
pointer to the list of their children. The implementation is efficient,
and the API is expressive. Treetree is useful for representing anything
that one would use S-expressions for in Lisp (inference trees, programs,
etc.). You can iterate over the contents of a tree in pre- or
post-order, iterate over the children of a particular node only, or
iterate over leaves only. The same options are available for iteration
over subtrees (e.g. the subtrees of f(g(x, y) z), in pre-order, are f(g(x, y) z), g(x, y), x, y, and z).
Currently I found these. I'll add new if I'll find...
Comments
Post a Comment