# tree.hh **Repository Path**: xhzhu-robotic/tree.hh ## Basic Information - **Project Name**: tree.hh - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-09-22 - **Last Updated**: 2021-09-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README tree.hh: an STL-like C++ tree class =================================== by Kasper Peeters 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 should work with any C++11 compiler, and has been used and tested on all major platforms (Linux, Windows, macOS, Android, iOS). The library is available under the terms of the GNU General Public License version 2 or 3. What you need ------------- The tree.hh is header-only; you only need to copy the `src/tree.hh `_ header file into your project and you are good to go. Then scan the example below and consult the `documentation `_. Sample use ---------- The following is a small sample program to illustrate how `tree.hh` is used:: #include #include #include #include "tree.hh" using namespace std; int main(int, char **) { tree tr; tree::iterator top, one, two, loc, banana; top=tr.begin(); one=tr.insert(top, "one"); two=tr.append_child(one, "two"); tr.append_child(two, "apple"); banana=tr.append_child(two, "banana"); tr.append_child(banana,"cherry"); tr.append_child(two, "peach"); tr.append_child(one,"three"); loc=find(tr.begin(), tr.end(), "two"); if(loc!=tr.end()) { tree::sibling_iterator sib=tr.begin(loc); while(sib!=tr.end(loc)) { cout << (*sib) << endl; ++sib; } cout << endl; tree::iterator sib2=tr.begin(loc); tree::iterator end2=tr.end(loc); while(sib2!=end2) { for(int i=0; i