Import of the tree library.

See: http://tree.phi-sci.com/index.html
This commit is contained in:
King_DuckZ 2014-07-06 21:56:18 +02:00
parent 103689a29a
commit ad613dc3fd
33 changed files with 9538 additions and 0 deletions

View file

@ -0,0 +1,220 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="verify-v1"
content="LkU+jobePpu3F8I4GPuTiOjrTukmo1qpWT+dT6SeAfk=" />
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<meta name="description" content="The tree.hh library provides C++
programmers with a container class to store arbitrary data in
n-ary tree form. It is compatible with the STL and its
algorithms wherever possible. Available under the terms of the GPL." />
<meta name="keywords" content="data structure, C++, programming, STL,
open source, container class" />
<title>tree.hh: an STL-like C++ tree class, documentation</title>
<link rel="stylesheet" type="text/css" href="tree.css" />
</head>
<body>
<div id="container">
<div id="title">
<div id="share">
<!-- AddThis Button BEGIN -->
<a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&amp;username=kpeeters"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=kpeeters"></script>
<!-- AddThis Button END -->
</div>
<div id="filler">
<img id="treeimg" src="tree2.png" alt="[background image]"/>
</div>
<div id="titletxt">
<h1>tree.hh: an STL-like C++ tree class</h1>
<h2 class="author">
<a href="http://maths.dur.ac.uk/users/kasper.peeters/">Kasper Peeters</a>, kasper.peeters (at) phi-sci.com
</h2>
</div>
</div>
<ul id="menubar">
<li><a href="index.html">Overview</a></li>
<li><a href="download.html">Download</a></li>
<li><a href="documentation.html">Documentation</a></li>
<li><a href="projects.html">Projects using tree.hh</a></li>
</ul>
<div id="linkbar">
<script type="text/javascript"><!--
google_ad_client = "pub-9577963716105989";
/* tree linkbar */
google_ad_slot = "0194609917";
google_ad_width = 728;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div id="main">
<div id="sidebar">
<script type="text/javascript"><!--
google_ad_client = "pub-9577963716105989";
/* tree.hh vertical ads */
google_ad_slot = "3744417434";
google_ad_width = 120;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<h2>Data structure overview</h2>
<div class="text">The data structure of the <code>tree</code> class is depicted
below (see the documentation for more detailed information).
Each node contains a pointer to the first and last child element,
and each child contains pointers to its previous and next sibling:
<img class="structure" src="structure.png" alt="[structure
diagram]" />
</div>
<div class="text">
Iterators come in various types. The normal <code>iterator</code> iterates depth-first
over all nodes. The beginning and end of the tree can be obtained by using the
<code>begin()</code> and <code>end()</code> members. The other type of iterator
only iterates over the nodes at one given depth (ie. over all siblings). One
typically uses these iterators to iterate over all children of a node, in which
case the [begin,end) range can be obtained by calling <code>begin(iterator)</code>
and <code>end(iterator)</code>.</div>
<div class="text">Iterators can be converted from one type to the other; this includes the `end'
iterators (all intervals are as usual closed at the beginning and open
at the end).</div>
<h2>Sample program</h2>
<div class="text">
Here is a small sample program to illustrate
how <code>tree.hh</code> is used in practise.
<div class="code">
<pre>#include &lt;algorithm&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;
#include "tree.hh"
using namespace std;
int main(int, char **)
{
tree&lt;string&gt; tr;
tree&lt;string&gt;::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&lt;string&gt;::sibling_iterator sib=tr.begin(loc);
while(sib!=tr.end(loc)) {
cout &lt;&lt; (*sib) &lt;&lt; endl;
++sib;
}
cout &lt;&lt; endl;
tree&lt;string&gt;::iterator sib2=tr.begin(loc);
tree&lt;string&gt;::iterator end2=tr.end(loc);
while(sib2!=end2) {
for(int i=0; i&lt;tr.depth(sib2)-2; ++i)
cout &lt;&lt; " ";
cout &lt;&lt; (*sib2) &lt;&lt; endl;
++sib2;
}
}
}</pre>
</div>
The output of this program is
<div class="code">
<pre>apple
banana
peach
apple
banana
cherry
peach</pre>
</div>
Note that this example only has one element at the
top of the tree (in this case that is the node containing "one") but
it is possible to have an arbitary number of such elements (then the
tree is more like a "bush"). Observe the way in which the two types of
iterators work. The first block of output, obtained using the
sibling_iterator, only displays the children directly below "two". The
second block iterates over all children at any depth below "two". In
the second output block, the <code>depth</code> member has been used
to determine the distance of a given node to the root of the
tree.
</div>
<h2>API documentation</h2>
<div class="text">
Documentation is available in the form of
a <a href="tree.pdf">pdf</a> file. This file is also available
in the tarball as a LaTeX file. Further information can be
obtained by reading the test program (included in the
distribution). Also look at the <a href="#example">simple
example</a> below.
</div>
<div class="text">
The most complete documentation of the interface is always
available in the <a href="doxygen/html/index.html">doxygen
generated documentation</a>.
</div>
</div>
<div id="flush"></div>
<p>
<a href="http://validator.w3.org/check?uri=referer">
<img
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
</p>
<!-- Start of StatCounter Code -->
<script type="text/javascript">
var sc_project=4068217;
var sc_invisible=1;
var sc_partition=50;
var sc_click_stat=1;
var sc_security="3f2419f9";
</script>
<script type="text/javascript"
src="http://www.statcounter.com/counter/counter_xhtml.js"></script>
<noscript>
<div class="statcounter">
<a title="blogspot statistics"
class="statcounter"
href="http://www.statcounter.com/blogger/">
<img
class="statcounter"
src="http://c.statcounter.com/4068217/0/3f2419f9/1/"
alt="blogspot statistics" /></a>
</div>
</noscript>
<!-- End of StatCounter Code -->
</div>
</body>
</html>

View file

@ -0,0 +1,175 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="verify-v1"
content="LkU+jobePpu3F8I4GPuTiOjrTukmo1qpWT+dT6SeAfk=" />
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<meta name="description" content="The tree.hh library provides C++
programmers with a container class to store arbitrary data in
n-ary tree form. It is compatible with the STL and its
algorithms wherever possible. Available under the terms of the GPL." />
<meta name="keywords" content="data structure, C++, programming, STL,
open source, container class" />
<title>tree.hh: an STL-like C++ tree class, download</title>
<link rel="stylesheet" type="text/css" href="tree.css" />
</head>
<body>
<div id="container">
<div id="title">
<div id="share">
<!-- AddThis Button BEGIN -->
<a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&amp;username=kpeeters"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=kpeeters"></script>
<!-- AddThis Button END -->
</div>
<div id="filler">
<img id="treeimg" src="tree2.png" alt="[background image]"/>
</div>
<div id="titletxt">
<h1>tree.hh: an STL-like C++ tree class</h1>
<h2 class="author">
<a href="http://maths.dur.ac.uk/users/kasper.peeters/">Kasper Peeters</a>, kasper.peeters (at) phi-sci.com
</h2>
</div>
</div>
<ul id="menubar">
<li><a href="index.html">Overview</a></li>
<li><a href="download.html">Download</a></li>
<li><a href="documentation.html">Documentation</a></li>
<li><a href="projects.html">Projects using tree.hh</a></li>
</ul>
<div id="linkbar">
<script type="text/javascript"><!--
google_ad_client = "pub-9577963716105989";
/* tree linkbar */
google_ad_slot = "0194609917";
google_ad_width = 728;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div id="main">
<div id="sidebar">
<script type="text/javascript"><!--
google_ad_client = "pub-9577963716105989";
/* tree.hh vertical ads */
google_ad_slot = "3744417434";
google_ad_width = 120;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<h2>Download</h2>
<div class="text">Everything (the header file, examples, documentation
and all other things referred to on this page) is contained in the
tarball</div>
<div class="filename">
<a href="tree-2.8.tar.gz">tree-2.8.tar.gz</a>
</div>
<div class="text">
Feel free to copy the header <a href="tree.hh">tree.hh</a>
(which is all you need code-wise) into your own source
directory as long as you respect the license (see above).
</div>
<div class="text">
The list of changes can be found in the <a href="ChangeLog">ChangeLog</a>.
</div>
<div class="text">
There is a small utility
library <a href="tree_util.hh">tree_util.hh</a> originally
written by Linda Buisman. This library contains a number of
functions to output a tree as text, to aid in debugging your
project.
</div>
<div class="text">The current version works with GNU gcc 3.x and
higher, Borland&nbsp;C++&nbsp;builder and Microsoft Visual C++ 7.1 and
higher (I no longer support older versions of Visual C++). It is
compatible with STLport (though older versions may not work
correctly, best to upgrade to something fairly recent).
</div>
<div class="text">The library is available for free, but if it
helps you a lot, why not consider a small donation?
<form id="donate"
action="https://www.paypal.com/cgi-bin/webscr" method="post">
<p>
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id"
value="YVWFQTJRGD8SW" />
<input type="image"
src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif"
name="submit"
alt="PayPal - The safer, easier way to pay online!" />
<img alt=""
src="https://www.paypal.com/en_GB/i/scr/pixel.gif"
width="1"
height="1" />
</p>
</form>
Your contribution is greatly appreciated!
</div>
<h2>Installation</h2>
<div class="text">
No installation is required as the tree.hh library is
contained in the single header file tree.hh. Just copy it into
your source directory (and upgrade it from the master site
when a new version becomes available).
</div>
</div>
<div id="flush"></div>
<p>
<a href="http://validator.w3.org/check?uri=referer">
<img
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
</p>
<!-- Start of StatCounter Code -->
<script type="text/javascript">
var sc_project=4068217;
var sc_invisible=1;
var sc_partition=50;
var sc_click_stat=1;
var sc_security="3f2419f9";
</script>
<script type="text/javascript"
src="http://www.statcounter.com/counter/counter_xhtml.js"></script>
<noscript>
<div class="statcounter">
<a title="blogspot statistics"
class="statcounter"
href="http://www.statcounter.com/blogger/">
<img
class="statcounter"
src="http://c.statcounter.com/4068217/0/3f2419f9/1/"
alt="blogspot statistics" /></a>
</div>
</noscript>
<!-- End of StatCounter Code -->
</div>
</body>
</html>

View file

@ -0,0 +1,270 @@
# Doxyfile 1.4.4
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = tree
PROJECT_NUMBER = "release 2.0"
OUTPUT_DIRECTORY = doxygen
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
DISTRIBUTE_GROUP_DOC = NO
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = YES
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = src/tree.hh
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.d \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.idl \
*.odl \
*.cs \
*.php \
*.php3 \
*.inc \
*.m \
*.mm \
*.dox \
*.C \
*.CC \
*.C++ \
*.II \
*.I++ \
*.H \
*.HH \
*.H++ \
*.CS \
*.PHP \
*.PHP3 \
*.M \
*.MM
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
USE_HTAGS = NO
VERBATIM_HEADERS = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = YES
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 881 B

View file

@ -0,0 +1,205 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="verify-v1"
content="LkU+jobePpu3F8I4GPuTiOjrTukmo1qpWT+dT6SeAfk=" />
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<meta name="description" content="The tree.hh library provides C++
programmers with a container class to store arbitrary data in
n-ary tree form. It is compatible with the STL and its
algorithms wherever possible. Available under the terms of the GPL." />
<meta name="keywords" content="data structure, C++, programming, STL,
open source, container class" />
<title>tree.hh: an STL-like C++ tree class</title>
<link rel="stylesheet" type="text/css" href="tree.css" />
</head>
<body>
<div id="container">
<div id="title">
<div id="share">
<!-- AddThis Button BEGIN -->
<a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&amp;username=kpeeters"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=kpeeters"></script>
<!-- AddThis Button END -->
</div>
<div id="plusone">
<!-- Place this tag where you want the +1 button to render -->
<g:plusone></g:plusone>
<!-- Place this tag after the last plusone tag -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</div>
<div id="filler">
<img id="treeimg" src="tree2.png" alt="[background image]"/>
</div>
<div id="titletxt">
<h1>tree.hh:&nbsp;an&nbsp;STL-like&nbsp;C++&nbsp;tree&nbsp;class</h1>
<h2 class="author">
<a href="http://maths.dur.ac.uk/users/kasper.peeters/">Kasper Peeters</a>, kasper.peeters (at) phi-sci.com
</h2>
</div>
</div>
<ul id="menubar">
<li><a href="index.html">Overview</a></li>
<li><a href="download.html">Download</a></li>
<li><a href="documentation.html">Documentation</a></li>
<li><a href="projects.html">Projects using tree.hh</a></li>
</ul>
<div id="linkbar">
<script type="text/javascript"><!--
google_ad_client = "pub-9577963716105989";
/* tree linkbar */
google_ad_slot = "0194609917";
google_ad_width = 728;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div id="main">
<div id="sidebar">
<script type="text/javascript"><!--
google_ad_client = "pub-9577963716105989";
/* tree.hh vertical ads */
google_ad_slot = "3744417434";
google_ad_width = 120;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<h2>Overview</h2>
<div class="text">
The <code>tree.hh</code> library for C++ provides an STL-like container class
for <i>n</i>-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 (see below).</div>
<div class="text">Documentation is available in the form of
a <a href="tree.pdf">pdf</a> file. See
the <a href="documentation.html">documentation page</a> for
more details and sample programs.
</div>
<div class="text">The <code>tree.hh</code> library is meant for generic <i>n</i>-ary
trees. For binary trees, AVL trees, quad trees and other data
structures, you may want to look elsewhere. </div>
<div class="text">The library is available for free, but if it
helps you a lot, why not consider a small donation?
<form id="donate"
action="https://www.paypal.com/cgi-bin/webscr" method="post">
<p>
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id"
value="YVWFQTJRGD8SW" />
<input type="image"
src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif"
name="submit"
alt="PayPal - The safer, easier way to pay online!" />
<img alt=""
src="https://www.paypal.com/en_GB/i/scr/pixel.gif"
width="1"
height="1" />
</p>
</form>
Your contribution is greatly appreciated!
</div>
<div class="text">
I have considered this class for inclusion in Boost. However,
there are many ways to implement a tree container, and there
is no good way to simultaneously satisfy everyone who would
use it. See the discussion on the Boost mailing list in
<a href="http://lists.boost.org/Archives/boost/2002/10/37383.php">2002</a>
and <a href="http://lists.boost.org/Archives/boost/2009/07/153719.php">2009</a>.
</div>
<h2>License</h2>
<div class="text">In principle, the <code>tree.hh</code> code is
available under the terms of the GNU General Public
License <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">2</a>
or <a href="http://www.gnu.org/copyleft/gpl.html">3</a>. However,
if you would like to use <code>tree.hh</code> under different
conditions, contact me and we will work something out.</div>
<div class="license">
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program. If not,
see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.
</div>
<div class="text">If you use <code>tree.hh</code>,
please satisfy my curiosity and write me a small email with
a bit of explanation of your software and the role of my tree
class in it.</div>
</div>
<div id="flush"></div>
<p>
<a href="http://validator.w3.org/check?uri=referer">
<img
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
</p>
<!-- Start of StatCounter Code -->
<script type="text/javascript">
var sc_project=4068217;
var sc_invisible=1;
var sc_partition=50;
var sc_click_stat=1;
var sc_security="3f2419f9";
</script>
<script type="text/javascript"
src="http://www.statcounter.com/counter/counter_xhtml.js"></script>
<noscript>
<div class="statcounter">
<a title="blogspot statistics"
class="statcounter"
href="http://www.statcounter.com/blogger/">
<img
class="statcounter"
src="http://c.statcounter.com/4068217/0/3f2419f9/1/"
alt="blogspot statistics" /></a>
</div>
</noscript>
<!-- End of StatCounter Code -->
</div>
</body>
</html>

View file

@ -0,0 +1,162 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="verify-v1"
content="LkU+jobePpu3F8I4GPuTiOjrTukmo1qpWT+dT6SeAfk=" />
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<meta name="description" content="The tree.hh library provides C++
programmers with a container class to store arbitrary data in
n-ary tree form. It is compatible with the STL and its
algorithms wherever possible. Available under the terms of the GPL." />
<meta name="keywords" content="data structure, C++, programming, STL,
open source, container class" />
<title>tree.hh: an STL-like C++ tree class, projects using tree.hh</title>
<link rel="stylesheet" type="text/css" href="tree.css" />
</head>
<body>
<div id="container">
<div id="title">
<div id="share">
<!-- AddThis Button BEGIN -->
<a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&amp;username=kpeeters"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=kpeeters"></script>
<!-- AddThis Button END -->
</div>
<div id="filler">
<img id="treeimg" src="tree2.png" alt="[background image]"/>
</div>
<div id="titletxt">
<h1>tree.hh: an STL-like C++ tree class</h1>
<h2 class="author">
<a href="http://maths.dur.ac.uk/users/kasper.peeters/">Kasper Peeters</a>, kasper.peeters (at) phi-sci.com
</h2>
</div>
</div>
<ul id="menubar">
<li><a href="index.html">Overview</a></li>
<li><a href="download.html">Download</a></li>
<li><a href="documentation.html">Documentation</a></li>
<li><a href="projects.html">Projects using tree.hh</a></li>
</ul>
<div id="linkbar">
<script type="text/javascript"><!--
google_ad_client = "pub-9577963716105989";
/* tree linkbar */
google_ad_slot = "0194609917";
google_ad_width = 728;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div id="main">
<div id="sidebar">
<script type="text/javascript"><!--
google_ad_client = "pub-9577963716105989";
/* tree.hh vertical ads */
google_ad_slot = "3744417434";
google_ad_width = 120;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<h2>Projects using tree.hh</h2>
<div class="text">The <code>tree.hh</code> library is used in various projects:
<dl>
<dt><strong><a
href="http://cadabra.phi-sci.com/">Cadabra</a></strong></dt>
<dd>A field-theory motivated approach to symbolic computer
algebra.</dd>
<dt><strong><a
href="http://www.gnu.org/software/gnash/">Gnash</a></strong></dt>
<dd>Gnash is a GNU Flash movie player. Previously, it was only
possible to play flash movies with proprietary software. While there
are some other free flash players, none support anything beyond SWF
v4. Gnash is based on GameSWF, and supports many SWF v7 features.</dd>
<dt><strong><a href="http://htmlcxx.sourceforge.net/">htmlcxx</a></strong></dt>
<dd>A simple non-validating css1 and html parser for C++.</dd>
<dt><strong><a href="http://www.cs.sfu.ca/~anoop/courses/CMPT-379-Fall-2007/index.html">Principles of Compiler Design</a></strong></dt>
<dd>A course in compiler design at the Simon Fraser University, Canada.</dd>
<dt><strong><a href="http://sourceforge.net/projects/liborigin/">liborigin</a></strong></dt>
<dd>A library for reading OriginLab OPJ project files, which is used
by <a href="http://soft.proindependent.com/qtiplot.html">QtiPlot</a>
and <a href="http://labplot.sourceforge.net/">LabPlot</a>, two
applications for data analysis and visualisation.</dd>
<dt><strong><a href="http://www.echem.uni-tuebingen.de/~bs/echem/software/EChem++/echem++.shtml">EChem++</a></strong></dt>
<dd>A project realizing the idea of a Problem Solving Environment
(PSE) in the field of computational electrochemistry. Computer
controlled experimental measurements, numerical simulation and
analysis of electrochemical processes will be combined under a common
user interface.</dd>
<dt><strong><a
href="http://www.infor.uva.es/~jadiego/">LZCS</a></strong></dt>
<dd>A semistructured document transformation tool. LZCS compresses
structured documents taking advantage of the redundant information
that can appear in the structure. The main idea is that frequently
repeated subtrees may exist and these can be replaced by a backward
reference to their first occurance. See the <a
href="http://www.dcc.uchile.cl/~gnavarro/ps/dcc04.1.ps.gz">accompanying
paper</a> for more details.</dd>
<dt><strong><a href="http://libofx.sourceforge.net/">libOFX</a></strong></dt>
<dd>A parser and an API designed to allow applications to very easily support OFX
command responses, usually provided by financial institutions for
statement downloads.</dd>
<dt><strong>A genetic programming project</strong></dt>
<dd>See this <a
href="http://www.cs.adfa.edu.au/~shanyin/publications/peel.pdf">paper</a> for
more information.</dd>
<dt><strong><a href="http://nlp.lsi.upc.edu/freeling/">FreeLing</a></strong></dt>
<dd> The FreeLing package consists of a library providing language analysis services (such as morfological analysis, date recognition, PoS tagging, etc.)</dd>
</dl>
Let me know about your project when you are using
<code>tree.hh</code>, so that I can add it to the list.</div>
</div>
<div id="flush"></div>
<p>
<a href="http://validator.w3.org/check?uri=referer">
<img
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
</p>
<!-- Start of StatCounter Code -->
<script type="text/javascript">
var sc_project=4068217;
var sc_invisible=1;
var sc_partition=50;
var sc_click_stat=1;
var sc_security="3f2419f9";
</script>
<script type="text/javascript"
src="http://www.statcounter.com/counter/counter_xhtml.js"></script>
<noscript>
<div class="statcounter">
<a title="blogspot statistics"
class="statcounter"
href="http://www.statcounter.com/blogger/">
<img
class="statcounter"
src="http://c.statcounter.com/4068217/0/3f2419f9/1/"
alt="blogspot statistics" /></a>
</div>
</noscript>
<!-- End of StatCounter Code -->
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View file

@ -0,0 +1,417 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="631.06183"
height="496.98901"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.46"
version="1.0"
sodipodi:docname="structure.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
inkscape:export-filename="/home/kasper/git/tree/doc/structure.png"
inkscape:export-xdpi="71.308388"
inkscape:export-ydpi="71.308388">
<defs
id="defs4">
<marker
inkscape:stockid="Arrow1Lend"
orient="auto"
refY="0"
refX="0"
id="Arrow1Lend"
style="overflow:visible">
<path
id="path3222"
d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
</marker>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="401.3348"
inkscape:cy="195.91012"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="904"
inkscape:window-height="715"
inkscape:window-x="155"
inkscape:window-y="123" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-79.177704,-27.247875)">
<rect
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect2391"
width="75"
height="25.714285"
x="195.57071"
y="51.866875" />
<text
xml:space="preserve"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
x="204.05081"
y="71.504051"
id="text2383"
sodipodi:linespacing="100%"><tspan
sodipodi:role="line"
id="tspan2385"
x="204.05081"
y="71.504051">head 1</tspan></text>
<g
id="g4556"
transform="translate(-30.304576,0.5199496)">
<g
transform="translate(120.20815,-92.934035)"
id="g4517">
<rect
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect3163"
width="75"
height="25.714285"
x="290.87708"
y="144.28096" />
<text
xml:space="preserve"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
x="299.35718"
y="163.91814"
id="text3165"
sodipodi:linespacing="100%"><tspan
sodipodi:role="line"
id="tspan3167"
x="299.35718"
y="163.91814">head 2</tspan></text>
</g>
</g>
<g
id="g3185">
<rect
y="260.67743"
x="79.677704"
height="25.714285"
width="60.857864"
id="rect3175"
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<text
sodipodi:linespacing="100%"
id="text3181"
y="278.85458"
x="87.344574"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
xml:space="preserve"><tspan
y="278.85458"
x="87.344574"
id="tspan3183"
sodipodi:role="line">node</tspan></text>
</g>
<g
id="g3190"
transform="translate(92.934022,-1.0101541)">
<rect
y="260.67743"
x="79.677704"
height="25.714285"
width="60.857864"
id="rect3192"
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<text
sodipodi:linespacing="100%"
id="text3194"
y="278.85458"
x="87.344574"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
xml:space="preserve"><tspan
y="278.85458"
x="87.344574"
id="tspan3196"
sodipodi:role="line">node</tspan></text>
</g>
<g
id="g3198"
transform="translate(201.02035,-1.010154)">
<rect
y="260.67743"
x="79.677704"
height="25.714285"
width="60.857864"
id="rect3200"
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<text
sodipodi:linespacing="100%"
id="text3202"
y="278.85458"
x="87.344574"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
xml:space="preserve"><tspan
y="278.85458"
x="87.344574"
id="tspan3204"
sodipodi:role="line">node</tspan></text>
</g>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 112.12693,256.36198 C 148.49242,226.0574 178.797,238.17923 196.97975,252.32137"
id="path3206"
sodipodi:nodetypes="cc" />
<text
xml:space="preserve"
style="font-size:15px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
x="148.49242"
y="228.07771"
id="text3208"
sodipodi:linespacing="100%"><tspan
sodipodi:role="line"
id="tspan3210"
x="148.49242"
y="228.07771">next sibling</tspan></text>
<text
xml:space="preserve"
style="font-size:15px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
x="108.37365"
y="333.25311"
id="text3212"
sodipodi:linespacing="100%"><tspan
sodipodi:role="line"
id="tspan3214"
x="108.37365"
y="333.25311">previous sibling</tspan></text>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 200.01021,290.38754 C 163.64472,320.69212 133.34014,308.57029 115.15739,294.42815"
id="path3994"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 209.10158,83.625892 L 101.01525,249.29091"
id="path3996" />
<text
xml:space="preserve"
style="font-size:14.99999809px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
x="-66.628067"
y="212.73572"
id="text4513"
sodipodi:linespacing="100%"
transform="matrix(0.5909299,-0.8067229,0.8067229,0.5909299,0,0)"><tspan
sodipodi:role="line"
id="tspan4515"
x="-66.628067"
y="212.73572">first child</tspan></text>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 220.21325,254.6613 C 256.57874,224.35672 286.88332,236.47855 305.06607,250.62069"
id="path4522"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 306.07622,290.38754 C 269.71073,320.69212 239.40615,308.57029 221.2234,294.42815"
id="path4524"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 257.96217,83.372105 L 323.88568,251.56499"
id="path4526"
sodipodi:nodetypes="cc" />
<text
xml:space="preserve"
style="font-size:14.99999809px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
x="241.30775"
y="-202.79788"
id="text4528"
sodipodi:linespacing="100%"
transform="matrix(0.4272211,0.9041472,-0.9041472,0.4272211,0,0)"><tspan
sodipodi:role="line"
id="tspan4530"
x="241.30775"
y="-202.79788">last child</tspan></text>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 274.76149,46.569867 C 311.12698,16.265292 341.43156,28.387122 359.61431,42.529262"
id="path4532"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 360.62446,84.316419 C 324.25897,114.621 293.95439,102.49917 275.77164,88.357029"
id="path4534"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:9.99999974, 9.99999974;stroke-dashoffset:0;stroke-opacity:1"
d="M 471.64002,63.927916 C 549.62414,63.927916 549.62414,63.927916 549.62414,63.927916"
id="path4546" />
<g
id="g4562"
transform="translate(-95.964492,0.2910246)">
<g
transform="translate(365.59772,-92.70511)"
id="g4548">
<rect
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4550"
width="75"
height="25.714285"
x="290.87708"
y="144.28096" />
<text
xml:space="preserve"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
x="299.35718"
y="163.91814"
id="text4552"
sodipodi:linespacing="100%"><tspan
sodipodi:role="line"
id="tspan4554"
x="299.35718"
y="163.91814">head n</tspan></text>
</g>
</g>
<g
id="g4568"
transform="translate(102.53048,214.52734)">
<rect
y="260.67743"
x="79.677704"
height="25.714285"
width="60.857864"
id="rect4570"
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<text
sodipodi:linespacing="100%"
id="text4572"
y="278.85458"
x="87.344574"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
xml:space="preserve"><tspan
y="278.85458"
x="87.344574"
id="tspan4574"
sodipodi:role="line">node</tspan></text>
</g>
<g
id="g4576"
transform="translate(195.4645,213.51719)">
<rect
y="260.67743"
x="79.677704"
height="25.714285"
width="60.857864"
id="rect4578"
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<text
sodipodi:linespacing="100%"
id="text4580"
y="278.85458"
x="87.344574"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
xml:space="preserve"><tspan
y="278.85458"
x="87.344574"
id="tspan4582"
sodipodi:role="line">node</tspan></text>
</g>
<g
id="g4584"
transform="translate(303.55083,213.51719)">
<rect
y="260.67743"
x="79.677704"
height="25.714285"
width="60.857864"
id="rect4586"
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<text
sodipodi:linespacing="100%"
id="text4588"
y="278.85458"
x="87.344574"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
xml:space="preserve"><tspan
y="278.85458"
x="87.344574"
id="tspan4590"
sodipodi:role="line">node</tspan></text>
</g>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 214.65741,470.88933 C 251.0229,440.58475 281.32748,452.70658 299.51023,466.84872"
id="path4592"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 302.54069,504.91489 C 266.1752,535.21947 235.87062,523.09764 217.68787,508.9555"
id="path4602"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 313.65237,301.1837 L 205.56604,466.84872"
id="path4604" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 322.74373,469.18865 C 359.10922,438.88407 389.4138,451.0059 407.59655,465.14804"
id="path4610"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 408.6067,504.91489 C 372.24121,535.21947 341.93663,523.09764 323.75388,508.9555"
id="path4612"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 329.17792,299.91976 L 426.41616,466.09234"
id="path4614"
sodipodi:nodetypes="cc" />
<text
xml:space="preserve"
style="font-size:25px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
x="257.5726"
y="-691.83954"
id="text4620"
sodipodi:linespacing="100%"
transform="matrix(0,1,-1,0,0,0)"><tspan
sodipodi:role="line"
id="tspan4622"
x="257.5726"
y="-691.83954">depth</tspan></text>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.70000005;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 665.71429,68.076468 L 665.71429,479.50504"
id="path4624" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 20 KiB

171
lib/tree-2.81/doc/tree.css Normal file
View file

@ -0,0 +1,171 @@
body {
font: 10pt "Lucida Grande", "Lucida Sans Unicode", Arial, Verdana, sans-serif;
}
div#container {
min-width: 700px;
margin-left: 20px;
margin-right: 20px;
margin-top: 20px;
margin-bottom: 30px;
background: #f0f0f0;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-moz-box-shadow: 1px 1px 9px #888;
padding: 5px 15px 5px 15px;
}
div#titletxt {
margin: -150px 0 30px 240px;
height: 70px;
}
div#filler {
width: 100%;
height: 160px;
background: url("filler.png");
padding: 0;
margin: 0;
margin-top: 5px;
-moz-box-shadow: 1px 1px 5px #888;
}
img#treeimg {
margin-top: 0;
}
/* Donations */
form#donate {
text-align: center;
margin-top: 1ex;
margin-bottom: 1ex;
}
/* Layout containers */
div#linkbar {
margin-right: 135px;
display: inline;
}
div#main {
margin-right: 135px;
display: inline;
}
div#sidebar {
margin-top: 16px;
float: right;
display: inline;
width: 125px;
margin-left: 10px;
}
div#flush {
clear: both;
}
/* Title color/style */
#title h1 {
font-size: 30px;
color: #b00000;
}
#title h2 {
font-size: 11pt;
font-weight: normal;
color: black;
border-bottom: 0px;
}
/* Menu */
ul#menubar {
margin-top: 0px;
margin-bottom: 35px;
margin-right: 2ex;
text-align: right;
}
#menubar li {
display: inline;
background: #b00000;
color: white;
font-weight: bold;
padding: .5ex 1ex .5ex 1ex;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
-moz-box-shadow: 1px 1px 9px #888;
}
#menubar li:hover {
background: #009000;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
-moz-box-shadow: 1px 1px 6px #888;
}
#menubar a {
text-decoration: none;
color: white;
}
/* Main color/style */
div#share {
position: absolute;
right: 50px;
top: 36px;
}
div#plusone {
position: absolute;
left: 50px;
top: 36px;
}
#main h2 {
margin-top: 2ex;
margin-right: 135px;
display: block;
background: #b00000;
color: white;
padding-left: 1ex;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
-moz-box-shadow: 1px 1px 9px #888;
}
div.text {
margin-left: 120px;
margin-bottom: 2ex;
margin-right: 145px;
}
div.license {
margin-left: 140px;
margin-bottom: 2ex;
margin-right: 155px;
}
div.filename {
margin-left: 200px;
margin-bottom: 1ex;
}
img.structure {
margin-top: 1ex;
margin-bottom: 1ex;
margin-left: 3ex;
}
dd {
margin-bottom: 2ex;
}
img {
border-style: none;
}
/* Code listing */
div.code {
margin: 1ex;
width: 90%;
border: dotted 1px black;
background: #f8f8f8;
font-size: 8pt;
padding: 1ex;
}
.code pre {
white-space: pre-wrap;
}

BIN
lib/tree-2.81/doc/tree.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
lib/tree-2.81/doc/tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 888 KiB

388
lib/tree-2.81/doc/tree.tex Normal file
View file

@ -0,0 +1,388 @@
\documentclass[11pt]{kasper}
%
% If you do not have 'kasper.cls', see
% http://www.damtp.cam.ac.uk/user/kp229/texstuff .
\usepackage{makeidx}
\usepackage{verbatim}
\usepackage{relsize}
\makeindex
%\newcommand{\toindex}[1]{#1\index{#1}}
\newcommand{\member}[1]{{\tt #1}\index{#1}}
%\newcommand{\member}[1]{{\tt #1}}
\def\mystrut{\vbox to 8.5pt{}\vtop to 3.5pt{}}
\def\V{\hskip10pt\vrule\hskip10pt}
\def\T{\hskip10pt\vrule\vrule height2.5pt depth -2.1pt width 10pt}
\def\L{\hskip10pt\vrule height 8.5pt depth -2.1pt
\vrule height2.5pt depth -2.1pt width 10pt}
\def\N{\hskip10pt\phantom{\vrule}\hskip10pt}
\def\hw{\hskip-1000pt plus 1fil}
% to test: insert before end of subtree
\begin{document}
\title{{\tt tree.hh} documentation}
\author{Kasper Peeters}
\email{kasper.peeters@gmail.com}
\maketitle
\begin{abstract}
The {\tt 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.\\[3ex]
Code and examples available at: {\tt http://tree.phi-sci.com/}\\[3ex]
{\bf This documentation is not yet entirely complete. Refer to the {\tt
tree.hh} header file for a full list of member functions.}
\end{abstract}
\vfill
\maketoc
\eject
\begin{sectionunit}
\title{Overview}
\maketitle
\begin{sectionunit}
\title{The container class}
\maketitle
The tree class of {\tt tree.hh} is a templated container class in the
spirit of the STL. It organises data in the form of a so-called n-ary
tree. This is a tree in which every node is connected to an arbitrary
number of child nodes. Nodes at the same level of the tree are called
``siblings'', while nodes that are below a given node are called its
``children''. At the top of the tree, there is a set of nodes which
are characterised by the fact that they do not have any parents. The
collection of these nodes is called the ``head'' of the tree. See
figure~\ref{f:overview} for a pictorial illustration of this
structure (90 degrees rotated for convenience).
\begin{figure}[th]
\begin{center}
\includegraphics[width=.5\textwidth]{treefig}
\caption{Overview of the tree structure. The elements at the top of
the tree (here displayed at the left for convenience) are in the
``head'' (there can be more than one such element). Every node is
linked to its children using the ``first child'' and ``last child''
links. In addition, all nodes on a given level are doubly-linked using
the ``previous sibling'' and ``next sibling'' links. The ``depth'' of
a given node refers to the horizontal distance from the head nodes.}
\label{f:overview}
\end{center}
\end{figure}
The tree class is templated over the data objects stored at the nodes;
just like you can have a {\tt vector<string>} you can now have a
{\tt tree<string>}. Many STL algorithms work on this data structure,
and where necessary alternatives have been provided.
\medskip
\end{sectionunit}
\begin{sectionunit}
\title{Iterators}
\maketitle
The essential difference between a container with the structure of a
tree and the STL containers is that the latter are ``linear''. While
the STL containers thus only have essentially one way in which one can
iterate over their elements, this is not true for trees. The {\tt
tree.hh} library provides (at present) four different iteration
schemes. To describe them, consider the following tree:
\begin{equation*}
\vcenter{\offinterlineskip
\halign{&#\mystrut\hfil\cr
root \hw\cr
\T A \cr
\V \T B \cr
\V \L C \cr
\L D \cr
\N \T E \cr
\N \L F \cr}}
\end{equation*}
The three iteration types and the resulting order in which nodes are
visited are tabulated below:
\begin{center}
\begin{tabular}{llll}
pre-order (default) & ``element before children'' &
\member{pre\_order\_iterator} & root A B C D E F \\
post-order & ``element after children'' &
\member{post\_order\_iterator} & B C A E F D root \\
breadth-first & &
\member{breadth\_first\_iterator} & root A D B C E F \\
sibling & ``only siblings'' &
\member{sibling\_iterator} & (for ex.) A D \\
fixed-depth & &
\member{fixed\_depth\_iterator} & (for ex.) A D \\
leaf & &
\member{leaf\_iterator} & B C E F
\end{tabular}
\end{center}
The pre-order ones are the default iterators, and therefore also known
under the name of {\tt iterator}. Sibling iterators and fixed-depth
iterators iterate only over the nodes at a given depth of the
tree. The former restrict themselves to the child nodes of one given
node, while the latter iterates over all child nodes at the given
depth. Finally, leaf iterators iterate over all leafs (bottom-most)
nodes of the tree.
There are copy constructors that will convert iterators of the
various types into each other. The post- and pre-order iterators are
both also known as ``depth-first'', in contrast to the
``breadth-first'' iterator.
The begin and end iterators of a tree can be obtained using
\member{begin()} and \member{end()} (for pre-order iterators) or
alternatively \member{begin\_post()} and \member{end\_post()} (for
post-order iterators) and \member{begin\_leaf()} and
\member{end\_leaf()} (for leaf iterators). Similarly, the begin and
end sibling iterators can be obtained by calling
\member{begin(iterator)} and \member{end(iterator)}. The range of
children of a given node can also be obtained directly from an
iterator, by using the {\tt iterator::begin()} and {\tt
iterator::end()} member functions.
If you want to (temporarily) make an iterator not go into the child
subtree, call the member function \member{skip\_children}. This will only
keep effect for a single increment or decrement of the
iterator. Finally, whether or not an iterator is actually pointing at
a node (i.e.~is not an ``end'' iterator) can be tested using the
\member{is\_valid(iterator)} member of the tree class.
\end{sectionunit}
\end{sectionunit}
\begin{sectionunit}
\title{Basic operations}
\maketitle
\begin{description}
\item[Initialising] There are two nontrivial constructors. One which takes
a single node element as argument. It constructs a tree with this node
begin the sole node in the head (in other words, it is a combination
of a trivial constructor together with a \member{set\_head} call).
The other non-trivial constructor takes an iterator, and copies the
subtree starting at that node into the newly created tree (useful for
constructing new tree objects given by subtrees of existing trees).
\item[Tree traversal] Besides the \member{operator++} and
\member{operator--} members for step-wise traversal through the tree,
it is also possible to use the \member{operator+=} and \member{operator-=}
member functions to make more than one step at the same time (though
these are linear time, not amortized constant). The result of stepping
beyond the end of the tree or stepping beyond the end of a sibling
range (for sibling iterators) is undefined.
The parent of a given node can be reached by calling the \member{parent}
member of the tree object, giving it an iterator pointing to the node.
If you know the number of children of a given node, you can get direct
access to the $n$th child by using the \member{child} member
function. Note that the value of the index is not checked and should
therefore always be valid.
\item[Appending child nodes] Nodes can be added as children of a given
node using the \member{append\_child} member function.
\item[Inserting nodes] Nodes can be inserted at the same depth as a
given other node using the \member{insert} and \member{insert\_after}
members functions. This is also how you insert the first node into a
tree.
\end{description}
\end{sectionunit}
\begin{sectionunit}
\title{Other algorithms}
\maketitle
\begin{sectionunit}
\title{Non-mutating algorithms}
\maketitle
\begin{description}
\item[Counting nodes] The total number of nodes of a tree can be
obtained using the \member{size} member function, while the number of
children of a given node can be obtained with a call to
\member{number\_of\_children(iterator)}. Similarly, the number of
nodes at a given depth (the number of siblings of a given node) can be
obtained using the \member{number\_of\_siblings} member function.
\item[Determining depth] The \member{depth()} member function returns the
distance of a node to the root.
\item[Accessing siblings by their index] See the next item.
\item[Determining index in a sibling range] In order to determine the
index of a node in the range of siblings to which it belongs, use the
\member{index(sibling\_iterator)} member function. The first sibling node
has index 0. The reverse of this function (obtaining a sibling node
given its index in the range of siblings) is called
\member{child(const iterator\_base\&, unsigned int)}.
\item[Comparing trees] While the STL \member{equal} algorithm can be used
to compare the values of the nodes in two different trees, it does not
know about the structure of the tree. If you want the comparison to
take this into account, use the \member{equal(iterator, iterator,
iterator, BinaryPredicate)} call of the tree class. As an addition to
the STL algorithm, the length of the first range does not have to be
equal to the length of the range pointed to by the second iterator.
There is also an \member{equal\_subtree} algorithm which takes only
two iterators, pointing to the (single-node) heads of two
subtrees.
\end{description}
\end{sectionunit}
\begin{sectionunit}
\title{Mutating algorithms}
\maketitle
\begin{description}
\item[Erasing nodes and subtrees] In order to remove a node including
its children from the tree, use the \member{erase(iterator)} call. If you
just want to erase the children, but not the node itself, use the
\member{erase\_children(iterator)} call.
\item[Replacing individual nodes or subtrees]
\item[Flattening subtrees] The procedure of moving all children of a
given node to be siblings of that node is called ``flattening''; it
acts as
\begin{equation*}
\vcenter{\offinterlineskip
\halign{&#\mystrut\hfil\cr
apple \hw\cr
\T banana\cr
\V \T pear \cr
\V \T strawberry \cr
\V \L cherry \cr
\L grape\cr}}\quad\rightarrow\quad
\vcenter{\offinterlineskip
\halign{&#\mystrut\hfil\cr
apple \hw\cr
\T banana\cr
\T pear \cr
\T strawberry \cr
\T cherry \cr
\L grape\cr}}
\end{equation*}
% \begin{screen}
% apple apple
% banana banana
% pear -> pear
% strawberry strawberry
% cherry cherry
% grape grape
% \end{screen}
when the tree is flattened at the ``banana'' node.
\item[Moving or exchanging subtrees] Simple exchange of one sibling node with the
next one is done through the member function \member{swap(sibling\_iterator)}. The
iterator remains valid and remains pointing to the moved subtree.
More complicated move operations are the \member{move\_ontop},
\member{move\_before} and \member{move\_after} ones. These all take
two iterators, a source and a target. The member
\member{move\_ontop(target, source)} removes the `target' node and
all its children, and replaces it with the `source' node and its
children. The `source' subtree is removed from its original location.
The other two move members do a similar thing, differing only in the
node which is to be replaced.
\item[Extracting subtrees] You can create a new tree object
filled with the data of a subtree of the original tree. This is
analogous to the extraction of a substring of a string. The relevant
member function is \member{subtree(sibling\_iterator,
sibling\_iterator)} which takes a range of siblings as argument.
There is also a slight variation of this member, which does not return
a tree object but instead populates one that is passed as an argument
(useful if you want to call this on a tree object subclassed from
{\tt tree<T>}.
\item[Sorting] The standard STL sort algorithm is not very useful for
trees, because it only exchanges values, not nodes. Applying it to a
tree would mean that the structure of the tree remains unmodified,
only node values get moved around (not their subtrees).
Therefore, the {\tt tree} class has its own sort member. It comes in
two forms, just like the STL sort, namely
\begin{screen}
void sort(sibling_iterator from, sibling_iterator to, bool deep=false);
template<class StrictWeakOrdering>
void sort(sibling_iterator from, sibling_iterator to,
StrictWeakOrdering comp, bool deep=false);
\end{screen}
The result of a call to either of these is that the nodes in the range
described by the two iterators get sorted. If the boolean {\tt deep}
is true, the subtrees of all these nodes will get sorted as well (and
so one can sort the entire tree in one call). As in the STL, you can
use the second form of this function to pass your own comparison
class.
If the nodes to which the two iterators point are not in the same
sibling range (i.e.~not at the same depth in the tree), the result is undefined.
\item[Merging] One way in which one might think of indicating the
position where new nodes are to be inserted, is to give the path that
leads to the insertion point. For instance, given the tree
\begin{equation*}
\vcenter{\offinterlineskip
\halign{&#\mystrut\hfil\cr
apple \hw\cr
\T banana\cr
\V \T pear \cr
\V \T strawberry \cr
\V \L cherry \cr
\L grape\cr}}
\end{equation*}
one could imagine using the sub-tree
\begin{equation*}
\vcenter{\offinterlineskip
\halign{&#\mystrut\hfil\cr
apple \hw\cr
\L banana\cr
\N \T coconut \cr
\N \L raspberry \cr}}
\end{equation*}
to indicate that the nodes ``coconut'' and ``raspberry'' are to be
inserted as new children of the ``banana'' node. In {\tt tree.hh} this
process is called \emph{tree merging}. It can do the simple addition
of children as above, but actually handles the generic case too: as
an example consider the merge
\begin{equation*}
\text{\tt merge}\left[
\vcenter{\offinterlineskip
\halign{&#\mystrut\hfil\cr
apple \hw\cr
\T banana\cr
\V \T pear \cr
\V \T strawberry \cr
\V \L cherry \cr
\T grape\cr
blueberry \cr}}\quad, \quad
\vcenter{\offinterlineskip
\halign{&#\mystrut\hfil\cr
apple \hw\cr
\T banana\cr
\V \T coconut \cr
\V \L raspberry \cr
\T tangerine \cr
\V \L plum\cr
blueberry \cr
\N \L orange \cr}}\right]\quad\rightarrow\quad
\vcenter{\offinterlineskip
\halign{&#\mystrut\hfil\cr
apple \hw\cr
\T banana\cr
\V \T pear\cr
\V \T strawberry\cr
\V \T cherry\cr
\V \T coconut \cr
\V \L raspberry \cr
\T grape\cr
\T tangerine \cr
\V \L plum\cr
blueberry \cr
\N \L orange \cr}}
\end{equation*}
As is clear from the above, the arguments to \member{merge} are two
sibling ranges.
\end{description}
\end{sectionunit}
\end{sectionunit}
\printindex
\end{document}

BIN
lib/tree-2.81/doc/tree2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

View file

@ -0,0 +1,190 @@
%!PS-Adobe-2.0 EPSF-2.0
%%Title: tree.eps
%%Creator: fig2dev Version 3.2 Patchlevel 0-beta3
%%CreationDate: Fri May 3 12:41:08 2002
%%For: kp229@church.amtp.cam.ac.uk (Kasper Peeters)
%%Orientation: Portrait
%%BoundingBox: 0 0 324 252
%%Pages: 0
%%BeginSetup
%%EndSetup
%%Magnification: 1.0000
%%EndComments
/$F2psDict 200 dict def
$F2psDict begin
$F2psDict /mtrx matrix put
/col-1 {0 setgray} bind def
/col0 {0.000 0.000 0.000 srgb} bind def
/col1 {0.000 0.000 1.000 srgb} bind def
/col2 {0.000 1.000 0.000 srgb} bind def
/col3 {0.000 1.000 1.000 srgb} bind def
/col4 {1.000 0.000 0.000 srgb} bind def
/col5 {1.000 0.000 1.000 srgb} bind def
/col6 {1.000 1.000 0.000 srgb} bind def
/col7 {1.000 1.000 1.000 srgb} bind def
/col8 {0.000 0.000 0.560 srgb} bind def
/col9 {0.000 0.000 0.690 srgb} bind def
/col10 {0.000 0.000 0.820 srgb} bind def
/col11 {0.530 0.810 1.000 srgb} bind def
/col12 {0.000 0.560 0.000 srgb} bind def
/col13 {0.000 0.690 0.000 srgb} bind def
/col14 {0.000 0.820 0.000 srgb} bind def
/col15 {0.000 0.560 0.560 srgb} bind def
/col16 {0.000 0.690 0.690 srgb} bind def
/col17 {0.000 0.820 0.820 srgb} bind def
/col18 {0.560 0.000 0.000 srgb} bind def
/col19 {0.690 0.000 0.000 srgb} bind def
/col20 {0.820 0.000 0.000 srgb} bind def
/col21 {0.560 0.000 0.560 srgb} bind def
/col22 {0.690 0.000 0.690 srgb} bind def
/col23 {0.820 0.000 0.820 srgb} bind def
/col24 {0.500 0.190 0.000 srgb} bind def
/col25 {0.630 0.250 0.000 srgb} bind def
/col26 {0.750 0.380 0.000 srgb} bind def
/col27 {1.000 0.500 0.500 srgb} bind def
/col28 {1.000 0.630 0.630 srgb} bind def
/col29 {1.000 0.750 0.750 srgb} bind def
/col30 {1.000 0.880 0.880 srgb} bind def
/col31 {1.000 0.840 0.000 srgb} bind def
end
save
-126.0 342.0 translate
1 -1 scale
/cp {closepath} bind def
/ef {eofill} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/sa {save} bind def
/rs {restore} bind def
/l {lineto} bind def
/m {moveto} bind def
/rm {rmoveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/sh {show} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/sd {setdash} bind def
/ff {findfont} bind def
/sf {setfont} bind def
/scf {scalefont} bind def
/sw {stringwidth} bind def
/tr {translate} bind def
/tnt {dup dup currentrgbcolor
4 -2 roll dup 1 exch sub 3 -1 roll mul add
4 -2 roll dup 1 exch sub 3 -1 roll mul add
4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
bind def
/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
4 -2 roll mul srgb} bind def
/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
/$F2psEnd {$F2psEnteredState restore end} def
%%EndProlog
$F2psBegin
10 setmiterlimit
n -1000 6700 m -1000 -1000 l 8494 -1000 l 8494 6700 l cp clip
0.06000 0.06000 sc
% Polyline
7.500 slw
gs clippath
4380 3828 m 4350 3948 l 4320 3828 l 4320 3990 l 4380 3990 l cp
4320 3222 m 4350 3102 l 4380 3222 l 4380 3060 l 4320 3060 l cp
clip
n 4350 3075 m 4350 3975 l gs col0 s gr gr
% arrowhead
n 4320 3222 m 4350 3102 l 4380 3222 l 4350 3222 l 4320 3222 l cp gs 0.00 setgray ef gr col0 s
% arrowhead
n 4380 3828 m 4350 3948 l 4320 3828 l 4350 3828 l 4380 3828 l cp gs 0.00 setgray ef gr col0 s
% Polyline
[60] 0 sd
n 4350 4350 m 4350 5475 l gs col0 s gr [] 0 sd
% Polyline
gs clippath
4021 5328 m 4039 5450 l 3966 5351 l 4028 5500 l 4083 5477 l cp
clip
n 2550 1875 m 4050 5475 l gs col0 s gr gr
% arrowhead
n 4021 5328 m 4039 5450 l 3966 5351 l 3993 5339 l 4021 5328 l cp gs 0.00 setgray ef gr col0 s
% Polyline
gs clippath
4380 2628 m 4350 2748 l 4320 2628 l 4320 2790 l 4380 2790 l cp
4320 2022 m 4350 1902 l 4380 2022 l 4380 1860 l 4320 1860 l cp
clip
n 4350 1875 m 4350 2775 l gs col0 s gr gr
% arrowhead
n 4320 2022 m 4350 1902 l 4380 2022 l 4350 2022 l 4320 2022 l cp gs 0.00 setgray ef gr col0 s
% arrowhead
n 4380 2628 m 4350 2748 l 4320 2628 l 4350 2628 l 4380 2628 l cp gs 0.00 setgray ef gr col0 s
% Polyline
gs clippath
3903 1695 m 4023 1725 l 3903 1755 l 4065 1755 l 4065 1695 l cp
clip
n 2550 1725 m 4050 1725 l gs col0 s gr gr
% arrowhead
n 3903 1695 m 4023 1725 l 3903 1755 l 3903 1725 l 3903 1695 l cp gs 0.00 setgray ef gr col0 s
% Polyline
gs clippath
6828 1695 m 6948 1725 l 6828 1755 l 6990 1755 l 6990 1695 l cp
clip
n 4725 1725 m 6975 1725 l gs col0 s gr gr
% arrowhead
n 6828 1695 m 6948 1725 l 6828 1755 l 6828 1725 l 6828 1695 l cp gs 0.00 setgray ef gr col0 s
% Polyline
[60] 0 sd
n 7275 1950 m 7275 2625 l gs col0 s gr [] 0 sd
/Times-Roman ff 180.00 scf sf
2100 1800 m
gs 1 -1 sc (head) col0 sh gr
/Times-Roman ff 180.00 scf sf
4200 1800 m
gs 1 -1 sc (node) col0 sh gr
/Times-Roman ff 180.00 scf sf
4200 3000 m
gs 1 -1 sc (node) col0 sh gr
/Times-Roman ff 180.00 scf sf
4200 4200 m
gs 1 -1 sc (node) col0 sh gr
/Times-Roman ff 180.00 scf sf
4200 5700 m
gs 1 -1 sc (node) col0 sh gr
/Times-Roman ff 180.00 scf sf
4575 2250 m
gs 1 -1 sc (next sibling) col0 sh gr
/Times-Roman ff 180.00 scf sf
4575 2475 m
gs 1 -1 sc (prev sibling) col0 sh gr
/Times-Roman ff 180.00 scf sf
4575 3450 m
gs 1 -1 sc (next sibling) col0 sh gr
/Times-Roman ff 180.00 scf sf
4575 3675 m
gs 1 -1 sc (prev sibling) col0 sh gr
/Times-Roman ff 180.00 scf sf
5850 1650 m
gs 1 -1 sc (first child) col0 sh gr
/Times-Roman ff 180.00 scf sf
2925 1650 m
gs 1 -1 sc (first child) col0 sh gr
/Times-Roman ff 180.00 scf sf
7125 1800 m
gs 1 -1 sc (node) col0 sh gr
/Times-Roman ff 180.00 scf sf
7125 2925 m
gs 1 -1 sc (node) col0 sh gr
/Times-Roman ff 180.00 scf sf
2550 3900 m
gs 1 -1 sc (last child) col0 sh gr
$F2psEnd
rs

View file

@ -0,0 +1,44 @@
#FIG 3.2
Landscape
Center
Inches
Letter
100.00
Single
-2
1200 2
2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 1 1 2
1 1 1.00 60.00 120.00
1 1 1.00 60.00 120.00
4350 3075 4350 3975
2 1 1 1 0 7 0 0 -1 4.000 0 0 -1 0 0 2
4350 4350 4350 5475
2 1 0 1 0 7 0 0 -1 4.000 0 0 -1 1 0 2
1 1 1.00 60.00 120.00
2550 1875 4050 5475
2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 1 1 2
1 1 1.00 60.00 120.00
1 1 1.00 60.00 120.00
4350 1875 4350 2775
2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 1 0 2
1 1 1.00 60.00 120.00
2550 1725 4050 1725
2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 1 0 2
1 1 1.00 60.00 120.00
4725 1725 6975 1725
2 1 1 1 0 7 0 0 -1 4.000 0 0 -1 0 0 2
7275 1950 7275 2625
4 0 0 0 0 0 12 0.0000 0 135 360 2100 1800 head\001
4 0 0 0 0 0 12 0.0000 4 135 360 4200 1800 node\001
4 0 0 0 0 0 12 0.0000 4 135 360 4200 3000 node\001
4 0 0 0 0 0 12 0.0000 4 135 360 4200 4200 node\001
4 0 0 0 0 0 12 0.0000 4 135 360 4200 5700 node\001
4 0 0 0 0 0 12 0.0000 4 180 870 4575 2250 next sibling\001
4 0 0 0 0 0 12 0.0000 4 180 870 4575 2475 prev sibling\001
4 0 0 0 0 0 12 0.0000 4 180 870 4575 3450 next sibling\001
4 0 0 0 0 0 12 0.0000 4 180 870 4575 3675 prev sibling\001
4 0 0 0 0 0 12 0.0000 4 135 720 5850 1650 first child\001
4 0 0 0 0 0 12 0.0000 4 135 720 2925 1650 first child\001
4 0 0 0 0 0 12 0.0000 4 135 360 7125 1800 node\001
4 0 0 0 0 0 12 0.0000 4 135 360 7125 2925 node\001
4 0 0 0 0 0 12 0.0000 4 135 690 2550 3900 last child\001

View file

@ -0,0 +1,71 @@
%PDF-1.3
%Çì<C387>¢
6 0 obj
<</Length 7 0 R/Filter /FlateDecode>>
stream
­UK<EFBFBD>Ó0¾ûWøÖ©YÏø}]‰—…H‡¥<E280A1>MPZØí
øùŒ_‰³©©h¤zÆóøÆó°E\„/¯›{b·<±{"?±°{ Ô(øÀ$ª9ˆŽ<CB86> l<C2A0>´AjÁAh n NbN ‰t°Jt—%Ê™Æ<E284A2>>´Í$+œvjô—èŽðž©Fó_ŃÕSDR“ÖÇx² ·Øþíq<>ƒŽX²I3_k`?siø*Û6:£<>*=46†c‰Œl%!HÀ™ðM¬èpzÀ$s>0Ræ„Ô•CKPècáÀÎu[*5! ˜Æ¤&˺<C38B>ÿËc·4±@NÕ¥´¶.eΪip<12>QT]ˆh«.̲ÂI1N¦Ï ŠHŸœ ׃s…ƒip.KÙ¤Y ÎrÓÅUB<>(!c7éÐå(]ÈbIccûX?§ƒÍÙ<C38D>æy ²«ª —VšuA®t°43褙pÐ YÂA/Õœ>—™x¿çÔ Gýwj VšUj®uðê¶•tES#ë<>¥HSw¥HŸèöޝo^6~×Ò+ìiƒÜµ{gàkÑú¡R@˜Š·vÓí¶oÚo è¼Ý²›ã÷í.ìXäíûÌ®ÆÕz‘ΈÂ&ÃÝï~ê¿ýñ1º”$ Ê?žw?GÁŠÑ —ög«ê[Cû€¤³ïŸO/|ÓõC |M× IÄ95_ûÙ©Œ-àék´¡Në)µ‡w-¿§^øöÌÐcendstream
endobj
7 0 obj
588
endobj
10 0 obj
<</R4
4 0 R>>
endobj
11 0 obj
<</R9
9 0 R>>
endobj
5 0 obj
<</Type/Page/MediaBox [0 0 324 252]
/Rotate 0/Parent 3 0 R
/Resources<</ProcSet[/PDF /Text]
/ExtGState 10 0 R
/Font 11 0 R
>>
/Contents 6 0 R
>>
endobj
3 0 obj
<< /Type /Pages /Kids [
5 0 R
] /Count 1
>>
endobj
1 0 obj
<</Type /Catalog /Pages 3 0 R
>>
endobj
4 0 obj
<</Type/ExtGState/Name/R4/TR/Identity/OPM 1/SM 0.02>>
endobj
9 0 obj
<</Subtype/Type1/BaseFont/Times-Roman/Type/Font/Name/R9>>
endobj
8 0 obj
<</Type/FontDescriptor/FontName/Times-Roman>>
endobj
2 0 obj
<</Producer (GNU Ghostscript 6.51)
>>endobj
xref
0 12
0000000000 65535 f
0000000971 00000 n
0000001222 00000 n
0000000912 00000 n
0000001019 00000 n
0000000752 00000 n
0000000015 00000 n
0000000673 00000 n
0000001161 00000 n
0000001088 00000 n
0000000692 00000 n
0000000722 00000 n
trailer
<< /Size 12 /Root 1 0 R /Info 2 0 R
>>
startxref
1274
%%EOF