Tree Container Library: Download
tree

The Tree Container Library

A C++ generic tree container library which, not only works much like the STL, but is also compatible with the STL algorithms. The Tree Container Library is used worldwide in thousands of industries and organizations. It is completely free to use, and is licensed under the zlib/libpng license.

The tree container library is an open source library, in accordance with the zlib/libpng license. This license gives you rights to use the library in commercial applications, as well as free ones. The license agreement, which is contained in all the source files of the TCL, is given further below.

This library is compatible with any C++ compiler which conforms to the majority of the template standards. Developers are encouraged to use this library in their own projects how they see fit. Please feel free to email me with any comments, problems, questions, or suggestions regarding the library.

The TCL is compatible with Visual Studio 6, 7, and 8 (Visual Studio 2005), as well as gcc.

NOTE: VC6 USERS!

Visual C++ 6.0 users will need to download version 5.0.8 or earlier. Visual C++ 6.0 users will also need to un-check the Enable Minimal Rebuild compiler option for successful compilation. And, as with the STL, the normal #pragma warning (disable : xxxx) directive is necessary to avoid the compiler warnings.

Note: VC2005 SP1 USERS!

Gabor Bernat has discovered that an issue with Visual Studio 2005, Service Pack 1 has an issue with templates which prevents the TCL from compiling correctly. Gabor suppied a Microsoft support link which provides more information on this issue and provides a hotfix to correct the issue.

A test suite is available for the TCL, which vigorously tests all operations of all four tree containers. Studying the code can be helpful to see how some of the lesser known operations are used.

The files included in the TCL can be used inside your project, or better yet, they can be included in a static library, then used in your project. There are 21 files included with the TCL. They are as follows.

  • basic_tree.h/basic_tree.inl
    The base class for the four types of tree containers, given below.
  • child_iterator.h
    Defines associative and sequential child element iterator classes.
  • child_node_iterator.h
    Defines associative and sequential child node iterator classes.
  • reverse_iterator.h
    Defines the reverse child element iterators for all trees.
  • reverse_node_iterator.h
    Defines the reverse child node iterators for all the trees.
  • descendant_iterator.h/descendant_iterator.inl
    Defines the descendant element iterators for all tree containers.
  • descendant_node_iterator.h/descendant_node_iterator.inl
    Defines the descendant node iterators for all trees.
  • associative_tree.h/associative_tree.inl
    Inherits from basic_tree, and is the base for the 'associative' trees, tree, multitree, and unique_tree, which use std::set as the internal container.
  • tree.h/tree.inl
    Tree container class declaration/implementation.
  • multitree.h/multitree.inl
    Multitree container class declaration/implementation.
  • unique_tree.h/unique_tree.inl
    unique_tree container class declaration/implementation.
  • ordered_iterator.h
    Defines the ordered iterators for unique_tree.
  • sequential_tree.h/sequential_tree.inl
    sequential_tree container class declaration/implementation. Inherits directly from basic_tree.

Please see the disclosure agreement below regarding use of this library. This license agreement is contained in each file of the TCL.

Tree Container Library: Generic container library to store data in tree-like structures.
Copyright (c) 2006 Mitchel Haas

This software is provided 'as-is', without any express or implied warranty.
In no event will the author be held liable for any damages arising from
the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:

1. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.

2. Altered source versions must be plainly marked as such,
and must not be misrepresented as being the original software.

3. The above copyright notice and this permission notice may not be removed
or altered from any source distribution.

This library is free software; you can redistribute it and/or modify it under the terms of the license agreement displayed above, and in each of the source files.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Please note that in this version and all versions after 5.0.0, the behavior of all three descendant iterators have changed. The descendant iterators now traverse the called, or top node. In particular, the pre order iterators and level order iterators will start their traversals on the top node, and the post order iterators will end their traversals on the top node. In previous versions (before 5.0.0) descendant iterators did not traverse the top node. This change was needed to comply with standard and accepted tree algorithm behavior. If you are upgrading the library from versions before 5.0.0, and use descendant iterators in your project, you may need to alter your code to adapt to this new behavior. All documentation and examples on this site, and in the download-able documentation, have been updated to reflect these changes. Please see version history for a full description of version changes.

Latest Version
Product Version Release Date Download Links
Tree Container Library5.0.6Jun 13, 2020
Earlier Versions
Product Version Release Date Download Links
Tree Container LibraryJan 01, 1970
Tree Container LibraryJan 01, 1970